summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/HallFameShareDlg.cs
blob: 6531e8f806a205bb1865c3efb02593ff09380091 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
using System;
using KKSG;
using UILib;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class HallFameShareDlg : DlgBase<HallFameShareDlg, HallFameShareBehavior>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/HallFameShareDlg";
			}
		}

		public override int layer
		{
			get
			{
				return 1;
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		public override bool pushstack
		{
			get
			{
				return true;
			}
		}

		private XFx _roleEffect;

		private uint m_show_time_token = 0u;

		protected override void Init()
		{
			base.Init();
			this.InitProperties();
		}

		protected override void OnShow()
		{
			base.OnShow();
			base.uiBehaviour.ShareBtn.SetAlpha(1f);
			this.ShowMainRoleAvatar();
			this.UpdateRoleDetail();
			this.PlayVictoryAction();
		}

		private void PlayVictoryAction()
		{
			float interval = XSingleton<X3DAvatarMgr>.singleton.SetMainAnimationGetLength(XSingleton<XEntityMgr>.singleton.Player.Present.PresentLib.Disappear);
			this.m_show_time_token = XSingleton<XTimerMgr>.singleton.SetTimer(interval, new XTimerMgr.ElapsedEventHandler(this.KillDummyTimer), null);
		}

		private void UpdateRoleDetail()
		{
			ulong roleID = XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID;
			HallFameRoleInfo roleInfoByRoleID = XHallFameDocument.Doc.GetRoleInfoByRoleID(roleID);
			bool flag = roleInfoByRoleID != null;
			if (flag)
			{
				ArenaStarType curSelectedType = DlgBase<HallFameDlg, HallFameBehavior>.singleton.CurSelectedType;
				string @string = XSingleton<XStringTable>.singleton.GetString(curSelectedType.ToString() + "_Hall_Fame");
				IXUILabel ixuilabel = base.uiBehaviour.RoleName.gameObject.transform.Find("Title").GetComponent("XUILabel") as IXUILabel;
				ixuilabel.SetText(@string + XSingleton<XStringTable>.singleton.GetString("SeasonFame"));
				base.uiBehaviour.RoleName.SetText(roleInfoByRoleID.OutLook.name);
				ixuilabel = (base.uiBehaviour.TopTenTimes.gameObject.transform.Find("Title").GetComponent("XUILabel") as IXUILabel);
				ixuilabel.SetText(@string + XSingleton<XStringTable>.singleton.GetString("TotalTopTen"));
				base.uiBehaviour.TopTenTimes.SetText(roleInfoByRoleID.hisData.rankTenNum.ToString());
				ixuilabel = (base.uiBehaviour.SeasonSpan.gameObject.transform.Find("Title").GetComponent("XUILabel") as IXUILabel);
				ixuilabel.SetText(@string + XSingleton<XStringTable>.singleton.GetString("SeasonTime"));
				DateTime dateTime = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(XHallFameDocument.Doc.SeasonBeginTime).ToLocalTime();
				DateTime dateTime2 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(XHallFameDocument.Doc.SeasonEndTime).ToLocalTime();
				base.uiBehaviour.SeasonSpan.SetText(((XHallFameDocument.Doc.SeasonBeginTime == 0UL) ? "--:--" : dateTime.ToString("MM.dd")) + "_" + ((XHallFameDocument.Doc.SeasonEndTime == 0UL) ? "--:--" : dateTime2.ToString("MM.dd")));
				ixuilabel = (base.uiBehaviour.ChampionTimes.gameObject.transform.Find("Title").GetComponent("XUILabel") as IXUILabel);
				ixuilabel.SetText(@string + XSingleton<XStringTable>.singleton.GetString("TotalTopOne"));
				base.uiBehaviour.ChampionTimes.SetText(roleInfoByRoleID.hisData.rankOneNum.ToString());
				string text = (roleInfoByRoleID.hisData.rankRecent.Count == 0) ? "" : roleInfoByRoleID.hisData.rankRecent[0].rank.ToString();
				for (int i = 1; i < roleInfoByRoleID.hisData.rankRecent.Count; i++)
				{
					uint num = roleInfoByRoleID.hisData.rankRecent[i].rank;
					num = ((num == uint.MaxValue) ? 0u : num);
					text = text + "/" + num;
				}
				base.uiBehaviour.RecentSeason.SetText(text);
			}
		}

		private void ShowMainRoleAvatar()
		{
			XSingleton<X3DAvatarMgr>.singleton.EnableMainDummy(true, base.uiBehaviour.uiDummy);
			bool flag = this._roleEffect != null;
			if (flag)
			{
				this._roleEffect.SetActive(true);
			}
		}

		protected override void OnHide()
		{
			XSingleton<X3DAvatarMgr>.singleton.EnableMainDummy(false, null);
			bool flag = this._roleEffect != null;
			if (flag)
			{
				this._roleEffect.SetActive(false);
			}
			this.KillTimer();
			XSingleton<X3DAvatarMgr>.singleton.ResetMainAnimation();
			base.OnHide();
		}

		protected override void OnUnload()
		{
			bool flag = this._roleEffect != null;
			if (flag)
			{
				XSingleton<XFxMgr>.singleton.DestroyFx(this._roleEffect, true);
				this._roleEffect = null;
			}
			this.KillTimer();
			XSingleton<X3DAvatarMgr>.singleton.ResetMainAnimation();
			base.OnUnload();
		}

		private void InitProperties()
		{
			base.uiBehaviour.ShareBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.ClickToShare));
			base.uiBehaviour.CloseBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.ClickToClose));
			this._roleEffect = XSingleton<XFxMgr>.singleton.CreateFx("Effects/FX_Particle/UIfx/UI_HallFameDlg_fx02", null, true);
			this._roleEffect.SetActive(false);
			this._roleEffect.SetParent(base.uiBehaviour.ParticleHanging);
		}

		private bool ClickToClose(IXUIButton button)
		{
			this.SetVisibleWithAnimation(false, null);
			return true;
		}

		private bool ClickToShare(IXUIButton button)
		{
			bool flag = XSingleton<UiUtility>.singleton.CheckPlatfomStatus();
			if (flag)
			{
				base.uiBehaviour.ShareBtn.SetAlpha(0f);
				XSingleton<XScreenShotMgr>.singleton.SendStatisticToServer(ShareOpType.Share, DragonShareType.ShowGlory);
				XSingleton<XScreenShotMgr>.singleton.StartExternalScreenShotView(new ScreenShotCallback(this.ShareSuccess));
			}
			return true;
		}

		private void ShareSuccess(bool succ)
		{
			XSingleton<XDebug>.singleton.AddGreenLog("ShareSuccess", null, null, null, null, null);
			bool flag = base.IsVisible();
			if (flag)
			{
				base.uiBehaviour.ShareBtn.SetAlpha(1f);
				this.SetVisible(false, true);
			}
		}

		private void KillDummyTimer(object sender)
		{
			this.KillTimer();
			bool flag = XSingleton<XEntityMgr>.singleton.Player != null && XSingleton<XEntityMgr>.singleton.Player.Present != null;
			if (flag)
			{
				XSingleton<X3DAvatarMgr>.singleton.SetMainAnimation(XSingleton<XEntityMgr>.singleton.Player.Present.PresentLib.AttackIdle);
			}
		}

		private void KillTimer()
		{
			XSingleton<XTimerMgr>.singleton.KillTimer(this.m_show_time_token);
			this.m_show_time_token = 0u;
		}
	}
}