123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- using Animancer;
- using Core.Event.Event;
- using Fort23.Core;
- using OfficeOpenXml.FormulaParsing.Excel.Functions.Logical;
- using UnityEngine;
- using UnityEngine.AI;
- namespace GameLogic.Combat.Hero.State
- {
- public class CombatHeroMoveState : CombatHeroStateBasic
- {
- protected Vector3 lasetTaregtPoint;
- protected Vector3 lastMovePoint;
- protected HeroPlayStateInfoBasic _transitionAsset;
- protected bool isStop;
- public CombatHeroMoveState(CombatHeroEntity combatHeroEntity) : base(combatHeroEntity)
- {
- }
- public override bool IsUpdateLockTarget()
- {
- return false;
- }
- protected override void ProEnter()
- {
- EventManager.Instance.AddEventListener(CustomEventType.RefreshFull,RefreshFull);
-
- Start();
- }
- protected void Start()
- {
- lasetTaregtPoint = new Vector3(999999, 99999, 99999);
- _transitionAsset = combatHeroEntity.combatHeroAnimtion.Play("run");
-
-
- }
- protected void RefreshFull(IEventData ieEventData)
- {
- RefreshFullEventData data = (RefreshFullEventData)ieEventData;
- if (data.isFullShow&&!isStop)
- {
- isStop = true;
-
- }
- else if(isStop)
- {
- Start();
- isStop = false;
- }
- }
- protected override void ProExit()
- {
- EventManager.Instance.RemoveEventListener(CustomEventType.RefreshFull,RefreshFull);
-
-
- // combatHeroEntity.CombatAIBasic.NavMeshAgent.acceleration = 0;
- }
- protected void SetNewPath(Vector3 taregtPos)
- {
- lastMovePoint = combatHeroEntity.dotPos;
- lasetTaregtPoint = taregtPos;
-
- }
- protected override void ProUpdate(float t)
- {
-
- if (combatHeroEntity.CombatAIBasic.currFocusTarget == null)
- {
- combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.idle);
- return;
- }
- if (combatHeroEntity.CombatHeroSkillControl.CanReleaseSkill() != null)
- {
- combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.att);
- return;
- }
- Vector3 targetPos = combatHeroEntity.CombatAIBasic.currFocusTarget.dotPos;
- Vector3 myPos = combatHeroEntity.dotPos;
-
- float dis = combatHeroEntity.CurrCombatHeroInfo.maxDisTo;
- if (combatHeroEntity.CombatAIBasic.currFocusTarget is BannerHero)
- {
- dis = 1;
- }
-
- if (Vector3.SqrMagnitude(targetPos - myPos) >
- dis)
- {
- if (Vector3.SqrMagnitude(lasetTaregtPoint - targetPos) > 1)
- {
- // SetNewPath(targetPos);
- }
- }
- else
- {
- combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.idle);
- return;
- }
-
-
- }
- }
- }
|