-
Notifications
You must be signed in to change notification settings - Fork 87
/
Iselfplayer.cs
1007 lines (902 loc) · 35.7 KB
/
Iselfplayer.cs
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
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.17929
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
// </By JiangXiBolong>
//------------------------------------------------------------------------------
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using BlGame.GameData;
using JT.FWW.Tools;
using GameDefine;
using System;
using System.Linq;
using JT.FWW.GameData;
using BlGame.GuideDate;
using BlGame.FSM;
using BlGame.GameState;
using BlGame.Resource;
using BlGame.Ctrl;
using BlGame.View;
//
namespace BlGame.GameEntity
{
public class Iselfplayer : Iplayer
{
public Iselfplayer(UInt64 sGUID, EntityCampType campType)
: base(sGUID, campType)
{
UserGameItems = new Dictionary<int, int>();
UserGameItemsCount = new Dictionary<int, int>();
UserGameItemsCoolDown = new Dictionary<int, float>();
for (int ct = 0; ct < 6; ct++)
{
UserGameItems.Add(ct, 0);
UserGameItemsCount.Add(ct, 0);
UserGameItemsCoolDown.Add(ct, 0f);
}
}
public bool IsAbsobing = false;
public bool isTargetChanged = false;
public const int PerFuryValue = 120;
public Dictionary<int, int> UserGameItems
{
private set;
get;
}
public Dictionary<int, int> UserGameItemsCount
{
private set;
get;
}
public Dictionary<int, float> UserGameItemsCoolDown
{
private set;
get;
}
public int[] AbsorbMonsterType = new int[2];
public GameObject objWarning
{
private set;
get;
}
private const float duringTime = 1f;
private const float hpRate = 0.3f;
private const int SKILL_UPDATE_TOTAL_LEVEL = 3;
public Dictionary<SkillType, int> SkillIdDic = new Dictionary<SkillType, int>();
public Dictionary<SkillType, int> BaseSkillIdDic = new Dictionary<SkillType, int>();
public override void OnEntityLeadSkill()
{
base.OnEntityLeadSkill();
ProgressBarInterface.startProgressBar(ProgressBarInterface.BarType.BarSkill, EntitySkillID);
}
//
public override void OnReborn()
{
base.OnReborn();
if (GameMethod.GetCameraGray != null)
{
GameMethod.GetCameraGray.enabled = false;
}
VirtualStickUI.Instance.SetVirtualStickUsable(true);
BlGame.AudioManager.Instance.PlayEffectAudio(RebornClip);
UInt64 myself_guid = PlayerManager.Instance.LocalPlayer.GameObjGUID;
MsgInfoManager.Instance.SetAudioPlay(myself_guid, MsgInfoManager.AudioPlayType.FuhuoAudio);
EventCenter.Broadcast(EGameEvent.eGameEvent_Reborn);
}
enum SlotSkill
{
Slot_KILL_ONE,//吸附槽1
Slot_KILL_TWO
}
public void SetAbsorbMonster(int monsterID, int slot)//slot 0 ,1
{
NpcConfigInfo npcInfo = ConfigReader.GetNpcInfo((int)monsterID);
int skillId = 0;
bool effect = true;
string spriteName = "";
if (AbsorbMonsterType[slot] != monsterID && npcInfo != null)
{
skillId = (slot == 0) ? npcInfo.NpcSkillType3 : npcInfo.NpcSkillType4;
effect = false;
spriteName = npcInfo.HeadPhoto.ToString();
}
else
{
if (AbsorbMonsterType[slot] == monsterID && monsterID != 0)
{
return;
}
}
SetBaseSkillType((SkillType.SKILL_TYPEABSORB1 + slot), skillId);//set absorb skill
SetAbsorbEffect(slot, effect);//set absorb btn effect
AbsorbMonsterType[slot] = monsterID; //set absorb monster id
EventCenter.Broadcast<int,string,bool>(EGameEvent.eGameEvent_AbsorbResult,slot,spriteName,effect);
}
/// <summary>
/// 设置锁定对象
/// </summary>
/// <param name="entity"></param>
/// 锁定随想实例
public override void SetSyncLockTarget(Ientity entity)
{
if (SyncLockTarget == entity)
{
return;
}
if (SyncLockTarget != null && SyncLockTarget.realObject != null)
{
if (SyncLockTarget.XueTiao != null)
{
SyncLockTarget.XueTiao.IsXueTiaoCpVib(false);
}
}
this.DeltLockTargetXuetiao(entity);
this.isTargetChanged = true;
this.SyncLockTarget = entity;
OnFocusTargetChanged();
UInt64 objId = (entity == null) ? 0 : entity.GameObjGUID;
CGLCtrl_GameLogic.Instance.EmsgToss_AskLockTarget(objId);
if (entity != null && entity is Iplayer)
{
AddOrDelEnemy((Iplayer)entity, true);
}
else
{
AddOrDelEnemy(null, true);
}
EventCenter.Broadcast<Ientity>(EGameEvent.eGameEvent_LockTarget, entity);
}
public override void OnEntityPrepareAttack()
{
}
public override void OnUpdate()
{
UpdateCoolDownGameItems();
base.OnUpdate();
if (Time.frameCount % 5 != 0)
{
return;
}
BuildingAtkWarningManager.Instance.OnUpdate();
//SecondaryGuideManager.Instance.OnUpdate();
IGuideMidMatchTip.Instance.OnUpdate();
//if (UIEnemyTeamMateInfo.Instance != null)
//{
// UIEnemyTeamMateInfo.Instance.OnUpdate();
//}
if (this.FSM != null && this.FSM.State == FsmState.FSM_STATE_DEAD)
{
return;
}
if (SyncLockTarget != null && SyncLockTarget.realObject != null)
{
if (Vector3.Distance(this.objTransform.position, SyncLockTarget.objTransform.position) > GameConstDefine.PlayerLockTargetDis)
{
if (!PlayerManager.Instance.IsLocalSameType(SyncLockTarget) && SyncLockTarget.entityType == EntityType.Monster || SyncLockTarget.entityType == EntityType.Soldier)
{
if (SyncLockTarget.XueTiao != null)
{
SyncLockTarget.XueTiao.IsXueTiaoCpVib(false);
}
}
this.SetSyncLockTarget(null);
}
return;
}
if (AutoLockTarget)
{
IEnumerable<Ientity> ItemList = GameMethod.GetEnemyItemListByRadius(PlayerManager.Instance.LocalPlayer, GameConstDefine.PlayerLockTargetDis);
IEnumerator<Ientity> Item = ItemList.GetEnumerator();
Item.MoveNext();
if (ItemList == null || Item.Current == null)
{
return;
}
this.SetSyncLockTarget(Item.Current);
}
}
public bool AutoLockTarget = true;
/// <summary>
/// 对象移动检测
/// </summary>
protected override void EntityMoveCheck()
{
base.EntityMoveCheck();
//this.CheckEnterAltar();
}
public override void OnEntitySkill()
{
if (SyncLockTarget == null || SyncLockTarget.RealEntity == null)
{
return;
}
}
public override void OnEntityExitPrepareSkill()
{
//ProgressBarInterface.stopBacktoCity();
}
/// <summary>
/// 进入Free状态
/// </summary>
public override void OnEnterFree()
{
base.OnEnterFree();
BlGame.AudioManager.Instance.StopHeroAudio();
}
public override void OnEnterEntityAdMove()
{
base.OnEnterEntityAdMove();
}
public override void OnExecuteEntityAdMove()
{
base.OnExecuteEntityAdMove();
Quaternion DestQuaternion = Quaternion.LookRotation(EntityFSMDirection);
Quaternion sMidQuater = Quaternion.Lerp(RealEntity.GetTransform().rotation, DestQuaternion, 10 * Time.deltaTime);
RealEntity.GetTransform().rotation = sMidQuater;
this.RealEntity.PlayerRunAnimation();
}
private bool bPlaySkill = false;
//
public override void OnEntityReleaseSkill()
{
if (EntitySkillID == 250101)//回城技能
{
Debug.Log("回城技能");
ProgressBarInterface.startProgressBar(ProgressBarInterface.BarType.BarSkill);
}
else
{
bPlaySkill = true;
base.OnEntityReleaseSkill();
//
}
//GameMethod.DebugError("player attack");
//
}
public void RemoveAreaCircle()
{
if (CircleArea != null)
{
UnityEngine.GameObject.DestroyImmediate(CircleArea);
}
}
//临时在这里管理光圈
private GameObject CircleArea = null;
private GameObject CircleGreen = null;
private GameObject CircleYellow = null;
private GameObject CircleRed = null;
//
public void initAreaCircle()
{
//if (SceneGuideTaskManager.Instance().IsNewsGuide() == SceneGuideTaskManager.SceneGuideType.NoGuide)
// return;
if (RealEntity == null)
return;
if (CircleArea == null)
{
string path = GameConstDefine.LoadGameOtherEffectPath;
//GameObject obj = Resources.Load(path + "guangquan_fanwei") as GameObject;
ResourceUnit objUnit = ResourcesManager.Instance.loadImmediate(path + "guangquan_fanwei", ResourceType.PREFAB);
GameObject obj = objUnit.Asset as GameObject;
if (obj == null)
{
GameMethod.DebugError("CircleArea obj null");
return;
}
//root = GameObject.Instantiate (obj) as GameObject;
CircleArea = GameObject.Instantiate(obj) as GameObject;
CircleArea.transform.parent = RealEntity.GetTransform();
CircleArea.transform.position = RealEntity.GetTransform().position + new Vector3(0.0f, 0.2f, 0.0f);
EventCenter.AddListener(EGameEvent.eGameEvent_LocalPlayerRange,UpdataRange);
CircleArea.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));
}
CapsuleCollider capsule = RealEntity.GetComponent<CapsuleCollider>();
if (capsule)
{
capsule.enabled = false;
}
}
private void UpdataRange()
{
if (CircleArea == null)
return;
if (RealEntity == null)
return;
CircleArea.transform.localScale = new Vector3(this.AtkDis * 2.0f / RealEntity.GetTransform().localScale.x, 1.0f, this.AtkDis * 2.0f / RealEntity.GetTransform().localScale.z);
}
//
public void OnFocusTargetChanged()
{
checkCircleRes();
if (SyncLockTarget == null)
{
setCircleEnable(CircleGreen, false);
setCircleEnable(CircleYellow, false);
setCircleEnable(CircleRed, false);
}
else if (SyncLockTarget.EntityCamp == EntityCamp)//友军
{
setCircleEnable(CircleGreen, true);
setCircleEnable(CircleYellow, false);
setCircleEnable(CircleRed, false);
}
else if (SyncLockTarget.EntityCamp == EntityCampType.CampTypeBad)
{
setCircleEnable(CircleGreen, false);
setCircleEnable(CircleYellow, true);
setCircleEnable(CircleRed, false);
}
else
{
setCircleEnable(CircleGreen, false);
setCircleEnable(CircleYellow, false);
setCircleEnable(CircleRed, true);
}
}
private void checkCircleRes()
{
string path = GameConstDefine.LoadGameOtherEffectPath;
if (CircleRed == null)
{
ResourceUnit objUnit = ResourcesManager.Instance.loadImmediate(path + "guangquan_red", ResourceType.PREFAB);
CircleRed = GameObject.Instantiate(objUnit.Asset) as GameObject;
}
if (CircleGreen == null)
{
ResourceUnit objUnit = ResourcesManager.Instance.loadImmediate(path + "guangquan_green", ResourceType.PREFAB);
CircleGreen = GameObject.Instantiate(objUnit.Asset) as GameObject;
}
if (CircleYellow == null)
{
ResourceUnit objUnit = ResourcesManager.Instance.loadImmediate(path + "guangquan_yellow", ResourceType.PREFAB);
CircleYellow = GameObject.Instantiate(objUnit.Asset) as GameObject;
}
}
private void setCircleEnable(GameObject obj, bool bEnabled)
{
if (bEnabled == true)
{
if (SyncLockTarget != null && SyncLockTarget.realObject != null)
{
obj.transform.parent = SyncLockTarget.realObject.transform;
obj.transform.position = SyncLockTarget.realObject.transform.position + new Vector3(0.0f, 0.2f, 0.0f);
obj.transform.localRotation = Quaternion.Euler(new Vector3(0.0f, 0.0f, 0.0f));
obj.gameObject.SetActive(true);
float radius = 1.0f;
if (CTools.IfTypeHero((JT.FWW.GameData.EObjectType)SyncLockTarget.NpcGUIDType))
{
radius = ConfigReader.HeroXmlInfoDict[SyncLockTarget.NpcGUIDType].n32LockRadious;
obj.transform.localScale = new Vector3(radius, 1.0f, radius);
}
else
{
radius = ConfigReader.NpcXmlInfoDict[SyncLockTarget.NpcGUIDType].n32LockRadius;
obj.transform.localScale = new Vector3(radius, 1.0f, radius);
}
}
}
else
{
obj.transform.parent = null;
obj.gameObject.SetActive(false);
}
}
//
public override void OnSkillAnimationEnd()
{
if (bPlaySkill == false)
//if (FSM.State != FsmState.FSM_STATE_PREPARESKILL)
{
OnFSMStateChange(EntityFreeFSM.Instance);
}
}
//
public override void OnAttackAnimationEnd()
{
OnFSMStateChange(EntityFreeFSM.Instance);
}
//请求吸附怪物
const int absBigLevel = 7;
const int absSmallLevel = 3;
public void SendAbsortMonster()
{
if (SyncLockTarget == null)
{
MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_NeedLockTarget);
return;
}
if (SyncLockTarget.entityType == EntityType.Building || SyncLockTarget.entityType == EntityType.Player || SyncLockTarget.entityType == EntityType.Soldier)
{
MsgInfoManager.Instance.ShowMsg(-130956);
return;
}
NpcConfigInfo info = ConfigReader.GetNpcInfo(SyncLockTarget.NpcGUIDType);
if (info == null)
return;
int isLock = info.NpcCanControl;
if (IsAbsobing == true)
return;
if (AbsorbMonsterType[0] != 0 && AbsorbMonsterType[1] != 0 && Level >= absBigLevel && (AbsorbMonsterType[1] != SyncLockTarget.NpcGUIDType && AbsorbMonsterType[0] != SyncLockTarget.NpcGUIDType) && isLock != 0)
{
CreateSoleSoldier();
return;
}
if (AbsorbMonsterType[0] != 0 && Level >= absSmallLevel && AbsorbMonsterType[0] != SyncLockTarget.NpcGUIDType && isLock != 0 && AbsorbMonsterType[1] == 0 && AbsorbMonsterType[1] != SyncLockTarget.NpcGUIDType && Level < absBigLevel)
{
CreateSoleSoldier();
return;
}
int npcType = -1;
CGLCtrl_GameLogic.Instance.EmsgToss_AskAbsorb(npcType);
}
void CreateSoleSoldier()
{
SoleSoldierCtrl.Instance.Enter();
//UISoleSoldier.Instance.OnTriggerAltar();
}
/// <summary>
/// 准备释放技能
/// </summary>
/// <param name="skType">Sk type.</param>
/// 技能类型
public void SendPreparePlaySkill(SkillType skType)
{
int skillID = GetSkillIdBySkillType(skType);
//沉默了
if (BlGame.Skill.BuffManager.Instance.isSelfHaveBuffType(1017))
{
return;
}
if (skillID == 0)
{
MsgInfoManager.Instance.ShowMsg((int)ERROR_TYPE.eT_AbsentSkillNULL);
return;
}
CGLCtrl_GameLogic.Instance.EmsgToss_AskUseSkill((uint)skillID);
}
public override int GetSkillIdBySkillType(SkillType type)
{
return GetSkillId(type);
}
public override void OnAttackEnd()
{
RealEntity.PlayerFreeAnimation();
}
/// <summary>
/// Run状态进入时调用
/// </summary>
public override void OnEnterMove()
{
BlGame.AudioManager.Instance.PlayHeroAudio(WalkAudioClip);
base.OnEnterMove();
}
//public bool CheckGuideMove(Vector3 pos) {
// if (!SceneGuideTaskManager.Instance().CheckObstructTaskCanMove(pos)) {
// RealEntity.PlayerFreeAnimation();
// OnCameraUpdatePosition();
// if (FSM != null && FSM.State != FsmState.FSM_STATE_FREE)
// CGLCtrl_GameLogic.Instance.EmsgToss_AskStopMove();
// return false;
// }
// return true;
//}
/// <summary>
/// 执行强制移动
/// </summary>
public override void OnExecuteForceMove()
{
//base.OnExecuteForceMove();
Quaternion DestQuaternion = Quaternion.LookRotation(EntityFSMDirection);
Quaternion sMidQuater = Quaternion.Lerp(RealEntity.GetTransform().rotation, DestQuaternion, 10 * Time.deltaTime);
RealEntity.GetTransform().rotation = sMidQuater;
float fTimeSpan = Time.realtimeSinceStartup - m_pcGOSSI.fBeginTime;
float fMoveDist = fTimeSpan * m_pcGOSSI.fForceMoveSpeed;
m_pcGOSSI.sServerSyncPos = m_pcGOSSI.sServerBeginPos + m_pcGOSSI.sServerDir * fMoveDist;
SkillMoveConfig skillInfo = ConfigReader.GetSkillMoveConfig(EntitySkillModelId);
if (skillInfo != null)
{
this.RealEntity.PlayerAnimation(skillInfo.action);
}
//2D位置同步
Vector3 serverPos2D = new Vector3(m_pcGOSSI.sServerSyncPos.x, 60, m_pcGOSSI.sServerSyncPos.z);
Vector3 realPos2D = new Vector3(RealEntity.GetTransform().position.x, 60, RealEntity.GetTransform().position.z);
Vector3 sSyncDir = serverPos2D - realPos2D;
sSyncDir.y = 0;
sSyncDir.Normalize();
float fDistToServerPos = Vector3.Distance(serverPos2D, realPos2D);
float fThisMoveSpeed = EntityFSMMoveSpeed;
if (fDistToServerPos > 10)
{
RealEntity.GetTransform().position = m_pcGOSSI.sServerBeginPos;
GameMethod.GetMainCamera.FixedUpdatePosition();
return;
}
Vector3 pos = realPos2D + EntityFSMMoveSpeed * Time.deltaTime * sSyncDir;
//this.realObject.transform.position = pos;
this.RealEntity.Controller.Move(sSyncDir * m_pcGOSSI.fForceMoveSpeed * Time.deltaTime);
GameMethod.GetMainCamera.FixedUpdatePosition();
}
public override void SetHp(float curHp)
{
base.SetHp(curHp);
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerHpChange);
//if(UIAvatarInfo.Instance != null){
// UIAvatarInfo.Instance.UpdateHpSlider();
//}
AddRuinWarning();
}
public override void SetHpMax(float curHpMax)
{
base.SetHpMax(curHpMax);
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerHpChange);
//if(UIAvatarInfo.Instance != null){
// UIAvatarInfo.Instance.UpdateHpSlider();
//}
AddRuinWarning();
}
public override void SetMp(float curMp)
{
base.SetMp(curMp);
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerMpChange);
//if(UIAvatarInfo.Instance != null){
// UIAvatarInfo.Instance.UpdateMpSlider();
//}
}
public override void SetMpMax(float curMpMax)
{
base.SetMpMax(curMpMax);
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerMpChange);
//if(UIAvatarInfo.Instance != null){
// UIAvatarInfo.Instance.UpdateMpSlider();
//}
}
public override void SetLevel(int curLv)
{
base.SetLevel(curLv);
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerLevelChange, curLv);
if (curLv != 1)
{
SetUpdateSkillId(curLv);
EventCenter.Broadcast(EGameEvent.eGameEvent_SkillDescribleUpdate);
}
}
//初始化技能升级列表
private void InitSkillDic(Dictionary<SkillType, int> skillDic)
{
int id = (int)ObjTypeID;
HeroConfigInfo heroInfo = ConfigReader.GetHeroInfo(id);
skillDic.Add(SkillType.SKILL_TYPE1, heroInfo.HeroSkillType1);
skillDic.Add(SkillType.SKILL_TYPE2, heroInfo.HeroSkillType2);
skillDic.Add(SkillType.SKILL_TYPE3, heroInfo.HeroSkillType3);
skillDic.Add(SkillType.SKILL_TYPE4, heroInfo.HeroSkillType4);
skillDic.Add(SkillType.SKILL_TYPEABSORB1, 0);
skillDic.Add(SkillType.SKILL_TYPEABSORB2, 0);
}
private void CleanSkillDic(Dictionary<SkillType, int> skillDic)
{
skillDic.Clear();
}
//技能升级时获得对应技能的Id
private void SetUpdateSkillId(int lv)
{
SetSkillUpdate(SkillType.SKILL_TYPE1, lv);
SetSkillUpdate(SkillType.SKILL_TYPE2, lv);
SetSkillUpdate(SkillType.SKILL_TYPE3, lv);
SetSkillUpdate(SkillType.SKILL_TYPE4, lv);
//暂时屏蔽随从技能升级
//SetSkillUpdate(SkillType.SKILL_TYPEABSORB1, lv);
//SetSkillUpdate(SkillType.SKILL_TYPEABSORB2, lv);
}
//更具技能类型,换算出满足指定技能的准确id
private void SetSkillUpdate(SkillType skillType, int lv)
{
int baseId = 0;
if (!BaseSkillIdDic.TryGetValue(skillType, out baseId)) return;//技能id不存在
SkillManagerConfig info = ConfigReader.GetSkillManagerCfg(baseId);
if (baseId == 0 || info == null)
{
return;//不存在技能信息
}
for (int i = baseId + SKILL_UPDATE_TOTAL_LEVEL - 1; i >= 0; i--)
{
SkillManagerConfig infoNew = ConfigReader.GetSkillManagerCfg(i);
if (i == 0 || infoNew == null || infoNew.n32UpgradeLevel > lv)
continue;
SkillIdDic[skillType] = i;
break;
}
}
//当更改基础技能时,比如随从技能改变
private void SetBaseSkillType(SkillType skillType, int skillId)
{
BaseSkillIdDic[skillType] = skillId;
//暂时屏蔽随从技能升级
if (skillType == SkillType.SKILL_TYPEABSORB1 || skillType == SkillType.SKILL_TYPEABSORB2)
{
SkillIdDic[skillType] = skillId;
return;
}
SkillManagerConfig info = ConfigReader.GetSkillManagerCfg(skillId);
if (skillId != 0 && info != null)
{
SetSkillUpdate(skillType, Level);
}
else if (skillId == 0)
{
SkillIdDic[skillType] = skillId;
}
}
//得到换算后的技能id
private int GetSkillId(SkillType type)
{
int baseId = 0;
if (SkillIdDic.TryGetValue(type, out baseId))
{
return baseId;
}
return 0;
}
public override void OnSkillInfoChange(int skillID, float time, float maxTime, int slot)
{
SkillType skillType = SkillType.SKILL_NULL;
if (skillID == SkillIdDic[SkillType.SKILL_TYPE1])
{
skillType = SkillType.SKILL_TYPE1;
}
else if (skillID == SkillIdDic[SkillType.SKILL_TYPE3])
{
skillType = SkillType.SKILL_TYPE3;
}
else if (skillID == SkillIdDic[SkillType.SKILL_TYPE2])
{
skillType = SkillType.SKILL_TYPE2;
}
else if (skillID == SkillIdDic[SkillType.SKILL_TYPE4])
{
skillType = SkillType.SKILL_TYPE4;
}
else if (skillID == SkillIdDic[SkillType.SKILL_TYPEABSORB1])
{
skillType = SkillType.SKILL_TYPEABSORB1;
}
else if (skillID == SkillIdDic[SkillType.SKILL_TYPEABSORB2])
{
skillType = SkillType.SKILL_TYPEABSORB2;
}
else
{
return;
}
SetBaseSkillType(skillType, skillID);
if (time > 0)
{
bPlaySkill = false;
}
EventCenter.Broadcast<SkillType, float, float>(EGameEvent.eGameEvent_LocalPlayerSkillCD, skillType, maxTime, time);
}
//获取对应技能的冷却时间
public float getSkillCoolDownTime(int skillID)
{
if (ConfigReader.GetSkillManagerCfg(skillID) == null)
{
return 10.0f;
}
return ConfigReader.GetSkillManagerCfg(skillID).coolDown / 1000.0f;
}
public override void SetExp(float curExp)
{
base.SetExp(curExp);
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerExpChange);
//if(UIAvatarInfo.Instance != null){
// UIAvatarInfo.Instance.UpdateExp();
//}
}
public override void OnEnterDead()
{
VirtualStickUI.Instance.SetVirtualStickUsable(false);
if (GameMethod.GetCameraGray != null)
{
GameMethod.GetCameraGray.enabled = true;
GameMethod.GetCameraGray.texFactor = 0f;
this.StrategyTick = Time.time;
}
this.SetSyncLockTarget(null);
RealEntity.PlayerDeadAnimation();
//if(UIAvatarInfo.Instance != null){
// UIAvatarInfo.Instance.UpdateLockHead();
//}
BlGame.AudioManager.Instance.PlayEffectAudio(DeadAudioClip);
RemoveRuinWarning();
//當英雄死了之後,就停止播放該英雄相關的所有聲音
BlGame.AudioManager.Instance.StopHeroAudio();
this.DoEntityDead();
}
public override void OnExecuteDead()
{
if (GameMethod.GetCameraGray != null && GameMethod.GetCameraGray.enabled)
{
float time = Time.time - this.StrategyTick;
if (time <= CommonDefine.CameraGrayTime)
{
GameMethod.GetCameraGray.texFactor = time / CommonDefine.CameraGrayTime;
}
}
}
public override void InitWhenCreateModel()
{
// base.InitWhenCreateModel();
if (PlayerPrefs.HasKey(GameMethod.RangeVoc))
{
int sKey = PlayerPrefs.GetInt(GameMethod.RangeVoc);
bool state = (sKey == 1) ? true : false;
GameMethod.SetRange(state);
}
bool effectState = false;
if (PlayerPrefs.HasKey(GameMethod.EffectVoc))
{
int sKey = PlayerPrefs.GetInt(GameMethod.EffectVoc);
effectState = (sKey == 1) ? true : false;
}
GameMethod.SetEffect(effectState);
InitSkillDic(SkillIdDic);
InitSkillDic(BaseSkillIdDic);
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerInit);
ResourceUnit WalkAudioClipUnit = ResourcesManager.Instance.loadImmediate(AudioDefine.PATH_HERO_WALKSOUND + ConfigReader.GetHeroInfo(this.NpcGUIDType).un32WalkSound, ResourceType.ASSET);
WalkAudioClip = WalkAudioClipUnit.Asset as AudioClip;
ResourceUnit DeadAudioClipUnit = ResourcesManager.Instance.loadImmediate(AudioDefine.PATH_HERO_DEADSOUND + ConfigReader.GetHeroInfo(this.NpcGUIDType).HeroDeathSould, ResourceType.ASSET);
DeadAudioClip = DeadAudioClipUnit.Asset as AudioClip;
ResourceUnit EnterAltarClipUnit = ResourcesManager.Instance.loadImmediate(AudioDefine.PATH_ENTERALTAR_SOUND, ResourceType.ASSET);
EnterAltarClip = EnterAltarClipUnit.Asset as AudioClip;
ResourceUnit RebornClipUnit = ResourcesManager.Instance.loadImmediate(AudioDefine.PATH_REBORN_SOUND, ResourceType.ASSET);
RebornClip = RebornClipUnit.Asset as AudioClip;
base.InitWhenCreateModel();
EventCenter.AddListener<UInt64>(EGameEvent.eGameEvent_GameOver, OnGameOver);
OnCameraUpdatePosition();
}
private void OnGameOver(UInt64 BsGuid)
{
RemoveRuinWarning();
EventCenter.RemoveListener(EGameEvent.eGameEvent_LocalPlayerRange, UpdataRange);
EventCenter.RemoveListener<UInt64>(EGameEvent.eGameEvent_GameOver, OnGameOver);
}
private AudioClip DeadAudioClip;
private AudioClip WalkAudioClip;
private AudioClip EnterAltarClip;
private AudioClip RebornClip;
public AudioClip GetAltarClip()
{
return EnterAltarClip;
}
protected override void UpdateFuryEffect()
{
base.UpdateFuryEffect();
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerUpdateFuryEffect);
}
protected override void UpdateFuryValue()
{
base.UpdateFuryValue();
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerUpdateFuryValue);
}
public override void SetFuryState(EFuryState state)
{
base.SetFuryState(state);
if (state == EFuryState.eFuryNullState)
{
EventCenter.Broadcast(EGameEvent.eGameEvent_LocalPlayerUpdateFuryValue);
}
EventCenter.Broadcast<EFuryState>(EGameEvent.eGameEvent_FuryStateInfo, state);
}
public void AddUserGameItems(int index, int id, int count, float last)
{
UserGameItems[index] = id;
UserGameItemsCount[index] = count;
UserGameItemsCoolDown[index] = last;
}
void UpdateCoolDownGameItems()
{
if (UserGameItemsCoolDown == null || UserGameItemsCoolDown.Count == 0)
return;
for (int i = 0; i < UserGameItemsCoolDown.Count; i++)
{
if (UserGameItemsCoolDown.ElementAt(i).Value > Time.deltaTime)
{
float time = (float)UserGameItemsCoolDown.ElementAt(i).Value;
time -= Time.deltaTime;
UserGameItemsCoolDown[UserGameItemsCoolDown.ElementAt(i).Key] = time;
}
else
{
UserGameItemsCoolDown[UserGameItemsCoolDown.ElementAt(i).Key] = 0f;
}
}
}
public void AddRuinWarning()
{
if (GameStateManager.Instance.GetCurState().GetStateType() != GameStateType.GS_Play)
return;
if (HpMax == 0)
{
return;
}
float rate = Hp / HpMax;
if (rate >= hpRate || rate <= 0)
{
RemoveRuinWarning();
return;
}
SendHpLessWarning(true);
if (objWarning != null)
{
return;
}
//objWarning = GameObject.Instantiate(Resources.Load(GameDefine.GameConstDefine.WarningRuin)) as GameObject;
ResourceUnit objWarningUnit = ResourcesManager.Instance.loadImmediate(GameDefine.GameConstDefine.WarningRuin, ResourceType.PREFAB);
objWarning = GameObject.Instantiate(objWarningUnit.Asset) as GameObject;
objWarning.transform.parent = WindowManager.Instance.GetWindow(EWindowType.EWT_GamePlayWindow).GetRoot();
objWarning.transform.localPosition = Vector3.zero;
objWarning.transform.localScale = Vector3.one;
UITweener tween = TweenAlpha.Begin(objWarning, duringTime, 0f);
tween.method = UITweener.Method.BounceIn;
tween.style = UITweener.Style.PingPong;
}
private void SendHpLessWarning(bool tag)
{
CEvent eve = new CEvent(EGameEvent.eGameEvent_NotifyHpLessWarning);
eve.AddParam("Tag", tag);
EventCenter.SendEvent(eve);
}
public void RemoveRuinWarning()
{
if (objWarning == null)
{
return;
}
SendHpLessWarning(false);
GameObject.DestroyImmediate(objWarning);
objWarning = null;
}
public override void CleanWhenGameOver()
{
UserGameItems.Clear();
UserGameItemsCount.Clear();
UserGameItemsCoolDown.Clear();
CleanSkillDic(SkillIdDic);
CleanSkillDic(BaseSkillIdDic);
SetFuryValue(0);
SetFuryState(EFuryState.eFuryNullState);
if (AbsorbMonsterType != null)
{
AbsorbMonsterType[0] = 0;
AbsorbMonsterType[1] = 0;
}
BattleingData.AllBlueHeroBattle.Clear();
BattleingData.AllRedHeroBattle.Clear();
}
public override void OnEnterSing()
{
base.OnEnterSing();
SkillManagerConfig skillconfig = ConfigReader.GetSkillManagerCfg(EntitySkillID);
//Debug.Log("EntitySkillId:" + EntitySkillID + "skillConfig.yTime" + skillconfig.yTime);
ProgressBarInterface.startProgressBar(skillconfig.yTime);
}
public override void OnExitSing()
{
base.OnExitSing();
ProgressBarInterface.hideProgressBar();
}
//public override bool CheckGuideCanMove(Vector3 pos)
//{
// if (!this.CheckGuideMove(pos))
// {