//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Thursday, February 28, 2019
|
//--------------------------------------------------------
|
using UnityEngine;
|
using System.Collections;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
|
public class EquipStarUpgradeCandidateSlot : MonoBehaviour
|
{
|
[SerializeField] Image m_BackGround;
|
[SerializeField] Image m_EmptyItem;
|
[SerializeField] ItemCell m_ItemCell;
|
[SerializeField] Text m_EquipStar;
|
[SerializeField] Text m_Description1;
|
[SerializeField] Text m_Description2;
|
[SerializeField] Button m_Select;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
|
public bool suitEffectDirty { get; set; }
|
|
EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
PackModel packModel { get { return ModelCenter.Instance.GetModel<PackModel>(); } }
|
|
EquipStarUpgradeCandidate candidate;
|
|
public void Display(EquipStarUpgradeCandidate candidate)
|
{
|
this.candidate = candidate;
|
this.m_Redpoint.redpointId = 1720000 + this.candidate.equipPosition.x * 100 + this.candidate.equipPosition.y;
|
DisplayBaseInfo();
|
DisplayDynamicInfo(true);
|
|
m_Select.SetListener(() => { model.SelectPlace(this.candidate.equipPosition); });
|
}
|
|
public void Dispose()
|
{
|
}
|
|
private void LateUpdate()
|
{
|
DisplayDynamicInfo(false);
|
}
|
|
private void DisplayBaseInfo()
|
{
|
var guid = equipModel.GetEquip(this.candidate.equipPosition);
|
var item = packModel.GetItemByGuid(guid);
|
if (item == null)
|
{
|
m_ItemCell.SetActive(false);
|
m_EmptyItem.SetActive(true);
|
var place = this.candidate.equipPosition.y;
|
m_Description1.text = Language.Get("L1076", UIHelper.GetEquipPlaceName(place));
|
m_Description1.color = UIHelper.GetUIColor(TextColType.NavyBrown, true);
|
m_Description2.text = Language.Get("EquipSuitPanel_IsPutOnText_1");
|
}
|
else
|
{
|
m_ItemCell.suitEffectDirty = suitEffectDirty;
|
m_ItemCell.SetActive(true);
|
m_EmptyItem.SetActive(false);
|
m_ItemCell.Init(item);
|
m_ItemCell.button.enabled = false;
|
m_Description1.text = item.config.ItemName;
|
m_Description1.color = UIHelper.GetUIColor(item.config.ItemColor, true);
|
m_Description2.text = string.Empty;
|
|
suitEffectDirty = false;
|
}
|
}
|
|
private void DisplayDynamicInfo(bool force)
|
{
|
if (force || this.candidate.selected.dirty)
|
{
|
var selected = this.candidate.selected.Fetch();
|
m_BackGround.SetSprite(selected ? "Title_RightWindow" : "Title_PopupWindow");
|
}
|
|
if (force || this.candidate.starLevel.dirty)
|
{
|
var starLevel = this.candidate.starLevel.Fetch();
|
m_EquipStar.text = starLevel >= 1 ? Language.Get("EquipStarLevel", starLevel) : "";
|
}
|
|
}
|
}
|
|
public class EquipStarUpgradeCandidateSlotPool
|
{
|
static GameObjectPool pool;
|
|
public static EquipStarUpgradeCandidateSlot Get()
|
{
|
if (pool == null)
|
{
|
pool = new GameObjectPool(UILoader.LoadPrefab("EquipStarUpgradeCandidateSlot"));
|
}
|
|
var instance = pool.Request();
|
instance.SetActive(true);
|
return instance.GetComponent<EquipStarUpgradeCandidateSlot>();
|
}
|
|
public static void Release(EquipStarUpgradeCandidateSlot behaviour)
|
{
|
if (pool == null)
|
{
|
return;
|
}
|
|
if (behaviour == null)
|
{
|
return;
|
}
|
|
behaviour.suitEffectDirty = true;
|
behaviour.SetActive(false);
|
behaviour.transform.SetParent(null);
|
pool.Release(behaviour.gameObject);
|
}
|
}
|
|
}
|