//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Wednesday, August 01, 2018
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using TableConfig;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace Snxxz.UI {
|
|
public class TrialExchangeWin : Window
|
{
|
[SerializeField] ScrollerController m_Controller;
|
[SerializeField] Text m_SelectClass;
|
[SerializeField] Button m_SelectClassUp;
|
[SerializeField] TrialSelectClassBehaviour m_SelectClassBehaviour;
|
[SerializeField] Button m_Close;
|
|
TrialDungeonModel model { get { return ModelCenter.Instance.GetModel<TrialDungeonModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
PlayerPackModel packModel { get { return ModelCenter.Instance.GetModel<PlayerPackModel>(); } }
|
#region Built-in
|
protected override void BindController()
|
{
|
|
}
|
|
protected override void AddListeners()
|
{
|
m_Controller.OnRefreshCell += OnRefreshCell;
|
m_Close.onClick.AddListener(CloseClick);
|
m_SelectClassUp.onClick.AddListener(SelectClassUp);
|
}
|
|
protected override void OnPreOpen()
|
{
|
model.SetDayRemind();
|
model.selectEquipClass = 1;
|
m_SelectClassBehaviour.gameObject.SetActive(false);
|
m_SelectClassUp.transform.localEulerAngles = Vector3.zero.SetZ(180);
|
foreach (var mapID in dungeonModel.DungeonMapDungeons(60010))
|
{
|
DungeonConfig _tagDungeonModel = ConfigManager.Instance.GetTemplate<DungeonConfig>(mapID);
|
DungeonRecord dungeonRecord;
|
if (dungeonModel.TryGetDungeonRecord(60010, out dungeonRecord))
|
{
|
if (dungeonRecord.lineGrades != null && dungeonRecord.lineGrades.ContainsKey(_tagDungeonModel.LineID))
|
{
|
model.selectEquipClass = model.LineToTokenClass(_tagDungeonModel.LineID);
|
}
|
}
|
}
|
model.SelectEquipClassEvent += SelectEquipClassEvent;
|
packModel.RefreshItemCountAct += RefreshItemCountAct;
|
Display();
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
model.SelectEquipClassEvent -= SelectEquipClassEvent;
|
packModel.RefreshItemCountAct -= RefreshItemCountAct;
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
#endregion
|
private void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
TrialExchangeCell trialExchangeCell = cell as TrialExchangeCell;
|
trialExchangeCell.Display(cell.index);
|
}
|
|
private void SelectClassUp()
|
{
|
bool _up = m_SelectClassBehaviour.gameObject.activeSelf;
|
m_SelectClassBehaviour.gameObject.SetActive(!_up);
|
if (!_up)
|
{
|
m_SelectClassBehaviour.Display();
|
}
|
m_SelectClassUp.transform.localEulerAngles = Vector3.zero.SetZ(_up ? 180 : 0);
|
}
|
|
void Display()
|
{
|
DisplayTrialExchanges();
|
DisplaySelectClass();
|
}
|
|
void DisplayTrialExchanges()
|
{
|
m_Controller.Refresh();
|
if (model.selectEquipClass == 1)
|
{
|
var configs = ConfigManager.Instance.GetAllValues<TrialExchangeConfig>();
|
for (int i = 0; i < configs.Count; i++)
|
{
|
m_Controller.AddCell(ScrollerDataType.Header, configs[i].id);
|
}
|
}
|
else
|
{
|
List<TrialExchangeConfig> list;
|
if (model.TryGetTrialExchanges(model.selectEquipClass, out list))
|
{
|
for (int i = 0; i < list.Count; i++)
|
{
|
m_Controller.AddCell(ScrollerDataType.Header, list[i].id);
|
}
|
}
|
}
|
m_Controller.Restart();
|
}
|
|
private void RefreshItemCountAct(PackType packtype, int arg2, int itemId)
|
{
|
if (packtype == PackType.rptItem && model.trialTokens.Contains(itemId))
|
{
|
m_Controller.m_Scorller.RefreshActiveCellViews();
|
}
|
}
|
|
void DisplaySelectClass()
|
{
|
m_SelectClass.text = model.selectEquipClass == 1 ? Language.Get("TrialClassSeleclAll") :
|
Language.Get("EquipSuitLV", Language.Get(StringUtility.Contact("Num_CHS_", model.selectEquipClass)));
|
}
|
|
private void SelectEquipClassEvent()
|
{
|
DisplayTrialExchanges();
|
DisplaySelectClass();
|
bool _up = m_SelectClassBehaviour.gameObject.activeSelf;
|
m_SelectClassUp.transform.localEulerAngles = Vector3.zero.SetZ(_up ? 0 : 180);
|
}
|
}
|
|
}
|