From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/Guild/XGuildJockerMatchView.cs | 505 +++++++++++++++++++++ 1 file changed, 505 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/Guild/XGuildJockerMatchView.cs (limited to 'Client/Assets/Scripts/XMainClient/Guild/XGuildJockerMatchView.cs') diff --git a/Client/Assets/Scripts/XMainClient/Guild/XGuildJockerMatchView.cs b/Client/Assets/Scripts/XMainClient/Guild/XGuildJockerMatchView.cs new file mode 100644 index 00000000..b4dac759 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/Guild/XGuildJockerMatchView.cs @@ -0,0 +1,505 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XGuildJockerMatchView : XGuildJokerCommonView + { + public override string fileName + { + get + { + return "Guild/GuildSystem/GuildJokerMatchDlg"; + } + } + + public override bool fullscreenui + { + get + { + return true; + } + } + + private CardMatchState MatchState + { + get + { + return this._Doc.MatchState; + } + } + + protected override string BestName + { + get + { + return this._Doc.MatchBestJockerName; + } + } + + protected override int CurrentCardCount + { + get + { + return this._Doc.MatchJockers.Count; + } + } + + protected override List CurrentCard + { + get + { + return this._Doc.MatchJockers; + } + } + + protected override uint CardResult + { + get + { + return this._Doc.MatchResult; + } + } + + protected override List BestCard + { + get + { + return this._Doc.MatchBestJockers; + } + } + + protected override int CurrentStore + { + get + { + return (int)this._Doc.MatchJockerStore; + } + } + + private XGuildJockerMatchDocument _Doc; + + private IXUILabel m_beginTime; + + private IXUILabel m_roundTime; + + private IXUIScrollView m_RankScrollView; + + private IXUIWrapContent m_RankWrapContent; + + private IXUILabel m_RuleTip; + + public XYuyinView _yuyinHandler; + + public Transform m_MyRank; + + public IXUILabel m_addCountPerRound; + + public IXUILabel m_GameTip2; + + private uint m_changeTimer = 0u; + + private XUIPool m_rewardPool; + + private Transform m_rewardTransform; + + private Transform m_TotalIncomeTransform; + + protected override void Init() + { + base.Init(); + this._Doc = XDocuments.GetSpecificDocument(XGuildJockerMatchDocument.uuID); + this.m_beginTime = (base.uiBehaviour.transform.Find("Bg/BeginTime").GetComponent("XUILabel") as IXUILabel); + this.m_roundTime = (base.uiBehaviour.transform.Find("Bg/RoundTime").GetComponent("XUILabel") as IXUILabel); + this.m_RankScrollView = (base.uiBehaviour.transform.Find("Bg/Ranking/ScrollView").GetComponent("XUIScrollView") as IXUIScrollView); + this.m_RankWrapContent = (base.uiBehaviour.transform.Find("Bg/Ranking/ScrollView/WrapContent").GetComponent("XUIWrapContent") as IXUIWrapContent); + this.m_RankWrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.OnRankWrapItemUpdate)); + this.m_RuleTip = (base.uiBehaviour.transform.Find("Bg/Rule/Bg/RuleTip").GetComponent("XUILabel") as IXUILabel); + IXUIPanel ixuipanel = base.uiBehaviour.transform.GetComponent("XUIPanel") as IXUIPanel; + ixuipanel.SetDepth(2); + this.m_MyRank = base.uiBehaviour.transform.Find("Bg/Ranking/MyRank"); + this.m_addCountPerRound = (base.uiBehaviour.transform.Find("Bg/AddCount/Num").GetComponent("XUILabel") as IXUILabel); + this.m_GameTip2 = (base.uiBehaviour.transform.Find("Bg/GameTip2").GetComponent("XUILabel") as IXUILabel); + this.m_rewardPool = new XUIPool(XSingleton.singleton.m_uiTool); + this.m_TotalIncomeTransform = base.uiBehaviour.transform.Find("Bg/TotalIncome"); + this.m_rewardTransform = base.uiBehaviour.transform.Find("Bg/TotalIncome/RewardList"); + Transform transform = base.uiBehaviour.transform.Find("Bg/TotalIncome/RewardList/Reward"); + this.m_rewardPool.SetupPool(transform.parent.parent.gameObject, transform.gameObject, 4u, true); + } + + protected override SeqListRef GetCardReward(int index) + { + return XGuildJokerDocument._CardRewardTable.Table[index].matchreward; + } + + public void RefreshSelfRank(int score, int rank) + { + this.SetBaseInfo(this.m_MyRank, XSingleton.singleton.XPlayerData.Name, rank, score); + } + + public void SetRankInfo(int count) + { + this.m_RankWrapContent.SetContentCount(count, false); + this.m_RankScrollView.ResetPosition(); + } + + private void SetBaseInfo(Transform t, string name, int index, int score) + { + IXUILabelSymbol ixuilabelSymbol = t.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol; + IXUILabel ixuilabel = t.Find("Score").GetComponent("XUILabel") as IXUILabel; + IXUISprite ixuisprite = t.Find("IndexSprite").GetComponent("XUISprite") as IXUISprite; + IXUILabel ixuilabel2 = t.Find("IndexLabel").GetComponent("XUILabel") as IXUILabel; + bool flag = index == -1; + if (flag) + { + ixuilabel2.Alpha = 1f; + ixuisprite.SetAlpha(0f); + ixuilabel2.SetText(XSingleton.singleton.GetString("NoRank")); + } + else + { + bool flag2 = index < 3; + if (flag2) + { + ixuilabel2.Alpha = 0f; + ixuisprite.SetAlpha(1f); + ixuisprite.SetSprite(string.Format("N{0}", index + 1)); + } + else + { + ixuilabel2.Alpha = 1f; + ixuisprite.SetAlpha(0f); + ixuilabel2.SetText((index + 1).ToString()); + } + } + ixuilabel.SetText(score.ToString()); + ixuilabelSymbol.InputText = name; + } + + private void OnRankWrapItemUpdate(Transform t, int index) + { + this.SetBaseInfo(t, (index < this._Doc.MatchRankNames.Count) ? this._Doc.MatchRankNames[index].ToString() : string.Empty, index, (index < this._Doc.MatchRankScores.Count) ? this._Doc.MatchRankScores[index] : 0); + } + + public void SetGameCount() + { + base.uiBehaviour.m_GameCount.SetText(this._Doc.MatchRound.ToString()); + base.uiBehaviour.m_ChangeCount.SetText(this._Doc.ChangeCount.ToString()); + } + + protected override void OnShow() + { + base.OnShow(); + this._Doc.wattingPTC = false; + base.SetupBestCard(); + this.RefreshWhenShow(); + this.SetRankInfo(this._Doc.MatchRankNames.Count); + ShowSettingArgs showSettingArgs = new ShowSettingArgs(); + showSettingArgs.position = 1; + showSettingArgs.needforceshow = true; + showSettingArgs.forceshow = true; + showSettingArgs.needdepth = true; + showSettingArgs.depth = 4; + DlgBase.singleton.ShowChatMiniUI(showSettingArgs); + this.m_RuleTip.SetText(XSingleton.singleton.ReplaceReturn(XSingleton.singleton.GetString("GUILD_JOKER_MATCH_RULE_TIP"))); + this.m_addCountPerRound.SetText(XSingleton.singleton.GetValue("CardMatchChangeAdd")); + bool flag = this._yuyinHandler != null; + if (flag) + { + this._yuyinHandler.Show(YuyinIconType.JOKER, 4); + this._yuyinHandler.Refresh(YuyinIconType.JOKER); + } + } + + public void RefreshWhenShow() + { + this.SetGameCount(); + base.SetCardStore(); + this.SetButtonState(); + this.ShowTimeClock(); + this.SetRoundInfo(); + this.SetRewardList(); + } + + public override void StackRefresh() + { + base.StackRefresh(); + this.RefreshWhenShow(); + } + + private void ShowTimeClock() + { + bool flag = this.MatchState == CardMatchState.CardMatch_StateEnd; + if (flag) + { + this.ShowGameOver(); + } + else + { + bool flag2 = this.MatchState == CardMatchState.CardMatch_StateRoundBegin || this.MatchState == CardMatchState.CardMatch_StateRounding || this.MatchState == CardMatchState.CardMatch_StateRoundEnd; + if (flag2) + { + this.ShowRoundTime(); + } + else + { + this.ShowWattingTime(); + } + } + } + + public void SetRoundInfo() + { + base.RefreshCard(); + this.SetCurrentReward(); + this.SetGameCount(); + base.SetCardStore(); + } + + protected override void OnLoad() + { + base.OnLoad(); + DlgHandlerBase.EnsureCreate(ref this._yuyinHandler, base.uiBehaviour.transform, true, this); + } + + public override void OnUpdate() + { + base.OnUpdate(); + bool flag = this._Doc.TimeLeft > 0.0; + if (flag) + { + string @string = XStringDefineProxy.GetString("GUILD_JOCKER_MATCH_WAITTING_LABEL"); + bool flag2 = this.m_beginTime.IsVisible(); + if (flag2) + { + this.m_beginTime.SetText(string.Format(@string, XSingleton.singleton.TimeDuarationFormatString((int)this._Doc.TimeLeft, 5))); + } + bool flag3 = this.m_roundTime.IsVisible(); + if (flag3) + { + this.m_roundTime.SetText(XSingleton.singleton.TimeDuarationFormatString((int)this._Doc.TimeLeft, 5)); + } + } + } + + protected override void OnHide() + { + this._Doc.SendJokerMatchExit(); + XSingleton.singleton.KillTimer(this.m_changeTimer); + ShowSettingArgs showSettingArgs = new ShowSettingArgs(); + showSettingArgs.position = 0; + showSettingArgs.needforceshow = true; + showSettingArgs.forceshow = false; + showSettingArgs.needdepth = true; + showSettingArgs.depth = 0; + showSettingArgs.anim = false; + DlgBase.singleton.ShowChatMiniUI(showSettingArgs); + base.OnHide(); + } + + protected override void OnUnload() + { + bool flag = this.m_rewardPool != null; + if (flag) + { + this.m_rewardPool = null; + } + DlgHandlerBase.EnsureUnload(ref this._yuyinHandler); + base.OnUnload(); + } + + private void ShowWattingTime() + { + this.m_beginTime.SetVisible(true); + this.m_roundTime.SetVisible(false); + base.SetGameTipStatus(false); + base.uiBehaviour.m_CurrentRewardTransfrom.gameObject.SetActive(false); + } + + private void ShowRoundTime() + { + base.uiBehaviour.m_CurrentRewardTransfrom.gameObject.SetActive(true); + this.m_beginTime.SetVisible(false); + this.m_roundTime.SetVisible(true); + base.SetGameTipStatus(this.MatchState == CardMatchState.CardMatch_StateRounding || this.MatchState == CardMatchState.CardMatch_StateRoundBegin); + } + + private void SetButtonState() + { + this.m_GameTip2.SetVisible(false); + bool flag = this.MatchState == CardMatchState.CardMatch_StateRounding || this.MatchState == CardMatchState.CardMatch_StateRoundBegin; + if (flag) + { + base.uiBehaviour.m_StartGame.SetGrey(this.CurrentCard.Count > 0); + base.uiBehaviour.m_StartGame.SetVisible(true); + base.SetButtonTip("GUILD_JOCKER_MATCH_GET"); + } + else + { + bool flag2 = this.MatchState == CardMatchState.CardMatch_StateRoundWaiting; + if (flag2) + { + base.uiBehaviour.m_StartGame.SetGrey(true); + base.uiBehaviour.m_StartGame.SetVisible(true); + base.SetButtonTip("GUILD_JOCKER_MATCH_WAITTING"); + } + else + { + bool flag3 = this.MatchState == CardMatchState.CardMatch_StateRoundEnd; + if (flag3) + { + base.uiBehaviour.m_StartGame.SetVisible(true); + base.uiBehaviour.m_StartGame.SetGrey(false); + } + else + { + bool flag4 = this.MatchState == CardMatchState.CardMatch_StateEnd; + if (flag4) + { + base.uiBehaviour.m_StartGame.SetVisible(true); + base.uiBehaviour.m_StartGame.SetGrey(true); + base.SetButtonTip("GUILD_REDPACKET_DETAIL_EXIT"); + this.m_GameTip2.SetVisible(true); + this.m_GameTip2.SetText(XSingleton.singleton.GetString("GUILD_JOCKER_MATCH_TIP_END")); + } + else + { + this.m_GameTip2.SetVisible(true); + this.m_GameTip2.SetText(XStringDefineProxy.GetString("GUILD_JOCKER_MATCH_TIP_START", new object[] + { + XSingleton.singleton.GetValue("CardMatchRound"), + XSingleton.singleton.GetValue("CardMatchRounding") + })); + base.uiBehaviour.m_StartGame.SetVisible(false); + } + } + } + } + } + + private void ShowGameOver() + { + XSingleton.singleton.KillTimer(this.m_changeTimer); + base.uiBehaviour.m_CurrentRewardTransfrom.gameObject.SetActive(false); + this.m_beginTime.SetVisible(false); + this.m_roundTime.SetVisible(false); + base.SetGameTipStatus(false); + } + + protected override bool OnCloseClick(IXUIButton button) + { + this.SetVisibleWithAnimation(false, null); + return true; + } + + protected override bool OnStartGameClicked(IXUIButton button) + { + bool flag = (this.MatchState == CardMatchState.CardMatch_StateRounding || this.MatchState == CardMatchState.CardMatch_StateRoundBegin) && this.CurrentCard.Count > 0; + if (flag) + { + this._Doc.SetJokerMatchRoundOver(); + } + else + { + bool flag2 = this.MatchState == CardMatchState.CardMatch_StateEnd; + if (flag2) + { + this.SetVisibleWithAnimation(false, null); + } + } + return true; + } + + protected override void OnCardClick(IXUISprite sp) + { + bool flag = this._changeCardLock || this._cardLock; + if (!flag) + { + bool flag2 = false; + for (int i = 0; i < this._Doc.MatchJockers.Count; i++) + { + bool flag3 = this._Doc.MatchJockers[i] == base.CardReAnalyze((uint)sp.ID); + if (flag3) + { + flag2 = true; + } + } + bool flag4 = !flag2; + if (!flag4) + { + bool flag5 = this._Doc.ChangeCount > 0u; + if (flag5) + { + this._Doc.SendGuildCardMatchChange(base.CardReAnalyze((uint)sp.ID)); + } + else + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("GUILD_JOCKER_NOTFREECOUNT"), "fece00"); + } + } + } + } + + public override void SetCurrentReward() + { + string text = string.Format("{0}:", XStringDefineProxy.GetString("CURRENT_REWARD")); + bool flag = this._Doc.MatchJockers.Count == 0; + if (flag) + { + base.SetCurrentRewardStr(text); + } + else + { + bool flag2 = this.CurrentCard.Count == 0; + if (flag2) + { + base.SetCurrentRewardStr(text); + } + else + { + bool flag3 = (ulong)this._Doc.MatchResult >= (ulong)((long)XGuildJokerDocument._CardRewardTable.Table.Length); + if (flag3) + { + text = string.Format("{0} {1}", text, XStringDefineProxy.GetString("NONE")); + } + else + { + CardRewardTable.RowData rowData = XGuildJokerDocument._CardRewardTable.Table[(int)this._Doc.MatchResult]; + for (int i = 0; i < rowData.matchreward.Count; i++) + { + text = string.Format("{0} {1}{2}", text, XLabelSymbolHelper.FormatSmallIcon((int)rowData.matchreward[i, 0]), rowData.matchreward[i, 1]); + } + List stringList = XSingleton.singleton.GetStringList("CardPointIcon"); + text = string.Format("{0} {1}{2}", text, XLabelSymbolHelper.FormatImage(stringList[0], stringList[1]), rowData.point); + } + base.SetCurrentRewardStr(text); + base.RefreshCardSelect(); + } + } + } + + private void SetRewardList() + { + int count = this._Doc.MatchItems.Count; + this.m_TotalIncomeTransform.gameObject.SetActive(count > 0); + this.m_rewardPool.ReturnAll(false); + for (int i = 0; i < count; i++) + { + GameObject gameObject = this.m_rewardPool.FetchGameObject(false); + gameObject.transform.parent = this.m_rewardTransform; + gameObject.transform.localPosition = new Vector3(0f, (float)(-(float)i * 28)); + ItemBrief itemBrief = this._Doc.MatchItems[i]; + IXUILabelSymbol ixuilabelSymbol = gameObject.GetComponent("XUILabelSymbol") as IXUILabelSymbol; + string text = string.Format("{0} X{1}", XLabelSymbolHelper.FormatSmallIcon((int)itemBrief.itemID), itemBrief.itemCount); + XSingleton.singleton.AddGreenLog("StrTemp:", text, null, null, null, null); + ixuilabelSymbol.InputText = text; + } + } + } +} -- cgit v1.1-26-g67d0