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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
|
using System;
using System.Collections.Generic;
using KKSG;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
internal class HomeSpriteClass
{
public PlantSprite.RowData Row
{
get
{
return this.m_row;
}
}
public bool IsHadSprite
{
get
{
return this.m_spriteId > 0u;
}
}
public uint SpriteId
{
get
{
return this.m_spriteId;
}
}
public bool HadDriveEnd
{
get
{
bool flag = this.m_row != null && this.m_row.Dialogues != null;
return !flag || (ulong)this.m_driveTimes >= (ulong)((long)(this.m_row.Dialogues.Length - 1));
}
}
private PlantSprite.RowData m_row;
private uint m_spriteId;
private uint m_driveTimes = 0u;
private Vector3 m_pos;
private XNpc m_npc;
private string m_fxPath = "";
private XFx m_fx;
private string m_transmitPath = "";
private XFx m_transmitFx;
private static List<Vector3> m_startPosList;
private static List<Vector3> m_posList;
private uint m_token = 0u;
private bool animLoadCbValid = false;
public HomeSpriteClass()
{
this.m_fxPath = "Effects/FX_Particle/Scene/Lzg_scene/rwts_01";
this.m_transmitPath = "Effects/FX_Particle/NPC/Lzg_Boss/yjsf/yjsh_ss";
}
public void SetSpriteInfo(uint spriteId)
{
this.m_spriteId = spriteId;
this.m_driveTimes = 0u;
bool flag = spriteId > 0u;
if (flag)
{
HomePlantDocument.Doc.SetHadRedDot();
this.m_row = HomePlantDocument.PlantSpriteTable.GetBySpriteID(spriteId);
bool flag2 = this.m_row == null;
if (flag2)
{
XSingleton<XDebug>.singleton.AddErrorLog("data error,spriteId =" + spriteId.ToString(), null, null, null, null, null);
}
this.GetStartPos();
SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
bool flag3 = sceneType == SceneType.SCENE_FAMILYGARDEN;
if (flag3)
{
this.LoadNpc();
}
}
}
public void SetNextStepOperation()
{
HomePlantDocument.Doc.SetFarmlandBoxStatus(true);
bool hadDriveEnd = this.HadDriveEnd;
if (hadDriveEnd)
{
HomePlantDocument.Doc.DriveTroubleMaker();
}
else
{
this.SetToNextPos();
}
}
public string GetDialogue()
{
bool flag = this.m_row == null && this.m_row.Dialogues != null;
string result;
if (flag)
{
result = "";
}
else
{
bool flag2 = (ulong)this.m_driveTimes >= (ulong)((long)this.m_row.Dialogues.Length);
if (flag2)
{
result = "";
}
else
{
result = this.m_row.Dialogues[(int)this.m_driveTimes];
}
}
return result;
}
public void ClearInfo()
{
this.m_driveTimes = 0u;
this.Destroy();
this.animLoadCbValid = false;
XSingleton<XTimerMgr>.singleton.KillTimer(this.m_token);
HomePlantDocument.Doc.SetHadRedDot();
}
public void SetSpriteBoxStatus(bool status)
{
bool flag = this.m_npc != null;
if (flag)
{
this.m_npc.EngineObject.EnableBC = status;
}
}
private void AnimLoadCallback(XAnimationClip clip)
{
bool flag = this.animLoadCbValid;
if (flag)
{
float interval = 0f;
bool flag2 = clip != null;
if (flag2)
{
interval = clip.length - 0.034f;
}
this.m_token = XSingleton<XTimerMgr>.singleton.SetTimer(interval, new XTimerMgr.ElapsedEventHandler(this.NpcMove), null);
this.animLoadCbValid = false;
}
}
private void SetToNextPos()
{
bool flag = this.m_npc == null;
if (!flag)
{
bool flag2 = this.m_fx != null;
if (flag2)
{
this.m_fx.SetActive(false);
}
bool flag3 = this.m_transmitFx == null;
if (flag3)
{
this.m_transmitFx = XSingleton<XFxMgr>.singleton.CreateFx(this.m_transmitPath, null, true);
}
this.m_transmitFx.SetActive(true);
bool flag4 = this.m_transmitFx != null && this.m_npc != null;
if (flag4)
{
this.m_transmitFx.Play(this.m_npc.EngineObject, new Vector3(-0.05f, this.m_npc.Height, 0f), Vector3.one, 1f, false, false, "", 0f);
}
this.animLoadCbValid = true;
XSingleton<XTimerMgr>.singleton.KillTimer(this.m_token);
this.m_npc.ShowUp(new OverrideAnimCallback(this.AnimLoadCallback));
}
}
private void NpcMove(object o = null)
{
this.AddDriveTimes();
this.m_npc.EngineObject.Position = this.m_pos;
XSingleton<XTimerMgr>.singleton.KillTimer(this.m_token);
bool flag = this.m_transmitFx != null && this.m_npc != null;
if (flag)
{
this.m_transmitFx.SetActive(false);
this.m_transmitFx.SetActive(true);
this.m_transmitFx.Play(this.m_npc.EngineObject, new Vector3(-0.05f, this.m_npc.Height, 0f), Vector3.one, 1f, false, false, "", 0f);
this.m_token = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.TransmitEffectEnd), null);
}
}
private void TransmitEffectEnd(object o = null)
{
this.SetSpriteBoxStatus(true);
bool flag = this.m_transmitFx != null;
if (flag)
{
this.m_transmitFx.SetActive(false);
}
bool flag2 = this.m_fx != null;
if (flag2)
{
this.m_fx.SetActive(true);
bool flag3 = this.m_fx != null && this.m_npc != null;
if (flag3)
{
this.m_fx.Play(this.m_npc.EngineObject, new Vector3(-0.05f, this.m_npc.Height + 0.6f, 0f), Vector3.one, 1f, false, false, "", 0f);
}
}
}
private void LoadNpc()
{
bool flag = this.m_npc != null;
if (flag)
{
XSingleton<XEntityMgr>.singleton.DestroyNpc(this.m_spriteId);
this.m_npc = null;
}
this.m_npc = XSingleton<XEntityMgr>.singleton.CreateNpc(this.m_spriteId, true);
bool flag2 = this.m_npc != null;
if (flag2)
{
this.m_npc.EngineObject.Position = this.m_pos;
}
bool flag3 = this.m_fx == null;
if (flag3)
{
this.m_fx = XSingleton<XFxMgr>.singleton.CreateFx(this.m_fxPath, null, true);
}
this.m_fx.SetActive(true);
bool flag4 = this.m_fx != null && this.m_npc != null;
if (flag4)
{
this.m_fx.Play(this.m_npc.EngineObject, new Vector3(-0.05f, this.m_npc.Height + 0.6f, 0f), Vector3.one, 1f, false, false, "", 0f);
}
}
private void Destroy()
{
bool flag = this.m_npc != null;
if (flag)
{
XSingleton<XEntityMgr>.singleton.DestroyNpc(this.m_spriteId);
this.m_npc = null;
this.m_spriteId = 0u;
}
bool flag2 = this.m_fx != null;
if (flag2)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this.m_fx, true);
this.m_fx = null;
}
bool flag3 = this.m_transmitFx != null;
if (flag3)
{
XSingleton<XFxMgr>.singleton.DestroyFx(this.m_transmitFx, true);
this.m_transmitFx = null;
}
}
private void AddDriveTimes()
{
bool hadDriveEnd = this.HadDriveEnd;
if (!hadDriveEnd)
{
this.m_driveTimes += 1u;
this.GetPos();
}
}
private void GetStartPos()
{
bool flag = HomeSpriteClass.m_startPosList == null || HomeSpriteClass.m_startPosList.Count == 0;
if (flag)
{
this.m_pos = Vector3.zero;
}
else
{
int index = UnityEngine.Random.Range(0, HomeSpriteClass.m_startPosList.Count);
this.m_pos = HomeSpriteClass.m_startPosList[index];
}
}
private void GetPos()
{
bool flag = HomeSpriteClass.m_startPosList == null || HomeSpriteClass.m_startPosList.Count == 0;
if (flag)
{
this.m_pos = Vector3.zero;
}
else
{
int index;
bool flag2;
do
{
index = UnityEngine.Random.Range(0, HomeSpriteClass.m_startPosList.Count);
flag2 = (this.m_pos != HomeSpriteClass.m_startPosList[index]);
}
while (!flag2);
this.m_pos = HomeSpriteClass.m_startPosList[index];
}
}
public static void InitPosList()
{
HomeSpriteClass.m_startPosList = new List<Vector3>();
string value = XSingleton<XGlobalConfig>.singleton.GetValue("TroublemakerStartPos");
string[] array = value.Split(XGlobalConfig.AllSeparators);
Vector3 zero = Vector3.zero;
for (int i = 0; i < array.Length; i += 3)
{
bool flag = !string.IsNullOrEmpty(array[i]) && !string.IsNullOrEmpty(array[i + 1]) && !string.IsNullOrEmpty(array[i + 2]);
if (flag)
{
zero.x = float.Parse(array[i]);
zero.y = float.Parse(array[i + 1]);
zero.z = float.Parse(array[i + 2]);
HomeSpriteClass.m_startPosList.Add(zero);
}
}
HomeSpriteClass.m_posList = new List<Vector3>();
value = XSingleton<XGlobalConfig>.singleton.GetValue("TroublemakerPos");
array = value.Split(XGlobalConfig.AllSeparators);
for (int j = 0; j < array.Length; j += 3)
{
bool flag2 = !string.IsNullOrEmpty(array[j]) && !string.IsNullOrEmpty(array[j + 1]) && !string.IsNullOrEmpty(array[j + 2]);
if (flag2)
{
zero.x = float.Parse(array[j]);
zero.y = float.Parse(array[j + 1]);
zero.z = float.Parse(array[j + 2]);
HomeSpriteClass.m_startPosList.Add(zero);
}
}
}
}
}
|