110 lines
3.4 KiB
C#
110 lines
3.4 KiB
C#
|
using Cal.DataTable;
|
||
|
using FairyGUI;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public class ActiveUIAwakeSyatem: AwakeSystem<ActiveUI>
|
||
|
{
|
||
|
public override void Awake(ActiveUI self)
|
||
|
{
|
||
|
self.Awake();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public class ActiveUIDestroySyatem: DestroySystem<ActiveUI>
|
||
|
{
|
||
|
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<string, ActivePerDayConfig> configDic = new UnOrderMultiMap<string, ActivePerDayConfig>();
|
||
|
|
||
|
public void Awake()
|
||
|
{
|
||
|
zoneScene = this.ZoneScene();
|
||
|
ui = GetParent<FUI_ActiveUI>();
|
||
|
AwakeAsync().Coroutine();
|
||
|
}
|
||
|
|
||
|
private async ETVoid AwakeAsync()
|
||
|
{
|
||
|
this.ui.m_listTop.selectedIndex = (int) this.type;
|
||
|
//顶部按钮
|
||
|
this.ui.m_listTop.onClickItem.Set(() =>
|
||
|
{
|
||
|
type = (ActiveType) this.ui.m_listTop.selectedIndex;
|
||
|
ShowLeft();
|
||
|
});
|
||
|
|
||
|
await ETTask.CompletedTask;
|
||
|
}
|
||
|
|
||
|
private void ShowLeft()
|
||
|
{
|
||
|
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<SessionComponent>()
|
||
|
.Call<M2C_StartActive>(new C2M_StartActive() { itemId = (int) activePerDayConfig.Id });
|
||
|
if (!ret.Message.IsNullOrEmpty())
|
||
|
{
|
||
|
TipHelper.OpenUI(ret.Message);
|
||
|
return;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void Destroy()
|
||
|
{
|
||
|
configDic.Clear();
|
||
|
}
|
||
|
}
|
||
|
}
|