//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Tuesday, March 05, 2019
|
//--------------------------------------------------------
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class EquipStarLevelSelectBehaviour : MonoBehaviour
|
{
|
[SerializeField] Button m_Select;
|
[SerializeField] Image m_SelectImg;
|
[SerializeField] Text m_Title;
|
[SerializeField] RedpointBehaviour m_Redpoint;
|
|
readonly List<EquipStarUpgradeCandidateSlot> slotBehaviours = new List<EquipStarUpgradeCandidateSlot>();
|
|
EquipStarModel model { get { return ModelCenter.Instance.GetModel<EquipStarModel>(); } }
|
EquipModel equipModel { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
public int level { get; private set; }
|
public void Init(int level)
|
{
|
this.level = level;
|
this.m_Redpoint.redpointId = 1720000 + this.level * 100;
|
|
var equipSet = equipModel.GetEquipSet(level);
|
var realmConfig = RealmConfig.Get(equipSet.realm);
|
this.m_Title.text = realmConfig.Name;
|
|
m_Select.SetListener(Select);
|
}
|
|
public void UnInit()
|
{
|
Dispose();
|
|
this.level = 0;
|
this.m_Select.RemoveAllListeners();
|
}
|
|
public void Display()
|
{
|
var candidates = this.model.candidatePlaces.Fetch();
|
for (var i = candidates.Count - 1; i >= 0; i--)
|
{
|
var behaviour = EquipStarUpgradeCandidateSlotPool.Get();
|
behaviour.Display(candidates[i]);
|
behaviour.transform.SetParentEx(this.transform.parent.parent.Find("Container_Candidate/ContentEquip"), Vector3.zero, Quaternion.identity, Vector3.one);
|
behaviour.transform.SetSiblingIndex(0);
|
slotBehaviours.Add(behaviour);
|
}
|
m_SelectImg.SetActive(true);
|
this.m_Title.color = new Color32(255, 255, 255, 255);//"#ffffff";
|
}
|
|
public void Dispose()
|
{
|
for (var i = slotBehaviours.Count - 1; i >= 0; i--)
|
{
|
EquipStarUpgradeCandidateSlotPool.Release(slotBehaviours[i]);
|
}
|
|
slotBehaviours.Clear();
|
m_SelectImg.SetActive(false);
|
this.m_Title.color = new Color32(198, 181, 149, 255); //c6b595
|
}
|
|
private void Select()
|
{
|
if (model.selectedLevel.value == this.level)
|
{
|
|
}
|
else
|
{
|
model.SelectLevel(this.level);
|
|
var equipPosition = model.GetRecommendEquipPosition();
|
if (this.level == equipPosition.x)
|
model.SelectPlace(equipPosition);
|
}
|
}
|
|
}
|
|
|
}
|