using Cal.DataTable; using FairyGUI; using System; using System.Collections.Generic; using UnityEngine; namespace ET { public class ActiveUIAwakeSyatem: AwakeSystem { public override void Awake(ActiveUI self) { self.Awake(); } } public class ActiveUIDestroySyatem: DestroySystem { public override void Destroy(ActiveUI self) { self.Destroy(); } } public class ActiveUI: Entity { public FUI_ActiveUI ui; private Scene zoneScene; private enum ActiveType { Day, Week, Month, Special, } private ActiveType type; private UnOrderMultiMap configDic = new UnOrderMultiMap(); public void Awake() { zoneScene = this.ZoneScene(); ui = GetParent(); AwakeAsync().Coroutine(); } private async ETVoid AwakeAsync() { this.ui.m_listTop.selectedIndex = (int) this.type; ShowLeft(); //顶部按钮 this.ui.m_listTop.onClickItem.Set(() => { type = (ActiveType) this.ui.m_listTop.selectedIndex; ShowLeft(); }); await ETTask.CompletedTask; } private void ShowLeft() { this.ui.m_listLeft.RemoveChildrenToPool(); this.ui.m_listItem.RemoveChildrenToPool(); configDic.Clear(); switch (type) { case ActiveType.Day: ShowDay(); break; case ActiveType.Week: break; case ActiveType.Month: break; case ActiveType.Special: break; default: throw new ArgumentOutOfRangeException(); } } private void ShowDay() { var list = ActivePerDayConfigCategory.Instance.activeIdDic[(byte) DateTime.Today.DayOfWeek]; if (list.Count == 0) return; foreach (long id in list) { ActivePerDayConfig activePerDayConfig = ActivePerDayConfigCategory.Instance.Get(id); configDic.Add(activePerDayConfig.Name, activePerDayConfig); } //左侧按钮 this.ui.m_listLeft.RemoveChildrenToPool(); foreach (string key in this.configDic.GetDictionary().Keys) { var btn = this.ui.m_listLeft.AddItemFromPool().asButton; btn.title = key; btn.onClick.Set(() => { var configList = configDic[key]; if (configList.Count != 0) { this.ui.m_listItem.RemoveChildrenToPool(); foreach (ActivePerDayConfig activePerDayConfig in configList) { var go = this.ui.m_listItem.AddItemFromPool().asLabel; go.title = activePerDayConfig.Desc; var _btn = go.GetChild("btn").asButton; _btn.onClick.Set(async () => { var ret = await this.zoneScene.GetComponent() .Call(new C2M_StartActive() { itemId = (int) activePerDayConfig.Id }); if (!ret.Message.IsNullOrEmpty()) { TipHelper.OpenUI(ret.Message); return; } }); } } }); } } public void Destroy() { configDic.Clear(); } } }