summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/UI/GuildArenaInspireCD.cs
blob: 7fd6f4e659f7f13c1064851866331c853c888cc6 (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
using System;
using UILib;
using UnityEngine;
using XUtliPoolLib;

namespace XMainClient.UI
{
	internal class GuildArenaInspireCD
	{
		private IXUILabel m_cdText;

		private IXUISprite m_cdSprite;

		private double m_inspireCdTotal = 20.0;

		private bool m_canInspire = true;

		private Transform transform;

		public GuildArenaInspireCD(Transform t)
		{
			this.transform = t;
			this.m_inspireCdTotal = double.Parse(XSingleton<XGlobalConfig>.singleton.GetValue("GMFInspireCoolDown"));
			this.m_cdText = (t.Find("cd").GetComponent("XUILabel") as IXUILabel);
			this.m_cdSprite = (t.Find("cd/Quan").GetComponent("XUISprite") as IXUISprite);
			this.ClearInspireCD();
		}

		public bool IsActive()
		{
			return !(this.transform == null) && this.transform.gameObject.activeInHierarchy;
		}

		private void ClearInspireCD()
		{
			this.m_canInspire = true;
			this.m_cdSprite.SetAlpha(0f);
			this.m_cdText.Alpha = 0f;
		}

		public void ExcuteInspireCD(double curInspire)
		{
			bool flag = !this.IsActive();
			if (!flag)
			{
				bool flag2 = curInspire > 0.0;
				if (flag2)
				{
					bool flag3 = curInspire > this.m_inspireCdTotal;
					if (flag3)
					{
						curInspire = this.m_inspireCdTotal;
					}
					float fillAmount = (float)(curInspire / this.m_inspireCdTotal);
					this.m_cdText.Alpha = 1f;
					this.m_cdSprite.SetAlpha(1f);
					this.m_cdSprite.SetFillAmount(fillAmount);
					this.m_canInspire = false;
					bool flag4 = curInspire >= 1.0;
					if (flag4)
					{
						int num = (int)(curInspire + 0.5);
						this.m_cdText.SetText(num.ToString());
					}
					else
					{
						this.m_cdText.SetText(curInspire.ToString("F1"));
					}
				}
				else
				{
					bool flag5 = !this.m_canInspire;
					if (flag5)
					{
						this.ClearInspireCD();
					}
				}
			}
		}
	}
}