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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
using System;
using System.Collections.Generic;
using KKSG;
using XMainClient.UI;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class XHomeFishingDocument : XDocComponent
{
public override uint ID
{
get
{
return XHomeFishingDocument.uuID;
}
}
public GardenFishConfig _HomeFishTable
{
get
{
return XHomeFishingDocument._homeFishTable;
}
}
public FishInfo FishInfoTable
{
get
{
return XHomeFishingDocument._fishInfo;
}
}
public bool isSweep { get; set; }
public List<ItemBrief> FishList
{
get
{
return this._fishList;
}
}
public uint TimerToken
{
get
{
return this._timerToken;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("HomeFishingDocument");
public static XTableAsyncLoader AsyncLoader = new XTableAsyncLoader();
private static GardenFishConfig _homeFishTable = new GardenFishConfig();
private static FishInfo _fishInfo = new FishInfo();
private bool _nearFishPoolState = false;
public uint FishingLevel = 1u;
public uint CurrentExp = 0u;
private List<ItemBrief> _fishList = new List<ItemBrief>();
public bool LastFishingHasFish = true;
private uint _timerToken;
private HomeFishingState _currState;
private bool m_first_cast = false;
public bool LastLevelUp = false;
private ulong _reconnectSign;
public bool IsFishing = false;
public bool ServerStopFishing = false;
private XEntityPresentation.RowData _fishingRodPresentation;
public static readonly int stoshID = 5500;
public static readonly string LEVELUPFX = "Effects/FX_Particle/UIfx/UI_jy_dy_sj";
public static void Execute(OnLoadedCallback callback = null)
{
XHomeFishingDocument.AsyncLoader.AddTask("Table/GardenFishing", XHomeFishingDocument._homeFishTable, false);
XHomeFishingDocument.AsyncLoader.AddTask("Table/FishInfo", XHomeFishingDocument._fishInfo, false);
XHomeFishingDocument.AsyncLoader.Execute(callback);
}
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._fishingRodPresentation = XSingleton<XEntityMgr>.singleton.EntityInfo.GetByPresentID(50001u);
}
protected override void EventSubscribe()
{
base.EventSubscribe();
base.RegisterEvent(XEventDefine.XEvent_AddItem, new XComponent.XEventHandler(this.OnAddItem));
}
public override void OnLeaveScene()
{
base.OnLeaveScene();
this._nearFishPoolState = false;
}
protected override void OnReconnected(XReconnectedEventArgs arg)
{
bool flag = this.IsFishing && this._currState == HomeFishingState.WAITSERVER;
if (flag)
{
bool flag2 = this._reconnectSign == XBagDocument.BagDoc.GetItemCount(5500) + 1UL;
if (flag2)
{
this.LastFishingHasFish = false;
this.OnFishingStateChange(null);
}
else
{
bool flag3 = this._reconnectSign == XBagDocument.BagDoc.GetItemCount(5500);
if (flag3)
{
this.SendFishingQuery();
}
}
}
bool flag4 = this.IsFishing && DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.IsVisible();
if (flag4)
{
XSingleton<XInput>.singleton.Freezed = true;
}
}
public void SendLevelExpQuery()
{
RpcC2M_GardenFishInfo rpcC2M_GardenFishInfo = new RpcC2M_GardenFishInfo();
HomePlantDocument specificDocument = XDocuments.GetSpecificDocument<HomePlantDocument>(HomePlantDocument.uuID);
rpcC2M_GardenFishInfo.oArg.garden_id = specificDocument.GardenId;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_GardenFishInfo);
}
private void SendFishingQuery()
{
XCharacterItemDocument specificDocument = XDocuments.GetSpecificDocument<XCharacterItemDocument>(XCharacterItemDocument.uuID);
bool flag = DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.IsVisible();
if (flag)
{
specificDocument.ToggleBlock(true);
}
RpcC2M_TryFish rpcC2M_TryFish = new RpcC2M_TryFish();
HomePlantDocument specificDocument2 = XDocuments.GetSpecificDocument<HomePlantDocument>(HomePlantDocument.uuID);
bool flag2 = specificDocument2.HomeType == HomeTypeEnum.MyHome;
if (flag2)
{
rpcC2M_TryFish.oArg.quest_type = GardenQuestType.MYSELF;
}
else
{
bool flag3 = specificDocument2.HomeType == HomeTypeEnum.OtherHome;
if (!flag3)
{
XSingleton<XDebug>.singleton.AddErrorLog("try fishing error. home type error.", null, null, null, null, null);
return;
}
rpcC2M_TryFish.oArg.quest_type = GardenQuestType.FRIEND;
}
rpcC2M_TryFish.oArg.garden_id = specificDocument2.GardenId;
rpcC2M_TryFish.oArg.casting_net = this.isSweep;
XSingleton<XClientNetwork>.singleton.Send(rpcC2M_TryFish);
}
public void SetLevelExpInfo(uint level, uint exp)
{
this.FishingLevel = level;
this.CurrentExp = exp;
bool flag = DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.Refresh(false);
}
}
public void OnFishingResultGet(List<ItemBrief> list, uint level, uint exp)
{
bool flag = !this.IsFishing;
if (!flag)
{
bool flag2 = list.Count == 0;
if (flag2)
{
this.LastFishingHasFish = false;
this.OnFishingStateChange(null);
}
else
{
this.LastFishingHasFish = true;
this.LastLevelUp = (this.FishingLevel != level);
this.FishingLevel = level;
this.CurrentExp = exp;
for (int i = 0; i < list.Count; i++)
{
uint num = list[i].itemCount;
for (int j = 0; j < this._fishList.Count; j++)
{
bool flag3 = this._fishList[j].itemID == list[i].itemID;
if (flag3)
{
num += this._fishList[j].itemCount;
this._fishList.RemoveAt(j);
break;
}
}
ItemBrief itemBrief = new ItemBrief();
itemBrief.itemID = list[i].itemID;
itemBrief.itemCount = num;
ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemBrief.itemID);
XSingleton<XDebug>.singleton.AddGreenLog("fishing get ", itemConf.ItemName[0], null, null, null, null);
itemBrief.isbind = !itemConf.CanTrade;
this._fishList.Add(itemBrief);
}
this.OnFishingStateChange(null);
}
}
}
public void StartFishing()
{
XDanceDocument.Doc.ReqStopJustDance();
this._entity = XSingleton<XEntityMgr>.singleton.Player;
XComponent xcomponent = XSingleton<XComponentMgr>.singleton.CreateComponent(XSingleton<XEntityMgr>.singleton.Player, XFishingComponent.uuID);
xcomponent.Attached();
this.SetStartFishingState();
this.IsFishing = true;
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.SetFishingTipsState(true);
}
public void StopFishing()
{
XSingleton<XEntityMgr>.singleton.Player.PlaySpecifiedAnimation(this._entity.Present.PresentLib.FishingIdle);
this._entity.Equipment.PlayFishingRodAnimation(this._fishingRodPresentation.FishingIdle);
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.SetFishingTipsState(false);
}
public void ContinueFishing()
{
this._timerToken = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.OnFishingStateChange), null);
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.SetFishingTipsState(true);
}
public void LeaveFishing()
{
bool serverStopFishing = this.ServerStopFishing;
if (serverStopFishing)
{
this.ServerStopFishing = false;
}
else
{
PtcC2M_GardenFishStop ptcC2M_GardenFishStop = new PtcC2M_GardenFishStop();
HomePlantDocument specificDocument = XDocuments.GetSpecificDocument<HomePlantDocument>(HomePlantDocument.uuID);
ptcC2M_GardenFishStop.Data.garden_id = specificDocument.GardenId;
XSingleton<XDebug>.singleton.AddGreenLog("notice server stop fishing.", null, null, null, null, null);
XSingleton<XClientNetwork>.singleton.Send(ptcC2M_GardenFishStop);
}
bool flag = XSingleton<XEntityMgr>.singleton.Player != null;
if (flag)
{
XSingleton<XEntityMgr>.singleton.Player.DetachComponent(XFishingComponent.uuID);
}
this.IsFishing = false;
XSingleton<XTimerMgr>.singleton.KillTimer(this._timerToken);
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.SetFishingTipsState(false);
}
private void SetStartFishingState()
{
this.m_first_cast = true;
this._currState = HomeFishingState.GET;
XSingleton<XEntityMgr>.singleton.Player.PlaySpecifiedAnimation(this._entity.Present.PresentLib.FishingIdle);
this._entity.Equipment.PlayFishingRodAnimation(this._fishingRodPresentation.FishingIdle);
this._timerToken = XSingleton<XTimerMgr>.singleton.SetTimer(1f, new XTimerMgr.ElapsedEventHandler(this.OnFishingStateChange), null);
}
private void OnFishingStateChange(object o = null)
{
bool flag = !this.IsFishing || XSingleton<XEntityMgr>.singleton.Player == null || this._entity == null;
if (!flag)
{
float num = 5f;
switch (this._currState)
{
case HomeFishingState.CAST:
{
this._currState = HomeFishingState.WAIT;
num = XSingleton<XEntityMgr>.singleton.Player.PlaySpecifiedAnimationGetLength(this._entity.Present.PresentLib.FishingWait);
bool flag2 = num < 0f;
if (flag2)
{
this.ErrorLeaveFishing();
return;
}
this._entity.Equipment.PlayFishingRodAnimation(this._fishingRodPresentation.FishingWait);
num = 2f;
XSingleton<XDebug>.singleton.AddGreenLog("state = wait, time = 2.0", null, null, null, null, null);
break;
}
case HomeFishingState.WAIT:
this._currState = HomeFishingState.WAITSERVER;
this._reconnectSign = XBagDocument.BagDoc.GetItemCount(5500);
this.SendFishingQuery();
num = -1f;
XSingleton<XDebug>.singleton.AddGreenLog("state = wait server, time = infinite", null, null, null, null, null);
break;
case HomeFishingState.WAITSERVER:
{
bool lastFishingHasFish = this.LastFishingHasFish;
if (lastFishingHasFish)
{
bool high = XHomeFishingDocument._fishInfo.GetByFishID(this._fishList[this._fishList.Count - 1].itemID).quality > 0;
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.PlayGetFishFx(high);
}
this._currState = HomeFishingState.PULL;
num = XSingleton<XEntityMgr>.singleton.Player.PlaySpecifiedAnimationGetLength(this._entity.Present.PresentLib.FishingPull);
bool flag3 = num < 0f;
if (flag3)
{
this.ErrorLeaveFishing();
return;
}
this._entity.Equipment.PlayFishingRodAnimation(this._fishingRodPresentation.FishingPull);
XSingleton<XDebug>.singleton.AddGreenLog("state = pull, time = ", num.ToString(), null, null, null, null);
bool flag4 = DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.IsVisible();
if (flag4)
{
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.DelayShowFish();
}
break;
}
case HomeFishingState.PULL:
{
this._currState = HomeFishingState.GET;
bool lastFishingHasFish2 = this.LastFishingHasFish;
if (lastFishingHasFish2)
{
num = XSingleton<XEntityMgr>.singleton.Player.PlaySpecifiedAnimationGetLength(this._entity.Present.PresentLib.FishingWin);
bool flag5 = num < 0f;
if (flag5)
{
this.ErrorLeaveFishing();
return;
}
this._entity.Equipment.PlayFishingRodAnimation(this._fishingRodPresentation.FishingWin);
XSingleton<XDebug>.singleton.AddGreenLog("state = win, time = ", num.ToString(), null, null, null, null);
}
else
{
num = XSingleton<XEntityMgr>.singleton.Player.PlaySpecifiedAnimationGetLength(this._entity.Present.PresentLib.FishingLose);
bool flag6 = num < 0f;
if (flag6)
{
this.ErrorLeaveFishing();
return;
}
this._entity.Equipment.PlayFishingRodAnimation(this._fishingRodPresentation.FishingLose);
}
break;
}
case HomeFishingState.GET:
{
bool first_cast = this.m_first_cast;
if (first_cast)
{
this.m_first_cast = false;
XCameraMotionData xcameraMotionData = new XCameraMotionData();
xcameraMotionData.Motion = "Animation/Main_Camera/Main_Camera_fishing_start";
xcameraMotionData.AutoSync_At_Begin = false;
xcameraMotionData.Coordinate = CameraMotionSpace.World;
xcameraMotionData.Follow_Position = true;
xcameraMotionData.LookAt_Target = false;
xcameraMotionData.At = 0f;
XCameraMotionEventArgs @event = XEventPool<XCameraMotionEventArgs>.GetEvent();
@event.Motion = xcameraMotionData;
@event.Target = XSingleton<XEntityMgr>.singleton.Player;
@event.Trigger = "ToEffect";
@event.Firer = XSingleton<XScene>.singleton.GameCamera;
XSingleton<XEventMgr>.singleton.FireEvent(@event);
}
bool flag7 = XBagDocument.BagDoc.GetItemCount(XHomeFishingDocument.stoshID) == 0UL;
if (flag7)
{
XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("FishingStoshLess"), "fece00");
this.StopFishing();
return;
}
this._currState = HomeFishingState.CAST;
num = XSingleton<XEntityMgr>.singleton.Player.PlaySpecifiedAnimationGetLength(this._entity.Present.PresentLib.FishingCast);
bool flag8 = num < 0f;
if (flag8)
{
this.ErrorLeaveFishing();
return;
}
this._entity.Equipment.PlayFishingRodAnimation(this._fishingRodPresentation.FishingCast);
XSingleton<XDebug>.singleton.AddGreenLog("state = cast, time = ", num.ToString(), null, null, null, null);
break;
}
}
bool flag9 = num > 0f;
if (flag9)
{
this._timerToken = XSingleton<XTimerMgr>.singleton.SetTimer(num, new XTimerMgr.ElapsedEventHandler(this.OnFishingStateChange), null);
}
}
}
public void SetFishingUIState(bool state)
{
bool flag = XSingleton<XScene>.singleton.SceneType != SceneType.SCENE_FAMILYGARDEN;
if (!flag)
{
bool flag2 = state == this._nearFishPoolState;
if (!flag2)
{
this._nearFishPoolState = state;
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.SetUIState(state);
}
}
}
public void ErrorLeaveFishing()
{
bool flag = DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.IsVisible();
if (flag)
{
DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.OnCloseBtnClick(null);
}
else
{
this.LeaveFishing();
}
}
protected bool OnAddItem(XEventArgs args)
{
bool flag = !this._nearFishPoolState;
bool result;
if (flag)
{
result = true;
}
else
{
XAddItemEventArgs xaddItemEventArgs = args as XAddItemEventArgs;
for (int i = 0; i < xaddItemEventArgs.items.Count; i++)
{
bool flag2 = xaddItemEventArgs.items[i].itemID == XHomeFishingDocument.stoshID;
if (flag2)
{
bool flag3 = DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.IsVisible() && DlgBase<HomeFishingDlg, HomeFishingBehaviour>.singleton.uiBehaviour.m_InFishingFrame.activeInHierarchy;
if (flag3)
{
bool flag4 = XBagDocument.BagDoc.GetItemCount(XHomeFishingDocument.stoshID) == (ulong)((long)xaddItemEventArgs.items[i].itemCount);
if (flag4)
{
this.ContinueFishing();
}
}
}
}
result = true;
}
return result;
}
public static void OnFishingStateStop(OutLookStateType newType, XEntity entity)
{
bool flag = newType == OutLookStateType.OutLook_Fish;
if (!flag)
{
XRole xrole = entity as XRole;
bool flag2 = xrole.Attributes.RoleID != XSingleton<XAttributeMgr>.singleton.XPlayerData.RoleID;
if (flag2)
{
XSingleton<XDebug>.singleton.AddGreenLog("outlook delete fishingRom.", null, null, null, null, null);
xrole.DetachComponent(XFishingComponent.uuID);
}
else
{
XHomeFishingDocument specificDocument = XDocuments.GetSpecificDocument<XHomeFishingDocument>(XHomeFishingDocument.uuID);
bool isFishing = specificDocument.IsFishing;
if (isFishing)
{
specificDocument.ServerStopFishing = true;
specificDocument.FishList.Clear();
specificDocument.ErrorLeaveFishing();
}
}
}
}
}
}
|