//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, February 27, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
|
public class EquipLevelSelectBehaviour : MonoBehaviour
|
{
|
[SerializeField] RectTransform m_AppearanceSign;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
[SerializeField] Button m_Select;
|
[SerializeField] Image m_Icon;
|
[SerializeField] Text m_LevelName;
|
[SerializeField] RectTransform m_LockContainer;
|
[SerializeField] FontColorSizeConfig m_FontConfig;
|
|
EquipModel model { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
int level = 0;
|
EquipSet equipSet;
|
|
public void Display(int level)
|
{
|
this.level = level;
|
this.equipSet = model.GetEquipSet(level);
|
|
this.m_Select.SetListener(Select);
|
DisplayBaseInfo();
|
UpdateDynamicInfo(true);
|
}
|
|
public void Dispose()
|
{
|
}
|
|
private void LateUpdate()
|
{
|
UpdateDynamicInfo(false);
|
}
|
|
private void DisplayBaseInfo()
|
{
|
var realmConfig = RealmConfig.Get(this.equipSet.realm);
|
m_LevelName.text = Language.Get("RealmEquipName", realmConfig.Name);
|
var unLocked = equipSet.unLocked;
|
m_LockContainer.gameObject.SetActive(!unLocked);
|
m_Redpoint.redpointId = this.equipSet.redpoint.id;
|
}
|
|
private void UpdateDynamicInfo(bool force)
|
{
|
if (equipSet == null)
|
{
|
return;
|
}
|
|
if (force || equipSet.selected.dirty)
|
{
|
var selected = equipSet.selected.Fetch();
|
m_Icon.SetSprite(selected ? "Level1TitleSelected" : "Level1TitleUnselect");
|
m_LevelName.color = m_FontConfig.GetColorSize(selected ? "Selected" : "Normal").color;
|
}
|
}
|
|
private void Select()
|
{
|
if (this.equipSet.unLocked)
|
{
|
model.SelectSet(this.level);
|
}
|
else
|
{
|
var config = RealmConfig.Get(this.equipSet.realm);
|
SysNotifyMgr.Instance.ShowTip("RealmEquipNoEnough", config.Name, Language.Get("RealmEquipName", config.Name));
|
}
|
}
|
|
}
|
|
}
|