summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/BattleRiftHandler.cs
blob: bae05e22623f92baec8b8f25f59157fd1d046478 (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
193
194
195
196
197
198
199
200
201
202
using System;
using System.Collections.Generic;
using KKSG;
using UILib;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class BattleRiftHandler : DlgHandlerBase
	{
		protected override string FileName
		{
			get
			{
				return "Battle/TeamMysteriousBattleDlg";
			}
		}

		private XRiftDocument _doc;

		private const int max_buff = 5;

		public uint s_time = 0u;

		private uint all_time = 0u;

		private uint tri_time = 0u;

		private uint dob_time = 0u;

		private uint sceneid;

		public IXUIProgress m_progress;

		public IXUILabel m_lblFloor;

		public IXUILabel m_lblTime1;

		public IXUILabel m_lblTime2;

		private IXUILabel m_lbltip;

		public GameObject[] m_goBuff = new GameObject[5];

		private float dtime = 0f;

		protected override void Init()
		{
			base.Init();
			this._doc = XDocuments.GetSpecificDocument<XRiftDocument>(XRiftDocument.uuID);
			this.m_lblFloor = (base.transform.Find("Floor").GetComponent("XUILabel") as IXUILabel);
			this.m_lblTime1 = (base.transform.Find("Time").GetComponent("XUILabel") as IXUILabel);
			this.m_lblTime2 = (base.transform.Find("Time2").GetComponent("XUILabel") as IXUILabel);
			this.m_lbltip = (base.transform.Find("Buff/Tip").GetComponent("XUILabel") as IXUILabel);
			this.m_progress = (base.transform.Find("Progress Bar").GetComponent("XUIProgress") as IXUIProgress);
			for (int i = 0; i < 5; i++)
			{
				this.m_goBuff[i] = base.transform.Find("Buff/BossBuff" + i).gameObject;
			}
		}

		protected override void OnShow()
		{
			base.OnShow();
			this.ParseData();
			bool flag = this._doc.scene_rift_data != null;
			if (flag)
			{
				this.Refresh((float)this._doc.scene_rift_data.floor, this._doc.scene_rift_data.buffIDs);
			}
			this.m_lbltip.SetVisible(false);
		}

		public void Refresh(float floor, List<Buff> buffs)
		{
			this.m_lblFloor.SetText(floor.ToString());
			this.RefreshBuff(buffs);
		}

		public override void OnUpdate()
		{
			base.OnUpdate();
			bool flag = Time.time - this.dtime > 1f && this._doc != null && !this._doc.stop_timer;
			if (flag)
			{
				this.dtime = Time.time;
				this.s_time += 1u;
				this.RefreshTime();
			}
		}

		private void RefreshTime()
		{
			float value = 1f - this.s_time / this.all_time;
			this.m_progress.value = value;
			this.m_lblTime1.SetText(this.TranNum2Date(this.all_time - this.s_time));
			bool flag = this.s_time < this.tri_time;
			if (flag)
			{
				this.m_lblTime2.SetText(this.TranNum2Date(this.tri_time - this.s_time));
			}
			else
			{
				bool flag2 = this.s_time < this.tri_time + this.dob_time;
				if (flag2)
				{
					this.m_lblTime2.SetText(this.TranNum2Date(this.tri_time + this.dob_time - this.s_time));
				}
				else
				{
					this.m_lblTime2.SetText(this.TranNum2Date(this.all_time - this.s_time));
				}
			}
		}

		private void ParseData()
		{
			this.sceneid = XSingleton<XScene>.singleton.SceneID;
			SceneTable.RowData sceneData = XSingleton<XSceneMgr>.singleton.GetSceneData(this.sceneid);
			for (int i = 0; i < (int)sceneData.LoseCondition.count; i++)
			{
				bool flag = sceneData.LoseCondition[i, 0] == 3;
				if (flag)
				{
					this.all_time = (uint)sceneData.LoseCondition[i, 1];
				}
			}
			for (int j = 0; j < XLevelRewardDocument.Table.Table.Length; j++)
			{
				bool flag2 = XLevelRewardDocument.Table.Table[j].scendid == this.sceneid;
				if (flag2)
				{
					this.tri_time = XLevelRewardDocument.Table.Table[j].star3[2];
					this.dob_time = XLevelRewardDocument.Table.Table[j].star2[2] - this.tri_time;
					break;
				}
			}
		}

		private string TranNum2Date(uint num)
		{
			uint num2 = num / 60u;
			uint num3 = num % 60u;
			return num2.ToString("D2") + ":" + num3.ToString("D2");
		}

		private void RefreshBuff(List<Buff> buffs)
		{
			int num = buffs.Count + 2;
			XTeamDocument specificDocument = XDocuments.GetSpecificDocument<XTeamDocument>(XTeamDocument.uuID);
			Rift.RowData rowData = this._doc.currRiftRow;
			bool flag = specificDocument.MyTeam != null && specificDocument.MyTeam.teamBrief != null && specificDocument.MyTeam.teamBrief.rift != null;
			if (flag)
			{
				XTeamRift rift = specificDocument.MyTeam.teamBrief.rift;
				rowData = this._doc.GetRiftData(rift.floor, (int)rift.id);
			}
			this.RefreshBuff(this.m_goBuff[0], string.Empty, XSingleton<XGlobalConfig>.singleton.GetValue("RiftAttr"), rowData.attack + "%");
			this.RefreshBuff(this.m_goBuff[1], string.Empty, XSingleton<XGlobalConfig>.singleton.GetValue("RiftHP"), rowData.hp + "%");
			for (int i = 2; i < num; i++)
			{
				RiftBuffSuitMonsterType.RowData buffSuitRow = this._doc.GetBuffSuitRow((uint)buffs[i - 2].buffID, buffs[i - 2].buffLevel);
				this.m_goBuff[i].SetActive(true);
				this.RefreshBuff(this.m_goBuff[i], buffSuitRow.atlas, buffSuitRow.icon, string.Empty);
				IXUISprite ixuisprite = this.m_goBuff[i].transform.Find("P").GetComponent("XUISprite") as IXUISprite;
				ixuisprite.ID = (ulong)((long)(i - 2));
				ixuisprite.RegisterSpritePressEventHandler(new SpritePressEventHandler(this.OnBuffPress));
			}
			for (int j = num; j < this.m_goBuff.Length; j++)
			{
				this.m_goBuff[j].SetActive(false);
			}
		}

		private bool OnBuffPress(IXUISprite spr, bool ispress)
		{
			int index = (int)spr.ID;
			Buff buff = this._doc.scene_rift_data.buffIDs[index];
			RiftBuffSuitMonsterType.RowData buffSuitRow = this._doc.GetBuffSuitRow((uint)buff.buffID, buff.buffLevel);
			this.m_lbltip.SetText(XSingleton<UiUtility>.singleton.ReplaceReturn(buffSuitRow.scription));
			this.m_lbltip.SetVisible(ispress);
			return true;
		}

		private void RefreshBuff(GameObject go, string atlas, string sp, string text)
		{
			IXUILabel ixuilabel = go.transform.Find("value").GetComponent("XUILabel") as IXUILabel;
			IXUISprite ixuisprite = go.transform.Find("P").GetComponent("XUISprite") as IXUISprite;
			ixuilabel.SetText(text);
			bool flag = string.IsNullOrEmpty(atlas);
			if (flag)
			{
				ixuisprite.SetSprite(sp);
			}
			else
			{
				ixuisprite.SetSprite(sp, atlas, false);
			}
		}
	}
}