From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/Guild/XGuildJokerDocument.cs | 288 +++++++++++++++++++++ 1 file changed, 288 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Guild/XGuildJokerDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/Guild/XGuildJokerDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/Guild/XGuildJokerDocument.cs b/Client/Assets/Scripts/XMainClient/Guild/XGuildJokerDocument.cs new file mode 100644 index 00000000..d4dfe1c9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Guild/XGuildJokerDocument.cs @@ -0,0 +1,288 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XGuildJokerDocument : XDocComponent + { + public override uint ID + { + get + { + return XGuildJokerDocument.uuID; + } + } + + public uint CardResult { get; set; } + + public uint CardStore { get; set; } + + public int GameCount { get; set; } + + public int ChangeCount { get; set; } + + public int BuyChangeCount { get; set; } + + public List RankNames + { + get + { + bool flag = this.m_RankNames == null; + if (flag) + { + this.m_RankNames = new List(); + } + return this.m_RankNames; + } + } + + public List RankScores + { + get + { + bool flag = this.m_RankScores == null; + if (flag) + { + this.m_RankScores = new List(); + } + return this.m_RankScores; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("GuildJokerDocument"); + + public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader(); + + public static CardRewardTable _CardRewardTable = new CardRewardTable(); + + public static CardStoreTable _CardStoreTable = new CardStoreTable(); + + public List CurrentCard = new List(); + + public List BestCard = new List(); + + public string BestName; + + public uint JokerToken; + + public bool WaitRpc = false; + + private float guildJokerStartTime = 0f; + + private List m_RankNames; + + private List m_RankScores; + + public static void Execute(OnLoadedCallback callback = null) + { + XGuildJokerDocument.AsyncLoader.AddTask("Table/CardReward", XGuildJokerDocument._CardRewardTable, false); + XGuildJokerDocument.AsyncLoader.AddTask("Table/CardStore", XGuildJokerDocument._CardStoreTable, false); + XGuildJokerDocument.AsyncLoader.Execute(callback); + } + + protected override void EventSubscribe() + { + base.EventSubscribe(); + } + + public override void OnEnterScene() + { + base.OnEnterScene(); + bool flag = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; + if (flag) + { + this.QueryGameCount(); + } + } + + public void QueryGameCount() + { + RpcC2G_QueryGuildCard rpc = new RpcC2G_QueryGuildCard(); + XSingleton.singleton.Send(rpc); + } + + public void SendJokerRank(uint type) + { + PtcC2M_GuildCardRankReq ptcC2M_GuildCardRankReq = new PtcC2M_GuildCardRankReq(); + ptcC2M_GuildCardRankReq.Data.type = type; + XSingleton.singleton.Send(ptcC2M_GuildCardRankReq); + } + + public void ReceiveJockerRank(List names, List scores) + { + this.m_RankNames = names; + this.m_RankScores = scores; + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.SetRankData(names.Count); + } + } + + public void SendStartGame() + { + bool flag = Time.time - this.guildJokerStartTime < 2f; + if (!flag) + { + this.guildJokerStartTime = Time.time; + RpcC2G_StartGuildCard rpc = new RpcC2G_StartGuildCard(); + XSingleton.singleton.Send(rpc); + } + } + + public void SendChangeCard(uint card) + { + bool waitRpc = this.WaitRpc; + if (!waitRpc) + { + this.WaitRpc = true; + RpcC2G_ChangeGuildCard rpcC2G_ChangeGuildCard = new RpcC2G_ChangeGuildCard(); + rpcC2G_ChangeGuildCard.oArg.card = card; + XSingleton.singleton.Send(rpcC2G_ChangeGuildCard); + } + } + + public void SendGameEnd() + { + RpcC2G_EndGuildCard rpc = new RpcC2G_EndGuildCard(); + XSingleton.singleton.Send(rpc); + } + + public void SetGameCount(uint gameCount, uint changeCount, uint buyChangeCount) + { + this.GameCount = (int)gameCount; + this.ChangeCount = (int)changeCount; + this.BuyChangeCount = (int)buyChangeCount; + XGuildRelaxGameDocument specificDocument = XDocuments.GetSpecificDocument(XGuildRelaxGameDocument.uuID); + specificDocument.RefreshRedPoint(); + XSingleton.singleton.RecalculateRedPointState(XSysDefine.XSys_GuildRelax_Joker, true); + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.SetGameCount(); + } + } + + public void ShowCard(List card, uint result, uint store) + { + this.CardResult = result; + this.CardStore = store; + this.GameCount = Math.Max(0, this.GameCount - 1); + this.CurrentCard.Clear(); + for (int i = 0; i < card.Count; i++) + { + this.CurrentCard.Add(card[i]); + } + XGuildRelaxGameDocument specificDocument = XDocuments.GetSpecificDocument(XGuildRelaxGameDocument.uuID); + specificDocument.RefreshRedPoint(); + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.RefreshCard(); + DlgBase.singleton.SetCurrentReward(); + DlgBase.singleton.SetGameTipStatus(true); + DlgBase.singleton.SetGameCount(); + DlgBase.singleton.SetCardStore(); + bool flag2 = this.CardResult != 8u; + if (flag2) + { + DlgBase.singleton.SetButtonTip("GET_REWARD"); + } + else + { + DlgBase.singleton.SetButtonTip("END_GAME"); + } + } + } + + public void ChangeCard(uint oldCard, uint newCard, uint result) + { + this.WaitRpc = false; + bool flag = this.ChangeCount != 0; + if (flag) + { + this.ChangeCount--; + } + else + { + this.BuyChangeCount++; + } + this.CardResult = result; + int cardNum = 0; + for (int i = 0; i < this.CurrentCard.Count; i++) + { + bool flag2 = this.CurrentCard[i] != oldCard; + if (!flag2) + { + this.CurrentCard[i] = newCard; + cardNum = i; + } + } + bool flag3 = !DlgBase.singleton.IsVisible(); + if (!flag3) + { + DlgBase.singleton.ChangeCard(oldCard, newCard, cardNum); + DlgBase.singleton.SetGameCount(); + } + } + + public void EndCardGame(uint result) + { + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + DlgBase.singleton.RefreshRank(); + bool flag2 = this.CardResult != 8u; + if (flag2) + { + XSingleton.singleton.PlayUISound("Audio/UI/pukeshenli", true, AudioChannel.Action); + DlgBase.singleton.JokerStatus(2); + XSingleton.singleton.KillTimer(this.JokerToken); + this.JokerToken = XSingleton.singleton.SetTimer(1f, DlgBase.singleton.ResetJokerStatusCb, null); + } + else + { + XSingleton.singleton.PlayUISound("Audio/UI/pukeshibai", true, AudioChannel.Action); + DlgBase.singleton.JokerStatus(3); + XSingleton.singleton.KillTimer(this.JokerToken); + this.JokerToken = XSingleton.singleton.SetTimer(1f, DlgBase.singleton.ResetJokerStatusCb, null); + } + } + this.CurrentCard.Clear(); + this.CardResult = 8u; + this.CardStore = 5u; + bool flag3 = !DlgBase.singleton.IsVisible(); + if (!flag3) + { + DlgBase.singleton.ClearCard(); + DlgBase.singleton.SetGameTipStatus(false); + DlgBase.singleton.SetButtonTip("START_GAME"); + DlgBase.singleton.SetCurrentReward(); + DlgBase.singleton.SetCardStore(); + } + } + + public void SetBestCard(List card, string name) + { + this.BestCard.Clear(); + for (int i = 0; i < card.Count; i++) + { + this.BestCard.Add(card[i]); + } + this.BestName = name; + bool flag = !DlgBase.singleton.IsVisible(); + if (!flag) + { + DlgBase.singleton.SetupBestCard(); + } + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + this.WaitRpc = false; + } + } +} -- cgit v1.1-26-g67d0