using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI
|
{
|
public class CandidateEquipWidget : MonoBehaviour
|
{
|
[SerializeField] Text m_Title;
|
[SerializeField] RectTransform m_CandidateContainer;
|
[SerializeField] CyclicScroll m_CandidateEquipScroll;
|
|
[SerializeField] RectTransform m_GetWayContainer;
|
[SerializeField] WayCell[] m_GetWayCells;
|
|
EquipModel model { get { return ModelCenter.Instance.GetModel<EquipModel>(); } }
|
|
int place = 0;
|
public void Display(int place, List<CandidateEquip> candidates)
|
{
|
this.place = place;
|
|
if (place == 0)
|
{
|
m_Title.text = "全部";
|
}
|
else
|
{
|
m_Title.text = UIHelper.GetEquipPlaceName(place);
|
}
|
|
if (!candidates.IsNullOrEmpty())
|
{
|
m_CandidateContainer.gameObject.SetActive(true);
|
m_GetWayContainer.gameObject.SetActive(false);
|
m_CandidateEquipScroll.Init(candidates);
|
}
|
else
|
{
|
m_CandidateContainer.gameObject.SetActive(false);
|
m_GetWayContainer.gameObject.SetActive(true);
|
DisplayGetWays();
|
}
|
}
|
|
public void Dispose()
|
{
|
|
}
|
|
private void DisplayGetWays()
|
{
|
var getWays = model.GetGetWays(model.selectedLevel.value, place);
|
if (getWays == null)
|
{
|
return;
|
}
|
|
for (var i = 0; i < m_GetWayCells.Length; i++)
|
{
|
var behaviour = m_GetWayCells[i];
|
if (i < getWays.Count)
|
{
|
behaviour.gameObject.SetActive(true);
|
var config = GetItemWaysConfig.Get(getWays[i]);
|
behaviour.icon.SetSprite(config.Icon);
|
behaviour.wayName.text = config.Text;
|
behaviour.funcName.text = config.name;
|
behaviour.wayButton.SetListener(() =>
|
{
|
WindowCenter.Instance.Close<EquipFrameWin>();
|
ModelCenter.Instance.GetModel<GetItemPathModel>().ClickGetWay(config.ID);
|
});
|
}
|
else
|
{
|
behaviour.gameObject.SetActive(false);
|
}
|
}
|
|
}
|
|
}
|
|
}
|