2021-05-05 13:36:19 +08:00
|
|
|
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;
|
2021-05-07 23:50:22 +08:00
|
|
|
ShowLeft();
|
2021-05-05 13:36:19 +08:00
|
|
|
//顶部按钮
|
|
|
|
this.ui.m_listTop.onClickItem.Set(() =>
|
|
|
|
{
|
|
|
|
type = (ActiveType) this.ui.m_listTop.selectedIndex;
|
|
|
|
ShowLeft();
|
|
|
|
});
|
|
|
|
|
|
|
|
await ETTask.CompletedTask;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ShowLeft()
|
2021-05-07 23:50:22 +08:00
|
|
|
{
|
|
|
|
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:
|
2021-05-21 22:50:06 +08:00
|
|
|
ShowMonth();
|
2021-05-07 23:50:22 +08:00
|
|
|
break;
|
|
|
|
case ActiveType.Special:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
throw new ArgumentOutOfRangeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ShowDay()
|
2021-05-05 13:36:19 +08:00
|
|
|
{
|
|
|
|
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;
|
2021-05-21 22:50:06 +08:00
|
|
|
var uiItem = FUI_LabelActionItem.GetFormPool(this.zoneScene,go);
|
|
|
|
uiItem.self.title = activePerDayConfig.Desc;
|
|
|
|
var _btn = uiItem.m_btn.self;
|
|
|
|
uiItem.m_controller.selectedIndex = 0;
|
|
|
|
uiItem.m_canClick.selectedIndex = 0;
|
2021-05-05 13:36:19 +08:00
|
|
|
_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;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-21 22:50:06 +08:00
|
|
|
private void ShowMonth()
|
|
|
|
{
|
|
|
|
//左侧按钮
|
|
|
|
this.ui.m_listLeft.RemoveChildrenToPool();
|
|
|
|
ActiveComponent activeComponent = this.zoneScene.GetComponent<ActiveComponent>();
|
|
|
|
|
|
|
|
var btn = this.ui.m_listLeft.AddItemFromPool().asButton;
|
|
|
|
btn.title = "签到奖励";
|
|
|
|
btn.onClick.Set(() =>
|
|
|
|
{
|
|
|
|
this.ui.m_listItem.RemoveChildrenToPool();
|
|
|
|
for (int i = activeComponent.currSigninConfigId; i < activeComponent.currSigninConfigId + 30; i++)
|
|
|
|
{
|
|
|
|
SignInRewardConfig config = SignInRewardConfigCategory.Instance.Get(i,false);
|
|
|
|
if(config==null) continue;
|
|
|
|
var go = this.ui.m_listItem.AddItemFromPool().asLabel;
|
|
|
|
var uiItem = FUI_LabelActionItem.GetFormPool(this.zoneScene,go);
|
|
|
|
var _btn =uiItem.m_btn.self;
|
|
|
|
var controller = uiItem.m_controller;
|
|
|
|
|
|
|
|
if (i == activeComponent.currSigninConfigId)
|
|
|
|
{
|
|
|
|
uiItem.m_canClick.selectedIndex= activeComponent.isGetSingninReward?1:0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
uiItem.m_canClick.selectedIndex = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
controller.selectedIndex = 1;
|
|
|
|
uiItem.self.title = $"{config.Year}-{config.Month}-{config.Day} 签到奖励,请接收!";
|
|
|
|
uiItem.m_list.RemoveChildrenToPool();
|
|
|
|
foreach (SignInRewardConfig.Rewards rewards in config.RewardsArr)
|
|
|
|
{
|
|
|
|
var btnSlot=uiItem.m_list.AddItemFromPool().asButton;
|
|
|
|
btnSlot.icon =UIPackage.GetItemURL(FUIPackage.Bag, BagHelper.GetIconName(rewards._Id).Item2);
|
|
|
|
btnSlot.title = rewards.Count.ToString();
|
|
|
|
}
|
|
|
|
_btn.onClick.Set(async() =>
|
|
|
|
{
|
|
|
|
var ret = await this.zoneScene.GetComponent<SessionComponent>()
|
|
|
|
.Call<M2C_GetSigninReward>(new C2M_GetSigninReward() { configId = (int) config.Id });
|
|
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
|
|
{
|
|
|
|
TipHelper.OpenUI(ret.Message);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
activeComponent.isGetSingninReward = true;
|
|
|
|
_btn.grayed = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-05-05 13:36:19 +08:00
|
|
|
public void Destroy()
|
|
|
|
{
|
|
|
|
configDic.Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|