using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
using vnxbqy.UI;
|
using System;
|
|
namespace EnhancedUI.EnhancedScroller
|
{
|
public class RoleTitleCell : ScrollerUI
|
{
|
[SerializeField] Image m_TitleIcon;
|
[SerializeField] Image m_BottomImg;
|
[SerializeField] Button m_UseTitleBtn;
|
[SerializeField] Image m_TitleEquipImg;
|
[SerializeField] Button m_TitleGetBtn;
|
[SerializeField] RectTransform m_ContainerNewGet;
|
[SerializeField] Button m_StarBtn;
|
[SerializeField] Text m_StarTxt;
|
[SerializeField] RedpointBehaviour redpoint;
|
|
TitleModel m_Model;
|
TitleModel model
|
{
|
get
|
{
|
return m_Model ?? (m_Model = ModelCenter.Instance.GetModel<TitleModel>());
|
}
|
}
|
|
TaskModel task { get { return ModelCenter.Instance.GetModel<TaskModel>(); } }
|
|
public override void Refresh(CellView cell)
|
{
|
int _index = cell.index;
|
if (_index >= model.roleTitleList.Count)
|
{
|
return;
|
}
|
int _titleId = model.roleTitleList[_index];
|
TitleData titleData = model.GetGainTitle(_titleId);
|
DienstgradConfig config = DienstgradConfig.Get(_titleId);
|
//m_TitleIcon.SetNativeSize();
|
|
UIFrame frame = m_TitleIcon.GetComponent<UIFrame>();
|
if (UIFrameMgr.Inst.ContainsDynamicImage(config.Image))
|
{
|
if (frame == null) frame = m_TitleIcon.gameObject.AddComponent<UIFrame>();
|
m_TitleIcon.raycastTarget = false;
|
frame.ResetFrame(config.Image);
|
frame.enabled = true;
|
}
|
else
|
{
|
if (frame != null) frame.enabled = false;
|
m_TitleIcon.SetSprite(config.Image);
|
}
|
|
if (model.presentSelectTitle == model.roleTitleList[_index])
|
{
|
m_BottomImg.SetSprite("Title_RightWindow");
|
}
|
else
|
{
|
m_BottomImg.SetSprite("Title_PopupWindow");
|
}
|
m_TitleGetBtn.SetActive(!model.IsTitleGain(_titleId) && config.gotoId > 0);
|
m_UseTitleBtn.SetActive(model.IsTitleGain(_titleId));
|
m_ContainerNewGet.SetActive(model.IsNewGet(_titleId));
|
m_UseTitleBtn.onClick.RemoveAllListeners();
|
if (titleData != null)
|
{
|
m_UseTitleBtn.onClick.AddListener(()=>
|
{
|
OnTitleUseClick(_index);
|
});
|
m_TitleEquipImg.SetActive(titleData.isEquiped);
|
}
|
m_TitleGetBtn.RemoveAllListeners();
|
if (titleData == null && config.gotoId > 0)
|
{
|
m_TitleGetBtn.AddListener(() =>
|
{
|
if (config.gotoId > 0)
|
{
|
if (config.missionId > 0
|
&& task.GetQuestState(config.missionId) == -1)
|
{
|
var taskConfig = PyTaskConfig.Get(config.missionId);
|
var taskName = string.Empty;
|
if (taskConfig != null)
|
{
|
var taskInfo = TASKINFOConfig.Get(taskConfig.name);
|
if (taskInfo != null)
|
{
|
taskName = taskInfo.show_writing;
|
}
|
}
|
SysNotifyMgr.Instance.ShowTip("RoleTitle_1", taskName);
|
return;
|
}
|
WindowJumpMgr.Instance.WindowJumpTo((JumpUIType)config.gotoId);
|
}
|
});
|
}
|
|
if (titleData == null || !TitleStarUpConfig.titleIDToIDs.ContainsKey(_titleId))
|
{
|
m_StarBtn.SetActive(false);
|
redpoint.redpointId = 0;
|
}
|
else
|
{
|
redpoint.redpointId = 1010104 * 1000 + _titleId;
|
m_StarBtn.SetActive(true);
|
m_StarTxt.text = Language.Get("EquipStar11", model.GetTitleStar(_titleId));
|
m_StarBtn.AddListener(() =>
|
{
|
model.selectTitleId = _titleId;
|
WindowJumpMgr.Instance.WindowJumpToEx("TitleStarUpWin");
|
});
|
}
|
}
|
|
private void OnTitleUseClick(int _index)
|
{
|
int id = model.roleTitleList[_index];
|
if (!model.IsTitleGain(id))
|
{
|
return;
|
}
|
TitleData title = model.GetGainTitle(id);
|
C0337_tagCPlayerChangeDienstgrad equipTitlePack = new C0337_tagCPlayerChangeDienstgrad();
|
equipTitlePack.GradID = (uint)id;
|
equipTitlePack.State = (byte)(title.isEquiped ? 0 : 1);
|
GameNetSystem.Instance.SendInfo(equipTitlePack);
|
}
|
}
|
}
|
|