| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using Animancer;
 
- using Common.Utility.CombatEvent;
 
- using Fort23.Common;
 
- using Fort23.Core;
 
- using Fort23.UTool;
 
- using GameLogic.Combat.CombatTool;
 
- using GameLogic.Combat.Hero;
 
- using UnityEngine;
 
- using UnityEngine.AI;
 
- using UnityEngine.Rendering;
 
- using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventinterface;
 
- public class CombatHeroEntity : ITimeLineSpecialDotPos, ILifeCycle, ITimeLineAnimtion, ITimeLineGetAttSpeed, IHero
 
- {
 
-     public bool IsEnemy { get; set; }
 
-     public bool isDie { get; set; }
 
-     public int number;
 
-     public CombatAIBasic CombatAIBasic;
 
-     public CombatHeroGameObject combatHeroGameObject;
 
-     public CombatHeroInfo CurrCombatHeroInfo;
 
-     public CombatHeroInfo MaxCombatHeroInfo;
 
-     public CombatHeroTimeLineControl combatHeroTimeLineControl;
 
-     public HeroAnimtionBasic combatHeroAnimtion;
 
-     public CombatHeroSkillControl CombatHeroSkillControl;
 
-     public bool isFollowState;
 
-     public BetterList<CombatParticleSystemPool> heroLoopParticle = new BetterList<CombatParticleSystemPool>();
 
-     public Vector3 dotPos
 
-     {
 
-         get { return combatHeroGameObject.position; }
 
-     }
 
-     public T GetThis<T>() where T : IHero
 
-     {
 
-         return (T)(object)this;
 
-     }
 
-     public GameObject GameObject
 
-     {
 
-         get { return combatHeroGameObject.transform.gameObject; }
 
-     }
 
-     public Vector3 faceDir { get; }
 
-     public async CTask<CombatHeroEntity> Init(CombatAIBasic combatAIBasic, CombatHeroInfo combatHeroInfo,
 
-         System.Action<CombatHeroEntity> callBack = null)
 
-     {
 
-         //后面记到检查战斗里面不要出现异步加载,也不要出现同步IO加载
 
-         string modelName = combatHeroInfo.modelName;
 
-         if (combatHeroInfo.isGpu)
 
-         {
 
-             modelName += "_gpu";
 
-         }
 
-         // GameTimeLineParticleFactory
 
-         GameObjectPool poolInterface =
 
-             await GObjectPool.Instance.FetchAsync<GameObjectPool>(modelName + ".prefab", null);
 
- #if !COMBAT_SERVER
 
-         if (poolInterface == null || poolInterface.own == null)
 
-         {
 
-             return null;
 
-         }
 
-         poolInterface.own.SetActive(false);
 
-         AssetHandle assetHandle =
 
-             await AssetBundleLoadManager.Instance.LoadAssetAsyncTask<TextAsset>(combatHeroInfo.modelName + "_TD.txt");
 
-         TextAsset textAsset = assetHandle.AssetObject<TextAsset>();
 
-         TimeLienData timeLienData = JsonManager.FromJson<TimeLienData>(textAsset.text);
 
-         timeLienData.DeserializeData();
 
-         assetHandle.Release();
 
-         combatHeroTimeLineControl = new CombatHeroTimeLineControl();
 
-         combatHeroTimeLineControl.Init(timeLienData);
 
-         combatHeroGameObject = new CombatHeroGameObject();
 
-         combatHeroGameObject.Init(this, poolInterface);
 
-         NavMeshAgent navMeshAgent = poolInterface.own.GetComponent<NavMeshAgent>();
 
-         if (combatAIBasic == null)
 
-         {
 
-             combatAIBasic = new CombatAIBasic();
 
-         }
 
-         HeroEntityMono heroEntityMono = poolInterface.own.GetComponent<HeroEntityMono>();
 
-         if (heroEntityMono == null)
 
-         {
 
-             heroEntityMono = poolInterface.own.AddComponent<HeroEntityMono>();
 
-         }
 
-         heroEntityMono.combatHeroEntity = this;
 
-         CombatAIBasic = combatAIBasic;
 
-         CombatAIBasic.Init(this, navMeshAgent);
 
-         CurrCombatHeroInfo = combatHeroInfo.Copy();
 
-         MaxCombatHeroInfo = combatHeroInfo.Copy();
 
-         CombatHeroSkillControl = new CombatHeroSkillControl();
 
-         CombatHeroSkillControl.Init(this);
 
-         AnimancerComponent animancerComponent = poolInterface.own.GetComponent<AnimancerComponent>();
 
-         if (animancerComponent != null)
 
-         {
 
-             combatHeroAnimtion = new CombatHeroAnimtion();
 
-         }
 
-         else
 
-         {
 
-             combatHeroAnimtion = new CombatHeroGPUAnimtion();
 
-         }
 
-         combatHeroAnimtion.Init(this);
 
-         CombatAIBasic.ChangeState(CombatHeroStateType.XiuMian);
 
-         CreateHeroHpEventData createHeroHpEventData = CreateHeroHpEventData.Create();
 
-         createHeroHpEventData.combatHeroEntity = this;
 
-         EventManager.Instance.Dispatch(CustomEventType.CreateHeroHp, createHeroHpEventData);
 
-         poolInterface.own.SetActive(true);
 
-         callBack?.Invoke(this);
 
- #endif
 
-         return this;
 
-     }
 
-     public void Update(float t)
 
-     {
 
-         CombatAIBasic.Update(t);
 
-         CombatHeroSkillControl.Update(t);
 
-         combatHeroTimeLineControl.Update(t);
 
-         combatHeroAnimtion.Update(t);
 
-     }
 
-     public T This<T>()
 
-     {
 
-         return (T)(object)this;
 
-     }
 
-     public T GetILifetCycleHitPoint<T>(string hitPoinName, bool isStandType, bool isIgnoreHind)
 
-         where T : ILifetCycleHitPoint
 
-     {
 
-         return combatHeroGameObject.GetILifetCycleHitPoint<T>(hitPoinName, isStandType, isIgnoreHind);
 
-     }
 
-     public T GetMainHotPoin<T>(bool isIgnoreHind = false) where T : ILifetCycleHitPoint
 
-     {
 
-         return combatHeroGameObject.GetMainHotPoin<T>(isIgnoreHind);
 
-     }
 
-     public void PlayAnim(string animName, bool isLoop, int layerId, bool repeat, float speed)
 
-     {
 
-         combatHeroAnimtion.Play(animName, speed);
 
-     }
 
-     public SpecialDotInfo GetSpecialDotInfo(string specialDotName)
 
-     {
 
-         return combatHeroGameObject.GetMainHotPoin<CombatHeroHitPoint>(true).GetSpecialDotInfo(specialDotName);
 
-     }
 
-     public float GetAttSpeed()
 
-     {
 
-         return CombatHeroSkillControl.NormalAttSpeedScale;
 
-     }
 
-     public void HeroDie(HarmReturnInfo harmReturnInfo)
 
-     {
 
-         isDie = true;
 
-         HeroDieEventData heroDieEventData = HeroDieEventData.Create();
 
-         heroDieEventData.combatHeroEntity = this;
 
-         heroDieEventData.HarmReturnInfo = harmReturnInfo;
 
-         CombatEventManager.Instance.Dispatch(CombatEventType.HeroDie, heroDieEventData);
 
-         combatHeroGameObject.HeroDie();
 
-         CombatAIBasic.ChangeState(CombatHeroStateType.dile);
 
-     }
 
-     public void HeroHurt(HarmReturnInfo harmReturnInfo)
 
-     {
 
-         CurrCombatHeroInfo.hp -= harmReturnInfo.att;
 
-         HarmUpdateEventData harmUpdateEventData = HarmUpdateEventData.Create();
 
-         harmUpdateEventData.HarmReturnInfo = harmReturnInfo;
 
-         CombatEventManager.Instance.Dispatch(CombatEventType.HarmUpdate, harmUpdateEventData);
 
-         HeroHpUpdateEventData heroHpUpdateEventData = HeroHpUpdateEventData.Create();
 
-         heroHpUpdateEventData.combatHeroEntity = this;
 
-         CombatEventManager.Instance.Dispatch(CombatEventType.HeroHpUpdate, heroHpUpdateEventData);
 
-         if (CurrCombatHeroInfo.hp <= 0)
 
-         {
 
-             HeroDie(harmReturnInfo);
 
-         }
 
-     }
 
-     public void Recover(HarmReturnInfo harmReturnInfo)
 
-     {
 
-         CurrCombatHeroInfo.hp += harmReturnInfo.att;
 
-         HarmUpdateEventData harmUpdateEventData = HarmUpdateEventData.Create();
 
-         harmUpdateEventData.HarmReturnInfo = harmReturnInfo;
 
-         CombatEventManager.Instance.Dispatch(CombatEventType.RecoverUpdate, harmUpdateEventData);
 
-         HeroHpUpdateEventData heroHpUpdateEventData = HeroHpUpdateEventData.Create();
 
-         heroHpUpdateEventData.combatHeroEntity = this;
 
-         CombatEventManager.Instance.Dispatch(CombatEventType.HeroHpUpdate, heroHpUpdateEventData);
 
-     }
 
-     public void CloseLoopFx()
 
-     {
 
-         for (int i = 0; i < heroLoopParticle.Count; i++)
 
-         {
 
-             GObjectPool.Instance.Recycle(heroLoopParticle[i]);
 
-         }
 
-         heroLoopParticle.Clear();
 
-     }
 
-     public bool IsAttDis(Vector3 pos)
 
-     {
 
-         return Vector3.SqrMagnitude(pos - combatHeroGameObject.transform.position) < CurrCombatHeroInfo.maxDisTo;
 
-     }
 
-     public void Dispose()
 
-     {
 
-         CombatHeroSkillControl.Dispose();
 
-         combatHeroGameObject.Dispose();
 
-         CombatAIBasic.Dispose();
 
-         combatHeroTimeLineControl.Dispose();
 
-         combatHeroAnimtion.Dispose();
 
-         CloseLoopFx();
 
-     }
 
- }
 
 
  |