Elin Decompiled Documentation EA 23.102 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)
 

Public Attributes

UIText textNow
 
Image barCircle
 
Image bgBar
 
RawImage bar
 
SpriteRenderer srBar
 
float duration
 
float originalWidth
 
Gradient gradient
 
bool useRatio
 
bool setText = true
 
float value
 
float lastValue = -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 68 of file Gauge.cs.

69 {
70 UpdateValue((int)(now * 100f), (int)(_max * 100f));
71 }
void UpdateValue(float now, float _max)
Definition: Gauge.cs:68

References UpdateValue().

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

◆ UpdateValue() [2/2]

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

Definition at line 73 of file Gauge.cs.

74 {
75 max = _max;
76 if (!base.gameObject.activeSelf)
77 {
78 base.gameObject.SetActive(value: true);
79 }
80 if ((bool)bar)
81 {
82 bar.SetActive(!hideBar);
83 }
84 if ((bool)bgBar)
85 {
86 bgBar.SetActive(!hideBar);
87 }
88 value = (float)now / (float)max;
89 if (value == lastValue)
90 {
91 return;
92 }
93 if (value < 0f)
94 {
95 value = 0f;
96 }
97 else if (value > 1f)
98 {
99 value = 1f;
100 }
101 if ((bool)textNow && setText)
102 {
103 textNow.color = gradient.Evaluate((float)now / (float)max);
104 if (first)
105 {
106 Num = now;
107 }
108 else
109 {
110 DOTween.To(() => Num, delegate(int x)
111 {
112 Num = x;
113 }, now, duration);
114 }
115 }
116 TweenUtil.KillTween(ref tween);
117 if ((bool)bar)
118 {
119 RectTransform rectTransform = bar.Rect();
120 Vector2 vector = new Vector2(originalWidth * value, rectTransform.sizeDelta.y);
121 if (first)
122 {
123 rectTransform.sizeDelta = vector;
124 first = false;
125 return;
126 }
127 tween = rectTransform.DOSizeDelta(vector, duration);
128 }
129 else if ((bool)srBar)
130 {
131 Vector2 vector2 = new Vector2(value * 100f, srBar.size.y);
132 if (first)
133 {
134 srBar.size = vector2;
135 first = false;
136 return;
137 }
138 tween = DOTween.To(() => srBar.size, delegate(Vector2 x)
139 {
140 srBar.size = x;
141 }, vector2, duration);
142 }
143 else
144 {
145 barCircle.fillAmount = value;
146 }
148 }
bool first
Definition: Gauge.cs:35
float duration
Definition: Gauge.cs:18
SpriteRenderer srBar
Definition: Gauge.cs:16
Gradient gradient
Definition: Gauge.cs:22
Tween tween
Definition: Gauge.cs:40
float originalWidth
Definition: Gauge.cs:20
bool setText
Definition: Gauge.cs:26
RawImage bar
Definition: Gauge.cs:14
UIText textNow
Definition: Gauge.cs:8
int max
Definition: Gauge.cs:46
Image bgBar
Definition: Gauge.cs:12
int Num
Definition: Gauge.cs:49
float value
Definition: Gauge.cs:29
bool hideBar
Definition: Gauge.cs:38
float lastValue
Definition: Gauge.cs:32

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

Member Data Documentation

◆ _lastNum

int Gauge._lastNum
private

Definition at line 44 of file Gauge.cs.

◆ _num

int Gauge._num
private

Definition at line 42 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.

◆ bgBar

Image Gauge.bgBar

Definition at line 12 of file Gauge.cs.

Referenced by UpdateValue().

◆ duration

float Gauge.duration

Definition at line 18 of file Gauge.cs.

Referenced by UpdateValue().

◆ first

bool Gauge.first = true

Definition at line 35 of file Gauge.cs.

Referenced by UpdateValue().

◆ gradient

Gradient Gauge.gradient

Definition at line 22 of file Gauge.cs.

Referenced by UpdateValue().

◆ hideBar

bool Gauge.hideBar

Definition at line 38 of file Gauge.cs.

Referenced by UpdateValue().

◆ lastValue

float Gauge.lastValue = -1f

Definition at line 32 of file Gauge.cs.

Referenced by UpdateValue().

◆ max

int Gauge.max
private

Definition at line 46 of file Gauge.cs.

Referenced by UpdateValue().

◆ originalWidth

float Gauge.originalWidth

Definition at line 20 of file Gauge.cs.

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

◆ setText

bool Gauge.setText = true

Definition at line 26 of file Gauge.cs.

Referenced by UpdateValue().

◆ srBar

SpriteRenderer Gauge.srBar

Definition at line 16 of file Gauge.cs.

Referenced by UpdateValue().

◆ textNow

UIText Gauge.textNow

Definition at line 8 of file Gauge.cs.

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

◆ tween

Tween Gauge.tween

Definition at line 40 of file Gauge.cs.

Referenced by UpdateValue().

◆ useRatio

bool Gauge.useRatio

Definition at line 24 of file Gauge.cs.

◆ value

float Gauge.value

Definition at line 29 of file Gauge.cs.

Referenced by UpdateValue().

Property Documentation

◆ Num

int Gauge.Num
getsetprivate

Definition at line 48 of file Gauge.cs.

49 {
50 get
51 {
52 return _num;
53 }
54 set
55 {
56 _num = value;
57 if (_num != _lastNum)
58 {
59 if ((bool)textNow && setText)
60 {
61 textNow.text = (useRatio ? (Mathf.RoundToInt((float)_num / (float)max * 100f) + "%") : (_num.ToString() ?? ""));
62 }
63 _lastNum = _num;
64 }
65 }
66 }
int _num
Definition: Gauge.cs:42
int _lastNum
Definition: Gauge.cs:44
bool useRatio
Definition: Gauge.cs:24

Referenced by UpdateValue().


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