//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, February 27, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class CandidateEquipBehaviour : ScrollItem
|
{
|
[SerializeField] ImageEx m_BackGround;
|
[SerializeField] Image m_UnLockLabel;
|
[SerializeField] ItemCell m_ItemCell;
|
[SerializeField] Text m_EquipName;
|
[SerializeField] Text m_EquipSorce;
|
[SerializeField] Button m_Select;
|
[SerializeField] RectTransform m_SelectedContainer;
|
[SerializeField] Material m_NormalMaterial;
|
[SerializeField] Material m_GrayMaterial;
|
|
EquipModel model { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
CandidateEquip candidateEquip;
|
|
public override void Display(object _data)
|
{
|
base.Display(_data);
|
this.candidateEquip = (CandidateEquip)_data;
|
|
DisplayBaseInfo();
|
DisplayDynamicInfo(true);
|
m_Select.SetListener(OpenItemTipWin);
|
}
|
|
public override void Dispose()
|
{
|
candidateEquip = null;
|
}
|
|
private void LateUpdate()
|
{
|
DisplayDynamicInfo(false);
|
}
|
|
private void DisplayBaseInfo()
|
{
|
var equip = packModel.GetItemByGuid(this.candidateEquip.guid);
|
m_ItemCell.Init(equip, true);
|
m_ItemCell.button.enabled = false;
|
|
var isEquipLevelUnlocked = model.IsLevelUnLocked(equip.config.LV);
|
|
m_BackGround.material = isEquipLevelUnlocked ? m_NormalMaterial : m_GrayMaterial;
|
m_UnLockLabel.SetActive(!isEquipLevelUnlocked);
|
m_EquipName.text = equip.config.ItemName;
|
m_EquipName.color = UIHelper.GetUIColor(equip.config.ItemColor, true);
|
m_EquipSorce.text = Language.Get("DogzFunc106", equip.score);
|
|
var isBetter = model.CompareToCurrent(this.candidateEquip.guid) > 0;
|
m_EquipSorce.color = UIHelper.GetUIColor(isBetter ? TextColType.Green : TextColType.Red, true);
|
}
|
|
private void DisplayDynamicInfo(bool force)
|
{
|
if (force || candidateEquip.selected.dirty)
|
{
|
m_SelectedContainer.SetActive(candidateEquip.selected.Fetch());
|
}
|
}
|
|
private void OpenItemTipWin()
|
{
|
ItemTipUtility.Show(this.candidateEquip.guid);
|
if (this.candidateEquip.selected.value)
|
{
|
model.ClearRecommendCandidateEquip();
|
}
|
}
|
|
}
|
|
}
|