From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/XOperatingActivityDocument.cs | 654 +++++++++++++++++++++ 1 file changed, 654 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XOperatingActivityDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XOperatingActivityDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XOperatingActivityDocument.cs b/Client/Assets/Scripts/XMainClient/XOperatingActivityDocument.cs new file mode 100644 index 00000000..3079fe35 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XOperatingActivityDocument.cs @@ -0,0 +1,654 @@ +using System; +using System.Collections.Generic; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XOperatingActivityDocument : XDocComponent + { + public override uint ID + { + get + { + return XOperatingActivityDocument.uuID; + } + } + + public static OperatingActivity OperatingActivityTable + { + get + { + return XOperatingActivityDocument.m_OperatingActivityTable; + } + } + + public List SealDatas + { + get + { + bool flag = this._staticSealDatas.Count == 0 && this.CurSealActID > 0u; + if (flag) + { + this.InitSealData(); + } + return this._staticSealDatas; + } + } + + public uint CurSealActID + { + get + { + return this.curSealActid; + } + set + { + this.curSealActid = value; + bool flag = this.curSealActid == 0u; + if (flag) + { + DlgBase.singleton.UpdateTab(); + } + else + { + this.InitSealData(); + } + } + } + + public static XOperatingActivityDocument Doc + { + get + { + return XSingleton.singleton.Doc.GetXComponent(XOperatingActivityDocument.uuID) as XOperatingActivityDocument; + } + } + + public XOperatingActivityView View { get; set; } + + public HashSet systemIds + { + get + { + bool flag = this.m_systemIds == null || this.m_systemIds.Count == 0; + if (flag) + { + this.m_systemIds = new HashSet(); + for (int i = 0; i < XOperatingActivityDocument.m_OperatingActivityTable.Table.Length; i++) + { + bool flag2 = XOperatingActivityDocument.m_OperatingActivityTable.Table[i] != null; + if (flag2) + { + this.m_systemIds.Add(XOperatingActivityDocument.m_OperatingActivityTable.Table[i].SysID); + } + } + } + return this.m_systemIds; + } + } + + private bool HolidayRedPoint + { + get + { + return this._holiday_data.LeftCount > 0u; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("XOperatingActivityDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + private static OperatingActivity m_OperatingActivityTable = new OperatingActivity(); + + private static FestScene m_FestivalTable = new FestScene(); + + public HistoryMaxStruct HisMaxLevel = new HistoryMaxStruct(); + + public Dictionary _forzenStates = new Dictionary(); + + private HashSet m_systemIds; + + protected List _staticSealDatas = new List(); + + protected uint curSealActid = 0u; + + private XOperatingActivityDocument.HolidayData _holiday_data; + + public XOperatingActivityDocument.LuckyTurntableInfo m_LuckyTurntableData = new XOperatingActivityDocument.LuckyTurntableInfo(); + + private Dictionary m_levelRedDotDic = new Dictionary(); + + private struct HolidayData + { + public uint HolidayID; + + public uint LeftCount; + + public uint LeftTime; + + public uint SceneID; + + public void Init() + { + this.HolidayID = 0u; + this.LeftCount = 0u; + this.LeftTime = 0u; + this.SceneID = 0u; + } + } + + public class LuckyTurntableItem + { + public int ItemID; + + public int ItemCount; + + public bool HasReceived; + } + + public class LuckyTurntableInfo + { + public int CurrencyType; + + public uint Price; + + public bool IsPay; + + public List Items = new List(); + + public bool CanBuy; + + public void RefreshItems(List records) + { + bool flag = this.Items.Count != records.Count; + if (flag) + { + this.Items.Clear(); + for (int i = records.Count; i > 0; i--) + { + this.Items.Add(new XOperatingActivityDocument.LuckyTurntableItem()); + } + } + this.CanBuy = false; + for (int j = 0; j < records.Count; j++) + { + XOperatingActivityDocument.LuckyTurntableItem luckyTurntableItem = this.Items[j]; + ItemRecord itemRecord = records[j]; + luckyTurntableItem.ItemID = (int)itemRecord.itemID; + luckyTurntableItem.ItemCount = (int)itemRecord.itemCount; + luckyTurntableItem.HasReceived = itemRecord.isreceive; + bool flag2 = !luckyTurntableItem.HasReceived; + if (flag2) + { + this.CanBuy = true; + } + } + } + } + + public void RequestGetLuckyTurntableData() + { + RpcC2G_GetLuckyActivityInfo rpc = new RpcC2G_GetLuckyActivityInfo(); + XSingleton.singleton.Send(rpc); + } + + public void OnReceiveGetLuckyTurntableData(GetLuckyActivityInfoRes res) + { + this.m_LuckyTurntableData.CurrencyType = (int)res.currencytype; + this.m_LuckyTurntableData.Price = res.price; + this.m_LuckyTurntableData.IsPay = res.ispay; + this.m_LuckyTurntableData.RefreshItems(res.itemrecord); + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + bool flag2 = DlgBase.singleton.m_luckyTurntableFrameHandler != null; + if (flag2) + { + DlgBase.singleton.m_luckyTurntableFrameHandler.RefeshInfo(); + } + } + } + + public void RequestBuyLuckyTurntable() + { + RpcC2G_BuyDraw rpc = new RpcC2G_BuyDraw(); + XSingleton.singleton.Send(rpc); + } + + public void OnReceiveBuyLuckyTurntable() + { + this.m_LuckyTurntableData.IsPay = true; + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + bool flag2 = DlgBase.singleton.m_luckyTurntableFrameHandler != null; + if (flag2) + { + DlgBase.singleton.m_luckyTurntableFrameHandler.OnBuy(); + } + } + } + + public void RequestUseLuckyTurntable() + { + RpcC2G_LotteryDraw rpc = new RpcC2G_LotteryDraw(); + XSingleton.singleton.Send(rpc); + } + + public void OnReceiveUseLuckyTurntable(LotteryDrawRes res) + { + this.m_LuckyTurntableData.CurrencyType = (int)res.currencytype; + this.m_LuckyTurntableData.Price = res.price; + this.m_LuckyTurntableData.IsPay = false; + this.m_LuckyTurntableData.RefreshItems(res.itemrecord); + int index = (int)res.index; + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + bool flag2 = DlgBase.singleton.m_luckyTurntableFrameHandler != null; + if (flag2) + { + DlgBase.singleton.m_luckyTurntableFrameHandler.OnGetIndex(index); + } + } + } + + public static void Execute(OnLoadedCallback callback = null) + { + XOperatingActivityDocument.AsyncLoader.AddTask("Table/OperatingActivity", XOperatingActivityDocument.m_OperatingActivityTable, false); + XOperatingActivityDocument.AsyncLoader.AddTask("Table/festivalscenelist", XOperatingActivityDocument.m_FestivalTable, false); + XOperatingActivityDocument.AsyncLoader.Execute(callback); + } + + public override void OnAttachToHost(XObject host) + { + base.OnAttachToHost(host); + } + + protected override void EventSubscribe() + { + base.EventSubscribe(); + base.RegisterEvent(XEventDefine.XEvent_ActivityTaskUpdate, new XComponent.XEventHandler(this.OnSealUpdate)); + base.RegisterEvent(XEventDefine.XEvent_PlayerLevelChange, new XComponent.XEventHandler(this.OnPlayerLevelChange)); + } + + public override void OnDetachFromHost() + { + base.OnDetachFromHost(); + this.DetachPandoraSDKRedPoint(); + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + this.SendQueryHolidayData(); + } + + public override void OnEnterSceneFinally() + { + base.OnEnterSceneFinally(); + this.SendQueryHolidayData(); + this.HisMaxLevel.Replace(); + bool flag = XSingleton.singleton.GetSceneType(XSingleton.singleton.SceneID) == SceneType.SCENE_HALL; + if (flag) + { + this.RefreshRedPoints(); + } + } + + public bool SysIsOpen(XSysDefine sys) + { + bool result; + if (sys != XSysDefine.XSys_LevelSeal) + { + result = XSingleton.singleton.IsSystemOpened(sys); + } + else + { + result = XDocuments.GetSpecificDocument(XLevelSealDocument.uuID).IsShowLevelSealIcon(); + } + return result; + } + + public bool IsHadRedDot() + { + bool flag = false; + foreach (KeyValuePair keyValuePair in this.m_levelRedDotDic) + { + flag |= keyValuePair.Value; + } + XAnnouncementDocument specificDocument = XDocuments.GetSpecificDocument(XAnnouncementDocument.uuID); + flag |= XSingleton.singleton.GetSysRedPointState(XSysDefine.XSys_LuckyTurntable); + return ((FirstPassDocument.Doc.IsHadOutRedDot | this.IsFrozenSealHadRedDot()) || flag) | specificDocument.RedPoint | this.HolidayRedPoint | XCampDuelDocument.Doc.IsRedPoint(); + } + + public bool IsFrozenSealHadRedDot() + { + foreach (SuperActivityTask.RowData rowData in this.SealDatas) + { + bool flag = XTempActivityDocument.Doc.GetActivityState(this.curSealActid, rowData.taskid) == 1u; + if (flag) + { + return true; + } + } + return false; + } + + public void RefreshRedPoints() + { + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_OperatingActivity, true); + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.RefreshRedpoint(); + } + } + + public void OnSystemChanged(List openIds, List closeIds) + { + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + int num = 0; + bool flag2 = this.systemIds != null; + if (flag2) + { + for (int i = 0; i < openIds.Count; i++) + { + bool flag3 = this.systemIds.Contains(openIds[i]); + if (flag3) + { + num = 1; + break; + } + } + for (int j = 0; j < closeIds.Count; j++) + { + bool flag4 = this.systemIds.Contains(closeIds[j]); + if (flag4) + { + bool flag5 = num == 1; + if (flag5) + { + num = 3; + } + else + { + num = 2; + } + break; + } + } + } + bool flag6 = num == 0; + if (!flag6) + { + bool flag7 = num == 1; + if (flag7) + { + DlgBase.singleton.RefreshUI(null); + } + else + { + DlgBase.singleton.RefreshUI(closeIds); + } + } + } + } + + public bool GetTabRedDotState(XSysDefine sys) + { + bool flag = false; + bool result; + if (sys != XSysDefine.XSys_FirstPass) + { + switch (sys) + { + case XSysDefine.XSys_CrushingSeal: + this.m_levelRedDotDic.TryGetValue(sys, out flag); + return this.IsFrozenSealHadRedDot() || flag; + case XSysDefine.XSys_WeekNest: + case (XSysDefine)608: + break; + case XSysDefine.XSys_Holiday: + return this.HolidayRedPoint; + case XSysDefine.XSys_Announcement: + { + XAnnouncementDocument specificDocument = XDocuments.GetSpecificDocument(XAnnouncementDocument.uuID); + return specificDocument.RedPoint; + } + default: + if (sys == XSysDefine.XSys_CampDuel) + { + return XCampDuelDocument.Doc.IsRedPoint(); + } + break; + } + this.m_levelRedDotDic.TryGetValue(sys, out flag); + result = (flag | XSingleton.singleton.GetSysRedPointState(sys)); + } + else + { + this.m_levelRedDotDic.TryGetValue(sys, out flag); + result = (FirstPassDocument.Doc.IsHadOutRedDot || flag); + } + return result; + } + + public void InitSealData() + { + this._staticSealDatas = XTempActivityDocument.Doc.GetDataByActivityType(this.curSealActid); + } + + public void SealOffsetDayUpdate() + { + this.CurSealActID = XTempActivityDocument.Doc.GetCrushingSealActid(); + DlgBase.singleton.UpdateSealTime(); + } + + public void RefeshLevelRedDot(uint curLevel) + { + bool flag = this.HisMaxLevel.PreLevel >= curLevel; + if (!flag) + { + this.HisMaxLevel.PreLevel = curLevel; + for (int i = 0; i < XOperatingActivityDocument.OperatingActivityTable.Table.Length; i++) + { + OperatingActivity.RowData rowData = XOperatingActivityDocument.OperatingActivityTable.Table[i]; + int sysOpenLevel = XSingleton.singleton.GetSysOpenLevel((int)rowData.SysID); + bool flag2 = (ulong)curLevel == (ulong)((long)sysOpenLevel); + if (flag2) + { + bool flag3 = this.m_levelRedDotDic.ContainsKey((XSysDefine)rowData.SysID); + if (flag3) + { + this.m_levelRedDotDic[(XSysDefine)rowData.SysID] = true; + } + else + { + this.m_levelRedDotDic.Add((XSysDefine)rowData.SysID, true); + } + } + else + { + bool flag4 = !this.m_levelRedDotDic.ContainsKey((XSysDefine)rowData.SysID); + if (flag4) + { + this.m_levelRedDotDic.Add((XSysDefine)rowData.SysID, false); + } + } + } + this.RefreshRedPoints(); + } + } + + public void CancleLevelRedDot(XSysDefine define) + { + bool flag = this.m_levelRedDotDic.ContainsKey(define); + if (flag) + { + this.m_levelRedDotDic[define] = false; + } + this.RefreshRedPoints(); + } + + protected bool OnSealUpdate(XEventArgs e) + { + XActivityTaskUpdatedArgs xactivityTaskUpdatedArgs = e as XActivityTaskUpdatedArgs; + for (int i = 0; i < this.SealDatas.Count; i++) + { + bool flag = this.SealDatas[i].taskid == xactivityTaskUpdatedArgs.xTaskID; + if (flag) + { + DlgBase.singleton.OnFsTaskStateUpdated(xactivityTaskUpdatedArgs.xTaskID, (ActivityTaskState)xactivityTaskUpdatedArgs.xState); + this.RefreshRedPoints(); + return true; + } + } + return false; + } + + private bool OnPlayerLevelChange(XEventArgs arg) + { + XPlayerLevelChangedEventArgs xplayerLevelChangedEventArgs = arg as XPlayerLevelChangedEventArgs; + this.RefeshLevelRedDot(xplayerLevelChangedEventArgs.level); + return true; + } + + public FestScene.RowData GetFestivalData(uint id) + { + return XOperatingActivityDocument.m_FestivalTable.GetByid(id); + } + + public void EnterHolidayLevel() + { + bool flag = this._holiday_data.HolidayID == 0u; + if (!flag) + { + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(this._holiday_data.SceneID); + bool flag2 = sceneData != null; + if (flag2) + { + bool flag3 = sceneData.syncMode == 0; + if (flag3) + { + bool flag4 = XTeamDocument.GoSingleBattleBeforeNeed(new EventDelegate(this.EnterHolidayLevel)); + if (!flag4) + { + PtcC2G_EnterSceneReq ptcC2G_EnterSceneReq = new PtcC2G_EnterSceneReq(); + ptcC2G_EnterSceneReq.Data.sceneID = this._holiday_data.SceneID; + XSingleton.singleton.Send(ptcC2G_EnterSceneReq); + } + } + else + { + XExpeditionDocument specificDocument = XDocuments.GetSpecificDocument(XExpeditionDocument.uuID); + XTeamDocument specificDocument2 = XDocuments.GetSpecificDocument(XTeamDocument.uuID); + int expIDBySceneID = specificDocument.GetExpIDBySceneID(this._holiday_data.SceneID); + specificDocument2.SetAndMatch(expIDBySceneID); + } + } + } + } + + public bool CheckFestivalIsOpen(uint sceneid) + { + return this._holiday_data.SceneID == sceneid; + } + + public uint GetFestivalLeftTime() + { + return this._holiday_data.LeftTime; + } + + public uint GetFestivalLeftCount() + { + return this._holiday_data.LeftCount; + } + + public string GetFestivalPicPath() + { + FestScene.RowData festivalData = this.GetFestivalData(this._holiday_data.HolidayID); + bool flag = festivalData == null; + string result; + if (flag) + { + result = null; + } + else + { + result = festivalData.PicPath; + } + return result; + } + + public uint[] GetFestivalRewardList() + { + FestScene.RowData festivalData = this.GetFestivalData(this._holiday_data.HolidayID); + bool flag = festivalData == null; + uint[] result; + if (flag) + { + result = null; + } + else + { + result = festivalData.RewardList; + } + return result; + } + + public void SendQueryHolidayData() + { + RpcC2G_GetHolidayStageInfo rpc = new RpcC2G_GetHolidayStageInfo(); + XSingleton.singleton.Send(rpc); + } + + public void SetHolidayData(GetHolidayStageInfoRes data) + { + this._holiday_data = default(XOperatingActivityDocument.HolidayData); + this._holiday_data.HolidayID = data.holidayid; + this._holiday_data.LeftCount = data.havetimes; + this._holiday_data.LeftTime = data.lasttime; + this._holiday_data.SceneID = data.sceneid; + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_Holiday, true); + this.RefreshRedPoints(); + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + bool flag2 = DlgBase.singleton.m_HolidayHandler != null; + if (flag2) + { + DlgBase.singleton.m_HolidayHandler.Refresh(); + } + } + } + + private void DetachPandoraSDKRedPoint() + { + List pandoraSDKTabListInfo = XSingleton.singleton.GetPandoraSDKTabListInfo("action"); + bool flag = pandoraSDKTabListInfo != null; + if (flag) + { + for (int i = 0; i < pandoraSDKTabListInfo.Count; i++) + { + XSingleton.singleton.DetachSysRedPointRelative(pandoraSDKTabListInfo[i].sysID); + } + } + } + + public void AttachPandoraRedPoint(int sysID) + { + int sys = XFastEnumIntEqualityComparer.ToInt(XSysDefine.XSys_OperatingActivity); + bool flag = sysID != 0; + if (flag) + { + XSingleton.singleton.AttachSysRedPointRelative(sys, sysID, false); + } + } + } +} -- cgit v1.1-26-g67d0