Elin Decompiled Documentation EA 23.345.1 Nightly
Loading...
Searching...
No Matches
Gauge Class Reference
Inheritance diagram for Gauge:

Public Member Functions

void UpdateValue (float now, float _max)
 
void UpdateValue (int now, int _max, int recovery=0)
 

Public Attributes

UIText textNow
 
Image barCircle
 
Image bgBar
 
RawImage bar
 
RawImage barRecover
 
SpriteRenderer srBar
 
float duration
 
float originalWidth
 
Gradient gradient
 
bool useRatio
 
bool setText = true
 
float value
 
float lastValue = -1f
 
float lastRecovery = -1f
 
bool first = true
 
bool hideBar
 
Tween tween
 

Properties

int Num [get, set]
 

Private Attributes

int _num
 
int _lastNum
 
int max
 

Detailed Description

Definition at line 6 of file Gauge.cs.

Member Function Documentation

◆ UpdateValue() [1/2]

void Gauge.UpdateValue ( float  now,
float  _max 
)
inline

Definition at line 73 of file Gauge.cs.

74 {
75 UpdateValue((int)(now * 100f), (int)(_max * 100f));
76 }
void UpdateValue(float now, float _max)
Definition: Gauge.cs:73

References UpdateValue().

Referenced by UIAutoTurn._Update(), WidgetHP.Refresh(), and UpdateValue().

◆ UpdateValue() [2/2]

void Gauge.UpdateValue ( int  now,
int  _max,
int  recovery = 0 
)
inline

Definition at line 78 of file Gauge.cs.

79 {
80 max = _max;
81 if (!base.gameObject.activeSelf)
82 {
83 base.gameObject.SetActive(value: true);
84 }
85 if ((bool)bar)
86 {
87 bar.SetActive(!hideBar);
88 }
89 if ((bool)bgBar)
90 {
91 bgBar.SetActive(!hideBar);
92 }
93 value = (float)now / (float)max;
94 if (value == lastValue && (float)recovery == lastRecovery)
95 {
96 return;
97 }
98 if (value < 0f)
99 {
100 value = 0f;
101 }
102 else if (value > 1f)
103 {
104 value = 1f;
105 }
106 if ((bool)textNow && setText)
107 {
108 textNow.color = gradient.Evaluate((float)now / (float)max);
109 if (first)
110 {
111 Num = now;
112 }
113 else
114 {
115 DOTween.To(() => Num, delegate(int x)
116 {
117 Num = x;
118 }, now, duration);
119 }
120 }
121 TweenUtil.KillTween(ref tween);
122 if ((bool)bar)
123 {
124 SetRect(bar, value);
125 if ((bool)barRecover)
126 {
127 SetRect(barRecover, (float)(now + recovery) / (float)max);
128 }
129 }
130 else if ((bool)srBar)
131 {
132 Vector2 vector = new Vector2(value * 100f, srBar.size.y);
133 if (first)
134 {
135 srBar.size = vector;
136 first = false;
137 return;
138 }
139 tween = DOTween.To(() => srBar.size, delegate(Vector2 x)
140 {
141 srBar.size = x;
142 }, vector, duration);
143 }
144 else
145 {
146 barCircle.fillAmount = value;
147 }
149 lastRecovery = recovery;
150 void SetRect(RawImage bar, float value)
151 {
152 value = Mathf.Clamp(value, 0f, 1f);
153 RectTransform rectTransform = bar.Rect();
154 Vector2 vector2 = new Vector2(originalWidth * value, rectTransform.sizeDelta.y);
155 if (first)
156 {
157 rectTransform.sizeDelta = vector2;
158 first = false;
159 }
160 else
161 {
162 tween = rectTransform.DOSizeDelta(vector2, duration);
163 }
164 }
165 }
float lastRecovery
Definition: Gauge.cs:37
bool first
Definition: Gauge.cs:40
float duration
Definition: Gauge.cs:20
SpriteRenderer srBar
Definition: Gauge.cs:18
Gradient gradient
Definition: Gauge.cs:24
Tween tween
Definition: Gauge.cs:45
float originalWidth
Definition: Gauge.cs:22
bool setText
Definition: Gauge.cs:28
RawImage bar
Definition: Gauge.cs:14
UIText textNow
Definition: Gauge.cs:8
int max
Definition: Gauge.cs:51
Image bgBar
Definition: Gauge.cs:12
int Num
Definition: Gauge.cs:54
RawImage barRecover
Definition: Gauge.cs:16
float value
Definition: Gauge.cs:31
bool hideBar
Definition: Gauge.cs:43
float lastValue
Definition: Gauge.cs:34

References bar, barRecover, bgBar, duration, first, gradient, hideBar, lastRecovery, lastValue, max, Num, originalWidth, setText, srBar, textNow, tween, and value.

Member Data Documentation

◆ _lastNum

int Gauge._lastNum
private

Definition at line 49 of file Gauge.cs.

◆ _num

int Gauge._num
private

Definition at line 47 of file Gauge.cs.

◆ bar

RawImage Gauge.bar

Definition at line 14 of file Gauge.cs.

Referenced by UIAutoTurn._Update(), and UpdateValue().

◆ barCircle

Image Gauge.barCircle

Definition at line 10 of file Gauge.cs.

◆ barRecover

RawImage Gauge.barRecover

Definition at line 16 of file Gauge.cs.

Referenced by UpdateValue().

◆ bgBar

Image Gauge.bgBar

Definition at line 12 of file Gauge.cs.

Referenced by UpdateValue().

◆ duration

float Gauge.duration

Definition at line 20 of file Gauge.cs.

Referenced by UpdateValue().

◆ first

bool Gauge.first = true

Definition at line 40 of file Gauge.cs.

Referenced by UpdateValue().

◆ gradient

Gradient Gauge.gradient

Definition at line 24 of file Gauge.cs.

Referenced by UpdateValue().

◆ hideBar

bool Gauge.hideBar

Definition at line 43 of file Gauge.cs.

Referenced by UpdateValue().

◆ lastRecovery

float Gauge.lastRecovery = -1f

Definition at line 37 of file Gauge.cs.

Referenced by UpdateValue().

◆ lastValue

float Gauge.lastValue = -1f

Definition at line 34 of file Gauge.cs.

Referenced by UpdateValue().

◆ max

int Gauge.max
private

Definition at line 51 of file Gauge.cs.

Referenced by UpdateValue().

◆ originalWidth

float Gauge.originalWidth

Definition at line 22 of file Gauge.cs.

Referenced by UISong.Update(), and UpdateValue().

◆ setText

bool Gauge.setText = true

Definition at line 28 of file Gauge.cs.

Referenced by UpdateValue().

◆ srBar

SpriteRenderer Gauge.srBar

Definition at line 18 of file Gauge.cs.

Referenced by UpdateValue().

◆ textNow

UIText Gauge.textNow

Definition at line 8 of file Gauge.cs.

Referenced by UIAutoTurn._Update(), WidgetHP.Refresh(), and UpdateValue().

◆ tween

Tween Gauge.tween

Definition at line 45 of file Gauge.cs.

Referenced by UpdateValue().

◆ useRatio

bool Gauge.useRatio

Definition at line 26 of file Gauge.cs.

◆ value

float Gauge.value

Definition at line 31 of file Gauge.cs.

Referenced by UpdateValue().

Property Documentation

◆ Num

int Gauge.Num
getsetprivate

Definition at line 53 of file Gauge.cs.

54 {
55 get
56 {
57 return _num;
58 }
59 set
60 {
61 _num = value;
62 if (_num != _lastNum)
63 {
64 if ((bool)textNow && setText)
65 {
66 textNow.text = (useRatio ? (Mathf.RoundToInt((float)_num / (float)max * 100f) + "%") : (_num.ToString() ?? ""));
67 }
68 _lastNum = _num;
69 }
70 }
71 }
int _num
Definition: Gauge.cs:47
int _lastNum
Definition: Gauge.cs:49
bool useRatio
Definition: Gauge.cs:26

Referenced by UpdateValue().


The documentation for this class was generated from the following file: