CombatMagicWeaponEntity.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. using Animancer;
  2. using Common.Utility.CombatEvent;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using Fort23.UTool;
  6. using GameLogic.Combat.Buff;
  7. using UnityEngine;
  8. using UnityEngine.AI;
  9. namespace GameLogic.Combat.Hero
  10. {
  11. /// <summary>
  12. /// 法宝对象
  13. /// </summary>
  14. public class CombatMagicWeaponEntity : CombatHeroEntity
  15. {
  16. protected MagicWeaponConfig _magicWeaponConfig;
  17. public float cd = 10;
  18. private MagicWeaponControl magicWeaponControl;
  19. public async CTask<CombatMagicWeaponEntity> Init(MagicWeaponControl magicWeaponControl,MagicWeaponConfig magicWeaponConfig,
  20. System.Action<CombatMagicWeaponEntity> callBack = null)
  21. {
  22. this.magicWeaponControl = magicWeaponControl;
  23. string modelName = magicWeaponConfig.model;
  24. // GameTimeLineParticleFactory
  25. CombatHeroGameObjectPool poolInterface =
  26. await GObjectPool.Instance.FetchAsync<CombatHeroGameObjectPool>(modelName + ".prefab", null);
  27. #if !COMBAT_SERVER
  28. if (poolInterface == null || poolInterface.own == null)
  29. {
  30. return null;
  31. }
  32. poolInterface.own.transform.position = Vector3.one;
  33. poolInterface.own.SetActive(false);
  34. combatHeroTimeLineControl = new CombatHeroTimeLineControl();
  35. combatHeroTimeLineControl.Init(this);
  36. AssetHandle assetHandle =
  37. await AssetBundleLoadManager.Instance.LoadAssetAsyncTask<TextAsset>(
  38. modelName + "_TD.txt");
  39. if (assetHandle != null)
  40. {
  41. TextAsset textAsset = assetHandle.AssetObject<TextAsset>();
  42. TimeLienData timeLienData = JsonManager.FromJson<TimeLienData>(textAsset.text);
  43. timeLienData.DeserializeData();
  44. assetHandle.Release();
  45. combatHeroTimeLineControl.AddTimeLienData(timeLienData);
  46. }
  47. combatHeroGameObject = new CombatHeroGameObject();
  48. combatHeroGameObject.Init(this, poolInterface);
  49. if (CombatAIBasic == null)
  50. {
  51. CombatAIBasic = new MagicWeaponAi();
  52. }
  53. HeroEntityMono heroEntityMono = poolInterface.own.GetComponent<HeroEntityMono>();
  54. if (heroEntityMono == null)
  55. {
  56. heroEntityMono = poolInterface.own.AddComponent<HeroEntityMono>();
  57. }
  58. heroEntityMono.combatHeroEntity = this;
  59. CombatAIBasic.Init(this);
  60. CombatHeroSkillControl = new CombatHeroSkillControl();
  61. await CombatHeroSkillControl.Init(this);
  62. AnimancerComponent animancerComponent = poolInterface.own.GetComponent<AnimancerComponent>();
  63. combatHeroAnimtion = new CombatHeroAnimtion();
  64. poolInterface.own.SetActive(true);
  65. combatHeroAnimtion.Init(this);
  66. CombatAIBasic.ChangeState(CombatHeroStateType.XiuMian);
  67. #endif
  68. callBack?.Invoke(this);
  69. return this;
  70. }
  71. public override void Update(float t)
  72. {
  73. combatHeroTimeLineControl.Update(t);
  74. if (CombatAIBasic.CurrState.GetType() == typeof(MagicWeaponIdleState))
  75. {
  76. cd -= t;
  77. if (cd <= 0)
  78. {
  79. }
  80. }
  81. }
  82. }
  83. }