//-------------------------------------------------------- // [Author]: 第二世界 // [ Date ]: Wednesday, September 20, 2017 //-------------------------------------------------------- using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace vnxbqy.UI { public class CommonDungeonSelectWin : Window { [SerializeField] Button closeBtn; [SerializeField] Text titleText; [SerializeField] ScrollerController scroller; [SerializeField] Text info; DungeonModel model { get { return ModelCenter.Instance.GetModel(); } } CommonDungeonSelectModel commonDungeonSelectModel { get { return ModelCenter.Instance.GetModel(); } } #region Built-in protected override void BindController() { } protected override void AddListeners() { closeBtn.AddListener(CloseClick); } protected override void OnPreOpen() { model.dungeonRecordChangeEvent += UpdateDungeonTimes; model.updateDungeonBuyCnt += UpdateDungeonBuyCnt; scroller.OnRefreshCell += OnRefreshCell; info.text = Language.Get("CommonDungeon1", DailyQuestConfig.Get(commonDungeonSelectModel.selectDailyQuestType).RelatedType == 1 ? 0: 5); titleText.text = MapConfig.Get(model.currentDungeon.mapId).Name; scroller.Refresh(); int maxLine = FBGeneralTrainConfig.GetMaxLine(model.currentDungeon.mapId); for (int i = 1; i <= maxLine; i++) { scroller.AddCell(ScrollerDataType.Header, i); } scroller.Restart(); DungeonRecord dungeonRecord; if (model.TryGetRecord(model.currentDungeon.mapId, out dungeonRecord)) { scroller.JumpIndex(dungeonRecord.passLineID - 1); } } protected override void OnActived() { } protected override void OnAfterOpen() { } protected override void OnPreClose() { model.dungeonRecordChangeEvent -= UpdateDungeonTimes; model.updateDungeonBuyCnt -= UpdateDungeonBuyCnt; scroller.OnRefreshCell -= OnRefreshCell; } protected override void OnAfterClose() { } #endregion private void UpdateDungeonTimes(int mapID) { scroller.m_Scorller.RefreshActiveCellViews(); } private void UpdateDungeonBuyCnt() { scroller.m_Scorller.RefreshActiveCellViews(); } void OnRefreshCell(ScrollerDataType type, CellView cell) { var _cell = cell as CommonDungeonSelectCell; _cell.Display(cell.index); } } }