255 lines
10 KiB
C#
255 lines
10 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 readonly 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;
|
|
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:
|
|
ShowMonth();
|
|
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;
|
|
var uiItem = FUI_LabelActionItem.GetFormPool(this.zoneScene, go);
|
|
uiItem.m_btn.self.title = "确定";
|
|
uiItem.self.title = activePerDayConfig.Desc;
|
|
var _btn = uiItem.m_btn.self;
|
|
uiItem.m_controller.selectedIndex = 0;
|
|
uiItem.m_canClick.selectedIndex = 0;
|
|
_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;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
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;
|
|
uiItem.m_btn.self.title = activeComponent.isGetSingninReward? "已领取" : "待领取";
|
|
}
|
|
else
|
|
{
|
|
uiItem.m_canClick.selectedIndex = 1;
|
|
uiItem.m_btn.self.title = "待领取";
|
|
}
|
|
|
|
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;
|
|
uiItem.m_canClick.selectedIndex = 1;
|
|
uiItem.m_btn.self.title = "已领取";
|
|
});
|
|
}
|
|
});
|
|
btn = this.ui.m_listLeft.AddItemFromPool().asButton;
|
|
btn.title = "累计签到奖励";
|
|
btn.onClick.Set(() =>
|
|
{
|
|
this.ui.m_listItem.RemoveChildrenToPool();
|
|
var now =DateTime.UtcNow;
|
|
var configList = SignInRewardMonthCategory.Instance.GetList(now);
|
|
foreach (SignInRewardMonth config in configList)
|
|
{
|
|
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 (config.Times <= activeComponent.signinMonthCount)
|
|
{
|
|
if (!activeComponent.gotSigninMonthTimesList.Contains(config.Times))
|
|
{
|
|
uiItem.m_canClick.selectedIndex = 0;
|
|
uiItem.m_btn.self.title = "待领取";
|
|
}
|
|
else
|
|
{
|
|
uiItem.m_canClick.selectedIndex = 1;
|
|
uiItem.m_btn.self.title = "已领取";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
uiItem.m_canClick.selectedIndex = 1;
|
|
uiItem.m_btn.self.title = "待领取";
|
|
}
|
|
|
|
controller.selectedIndex = 1;
|
|
uiItem.self.title = $"当月你已经累计签到{activeComponent.signinMonthCount}天 累计{config.Times}天奖励如下,请按时接收!";
|
|
uiItem.m_list.RemoveChildrenToPool();
|
|
foreach (var 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_GetSigninInMonthReward>(new C2M_GetSigninInMonthReward() { configId = (int) config.Id });
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
{
|
|
TipHelper.OpenUI(ret.Message);
|
|
return;
|
|
}
|
|
|
|
activeComponent.gotSigninMonthTimesList.Add(config.Times);
|
|
uiItem.m_canClick.selectedIndex = 1;
|
|
uiItem.m_btn.self.title = "已领取";
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
public void Destroy()
|
|
{
|
|
configDic.Clear();
|
|
}
|
|
}
|
|
} |