summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XAttributeCommon.cs
blob: a16821cc39a3aec07b0ea7fe29ce1656e7c117d5 (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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
using System;
using System.Collections.Generic;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XAttributeCommon
	{
		public static readonly int AttrCount = 301;

		public static readonly int BasicStart = 0;

		public static readonly int BasicEnd = XAttributeCommon.AttrCount;

		public static readonly int PercentStart = 1000;

		public static readonly int PercentEnd = XAttributeCommon.PercentStart + XAttributeCommon.AttrCount;

		public static readonly int TotalStart = 2000;

		public static readonly int TotalEnd = XAttributeCommon.TotalStart + XAttributeCommon.AttrCount;

		private static readonly HashSet<XAttributeDefine> _FirstLevelAttrs = new HashSet<XAttributeDefine>
		{
			XAttributeDefine.XAttr_Strength_Basic,
			XAttributeDefine.XAttr_Strength_Percent,
			XAttributeDefine.XAttr_Strength_Total,
			XAttributeDefine.XAttr_Agility_Basic,
			XAttributeDefine.XAttr_Agility_Percent,
			XAttributeDefine.XAttr_Agility_Total,
			XAttributeDefine.XAttr_Intelligence_Basic,
			XAttributeDefine.XAttr_Intelligence_Percent,
			XAttributeDefine.XAttr_Intelligence_Total,
			XAttributeDefine.XAttr_Vitality_Basic,
			XAttributeDefine.XAttr_Vitality_Percent,
			XAttributeDefine.XAttr_Vitality_Total
		};

		public static XAttributeDefine GetAttrLimitAttr(XAttributeDefine currAttr)
		{
			XAttributeDefine result;
			if (currAttr != XAttributeDefine.XAttr_CurrentHP_Basic)
			{
				if (currAttr != XAttributeDefine.XAttr_CurrentSuperArmor_Basic)
				{
					if (currAttr != XAttributeDefine.XAttr_CurrentMP_Basic)
					{
						result = XAttributeDefine.XAttr_Invalid;
					}
					else
					{
						result = XAttributeDefine.XAttr_MaxMP_Total;
					}
				}
				else
				{
					result = XAttributeDefine.XAttr_MaxSuperArmor_Total;
				}
			}
			else
			{
				result = XAttributeDefine.XAttr_MaxHP_Total;
			}
			return result;
		}

		public static XAttributeDefine GetRegenAttr(XAttributeDefine currAttr)
		{
			XAttributeDefine result;
			if (currAttr != XAttributeDefine.XAttr_CurrentHP_Basic)
			{
				if (currAttr != XAttributeDefine.XAttr_CurrentSuperArmor_Basic)
				{
					if (currAttr != XAttributeDefine.XAttr_CurrentMP_Basic)
					{
						result = XAttributeDefine.XAttr_Invalid;
					}
					else
					{
						result = XAttributeDefine.XAttr_MPRecovery_Total;
					}
				}
				else
				{
					result = XAttributeDefine.XAttr_SuperArmorReg_Total;
				}
			}
			else
			{
				result = XAttributeDefine.XAttr_HPRecovery_Total;
			}
			return result;
		}

		public static XAttributeDefine GetAttrCurAttr(XAttributeDefine limitAttr)
		{
			if (limitAttr <= XAttributeDefine.XAttr_MaxHP_Percent)
			{
				if (limitAttr <= XAttributeDefine.XAttr_MaxSuperArmor_Basic)
				{
					if (limitAttr != XAttributeDefine.XAttr_MaxHP_Basic)
					{
						if (limitAttr != XAttributeDefine.XAttr_MaxSuperArmor_Basic)
						{
							goto IL_78;
						}
						goto IL_73;
					}
				}
				else
				{
					if (limitAttr == XAttributeDefine.XAttr_MaxMP_Basic)
					{
						goto IL_6E;
					}
					if (limitAttr != XAttributeDefine.XAttr_MaxHP_Percent)
					{
						goto IL_78;
					}
				}
			}
			else if (limitAttr <= XAttributeDefine.XAttr_MaxMP_Percent)
			{
				if (limitAttr == XAttributeDefine.XAttr_MaxSuperArmor_Percent)
				{
					goto IL_73;
				}
				if (limitAttr != XAttributeDefine.XAttr_MaxMP_Percent)
				{
					goto IL_78;
				}
				goto IL_6E;
			}
			else if (limitAttr != XAttributeDefine.XAttr_MaxHP_Total)
			{
				if (limitAttr == XAttributeDefine.XAttr_MaxSuperArmor_Total)
				{
					goto IL_73;
				}
				if (limitAttr != XAttributeDefine.XAttr_MaxMP_Total)
				{
					goto IL_78;
				}
				goto IL_6E;
			}
			return XAttributeDefine.XAttr_CurrentHP_Basic;
			IL_6E:
			return XAttributeDefine.XAttr_CurrentMP_Basic;
			IL_73:
			return XAttributeDefine.XAttr_CurrentSuperArmor_Basic;
			IL_78:
			return XAttributeDefine.XAttr_Invalid;
		}

		public static bool IsBasicRange(int id)
		{
			return id > XAttributeCommon.BasicStart && id < XAttributeCommon.BasicEnd;
		}

		public static bool IsPercentRange(int id)
		{
			return id > XAttributeCommon.PercentStart && id < XAttributeCommon.PercentEnd;
		}

		public static bool IsPercentRange(XAttributeDefine attr)
		{
			return XFastEnumIntEqualityComparer<XAttributeDefine>.ToInt(attr) > XAttributeCommon.PercentStart && XFastEnumIntEqualityComparer<XAttributeDefine>.ToInt(attr) < XAttributeCommon.PercentEnd;
		}

		public static bool IsTotalRange(int id)
		{
			return id > XAttributeCommon.TotalStart && id < XAttributeCommon.TotalEnd;
		}

		public static int GetBasicAttr(int id)
		{
			return id % 1000;
		}

		public static string GetAttrStr(int attrid)
		{
			return XStringDefineProxy.GetString((XAttributeDefine)attrid);
		}

		public static string GetAttrValueStr(int attrid, float attrValue)
		{
			bool flag = XAttributeCommon.IsPercentRange(attrid);
			string result;
			if (flag)
			{
				result = string.Format((attrValue >= 0f) ? "+{0}%" : "{0}%", attrValue.ToString("0.#"));
			}
			else
			{
				result = string.Format((attrValue >= 0f) ? "+{0}" : "{0}", (int)attrValue).ToString();
			}
			return result;
		}

		public static string GetAttrValueStr(uint attrid, uint attrValue, bool bWithSignal = true)
		{
			bool flag = XAttributeCommon.IsPercentRange((int)attrid);
			string result;
			if (flag)
			{
				result = string.Format((bWithSignal && attrValue >= 0u) ? "+{0}%" : "{0}%", attrValue.ToString());
			}
			else
			{
				result = string.Format((bWithSignal && attrValue >= 0u) ? "+{0}" : "{0}", attrValue).ToString();
			}
			return result;
		}

		public static bool IsFirstLevelAttr(XAttributeDefine attr)
		{
			return XAttributeCommon._FirstLevelAttrs.Contains(attr);
		}
	}
}