DESKTOP-FB72PO8\Administrator 5 месяцев назад
Родитель
Сommit
34049524bb

+ 1 - 1
Assets/Art/ArtHero/Hero01.prefab

@@ -1584,7 +1584,7 @@ Animator:
   m_Controller: {fileID: 0}
   m_CullingMode: 0
   m_UpdateMode: 0
-  m_ApplyRootMotion: 0
+  m_ApplyRootMotion: 1
   m_LinearVelocityBlending: 0
   m_StabilizeFeet: 0
   m_WarningMessage: 

+ 9 - 0
Assets/Art/HeroTimeLine/Hero01.playable

@@ -1903,6 +1903,15 @@ MonoBehaviour:
       weightedMode: 0
       inWeight: 0
       outWeight: 0
+    - serializedVersion: 3
+      time: 0.8141565
+      value: 0.15265764
+      inSlope: 0.52793455
+      outSlope: 0.52793455
+      tangentMode: 0
+      weightedMode: 0
+      inWeight: 0.22059505
+      outWeight: 0.77579695
     - serializedVersion: 3
       time: 1
       value: 1

+ 7 - 1
Assets/Res/HeroAnimtion/Hero01_library.asset

@@ -26,7 +26,7 @@ MonoBehaviour:
           _NormalizedTimes: []
           _Callbacks: []
           _Names: []
-        _Clip: {fileID: 1827226128182048838, guid: 03e7b9c42e25e6c4f89acb40263d29f9, type: 3}
+        _Clip: {fileID: 1827226128182048838, guid: 61b882f7d27344948b5ebcaa1c47a47c, type: 3}
         _NormalizedStartTime: NaN
 --- !u!114 &-6463034078416130267
 MonoBehaviour:
@@ -180,6 +180,12 @@ MonoBehaviour:
     - _From: 0
       _To: 5
       _Fade: 0
+    - _From: 7
+      _To: 5
+      _Fade: 0
+    - _From: 7
+      _To: 6
+      _Fade: 0
     _Aliases: []
     _AliasAllTransitions: 0
 --- !u!114 &4132149882535381313

+ 62 - 0
Assets/Scenes/testCombat.scene

@@ -124,6 +124,67 @@ NavMeshSettings:
     debug:
       m_Flags: 0
   m_NavMeshData: {fileID: 0}
+--- !u!1001 &290659490
+PrefabInstance:
+  m_ObjectHideFlags: 0
+  serializedVersion: 2
+  m_Modification:
+    serializedVersion: 3
+    m_TransformParent: {fileID: 0}
+    m_Modifications:
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalPosition.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalPosition.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalPosition.z
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalRotation.w
+      value: 1
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalRotation.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalRotation.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalRotation.z
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.x
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.y
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 5896097632680916319, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_LocalEulerAnglesHint.z
+      value: 0
+      objectReference: {fileID: 0}
+    - target: {fileID: 7596842400906533007, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_Name
+      value: Hero01
+      objectReference: {fileID: 0}
+    - target: {fileID: 7596842400906533007, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
+      propertyPath: m_IsActive
+      value: 0
+      objectReference: {fileID: 0}
+    m_RemovedComponents: []
+    m_RemovedGameObjects: []
+    m_AddedGameObjects: []
+    m_AddedComponents: []
+  m_SourcePrefab: {fileID: 100100000, guid: ad281f95eddc5284d86b6f7f2aebdea4, type: 3}
 --- !u!1 &376281604
 GameObject:
   m_ObjectHideFlags: 0
@@ -719,3 +780,4 @@ SceneRoots:
   - {fileID: 855042511}
   - {fileID: 646309636}
   - {fileID: 1168356868}
+  - {fileID: 290659490}

+ 2 - 1
Assets/Scripts/Core/State/IState.cs

@@ -1,11 +1,12 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using Core.State;
 using UnityEngine;
 
 public interface IState: IDisposable
 {
-    void Enter();
+    void Enter(IStateEnterData iStateEnterData);
     void Update(float t);
     void Exit();
 }

+ 7 - 0
Assets/Scripts/Core/State/IStateEnterData.cs

@@ -0,0 +1,7 @@
+namespace Core.State
+{
+    public interface IStateEnterData
+    {
+        
+    }
+}

+ 3 - 0
Assets/Scripts/Core/State/IStateEnterData.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 9a7ee9df330b4bbcac043c22c0b5ba57
+timeCreated: 1731570910

+ 2 - 1
Assets/Scripts/Core/State/StateBasic.cs

@@ -1,5 +1,6 @@
 using System.Collections;
 using System.Collections.Generic;
+using Core.State;
 using UnityEngine;
 
 public class StateBasic : IState
@@ -9,7 +10,7 @@ public class StateBasic : IState
         
     }
 
-    public void Enter()
+    public void Enter(IStateEnterData iStateEnterData)
     {
         
     }

+ 2 - 2
Assets/Scripts/Core/State/StateControl.cs

@@ -33,7 +33,7 @@ namespace Core.State
             }
         }
 
-        public void ChangeState(string name)
+        public void ChangeState(string name,IStateEnterData iStateEnterData=null)
         {
             if (!_states.TryGetValue(name, out IState state))
             {
@@ -47,7 +47,7 @@ namespace Core.State
 
             CurrStateName = name;
             _currIState = state;
-            _currIState.Enter();
+            _currIState.Enter(iStateEnterData);
         }
 
         public void Dispose()

+ 24 - 0
Assets/Scripts/Core/Triiger/OnAnimatorMoveEvent.cs

@@ -0,0 +1,24 @@
+using System;
+using UnityEngine;
+
+namespace Core.Triiger
+{
+    public class OnAnimatorMoveEvent : MonoBehaviour
+    {
+        public readonly EasyEvent OnCollisionEnter2DEvent = new EasyEvent();
+
+        private void OnAnimatorMove()
+        {
+            OnCollisionEnter2DEvent.Trigger();
+        }
+    }
+
+    public static class OnAnimatorMoveEventExtension
+    {
+        public static IUnRegister OnAnimatorMove(this GameObject self, Action onAnimatorMove)
+        {
+            return self.GetOrAddComponent<OnAnimatorMoveEvent>().OnCollisionEnter2DEvent
+                .Register(onAnimatorMove);
+        }
+    }
+}

+ 3 - 0
Assets/Scripts/Core/Triiger/OnAnimatorMoveEvent.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: b813f65ce2e941a8bf33c5eca6f6a87b
+timeCreated: 1731571143

+ 3 - 2
Assets/Scripts/GameLogic/Combat/CombatState/CombatStateBasic.cs

@@ -1,4 +1,5 @@
-using GameLogic.Combat.CombatTool;
+using Core.State;
+using GameLogic.Combat.CombatTool;
 
 namespace GameLogic.Combat.CombatState
 {
@@ -11,7 +12,7 @@ namespace GameLogic.Combat.CombatState
             this.CombatController = combatController;
         }
 
-        public void Enter()
+        public void Enter(IStateEnterData iStateEnterData)
         {
             ProEnter();
         }

+ 18 - 2
Assets/Scripts/GameLogic/Combat/Hero/CombatHeroAnimtion.cs

@@ -2,8 +2,10 @@
 using System.Collections.Generic;
 using Animancer;
 using Animancer.TransitionLibraries;
+using Core.Triiger;
 using Fort23.UTool;
 using UnityEngine;
+using UnityEngine.AI;
 using Utility;
 
 namespace GameLogic.Combat.Hero
@@ -14,9 +16,13 @@ namespace GameLogic.Combat.Hero
 
         protected Map<string, TransitionAsset> _transitionMap = new Map<string, TransitionAsset>();
 
-        public void Init(AnimancerComponent animancer)
+        private CombatHeroEntity combatHeroEntity;
+
+        public void Init(AnimancerComponent animancer, CombatHeroEntity combatHeroEntity)
         {
             AnimancerComponent = animancer;
+            AnimancerComponent.gameObject.OnAnimatorMove(OnAnimatorMove);
+            this.combatHeroEntity = combatHeroEntity;
             if (AnimancerComponent != null)
             {
                 // AnimancerComponent.GetAnimationClips();
@@ -35,11 +41,21 @@ namespace GameLogic.Combat.Hero
             }
         }
 
+        protected void OnAnimatorMove()
+        {
+            combatHeroEntity.CombatAIBasic.NavMeshAgent.Raycast(AnimancerComponent.Animator.rootPosition,
+                out NavMeshHit hit);
+            if (!hit.hit)
+            {
+                combatHeroEntity.combatHeroGameObject.SetPosition(AnimancerComponent.Animator.rootPosition);
+            }
+        }
+
         public void Play(string name, float speed = 1)
         {
             if (!_transitionMap.TryGetValue(name, out TransitionAsset clipTransition))
             {
-                LogTool.Log("没有找到要播放的动画"+name);
+                LogTool.Log("没有找到要播放的动画" + name);
                 return;
             }
 

+ 1 - 1
Assets/Scripts/GameLogic/Combat/Hero/CombatHeroEntity.cs

@@ -80,7 +80,7 @@ public class CombatHeroEntity : ITimeLineSpecialDotPos, ILifeCycle, ITimeLineAni
 
         AnimancerComponent animancerComponent = poolInterface.own.GetComponent<AnimancerComponent>();
         combatHeroAnimtion = new CombatHeroAnimtion();
-        combatHeroAnimtion.Init(animancerComponent);
+        combatHeroAnimtion.Init(animancerComponent,this);
         CombatAIBasic.ChangeState(CombatHeroStateType.idle);
         CreateHeroHpEventData createHeroHpEventData = CreateHeroHpEventData.Create();
         createHeroHpEventData.combatHeroEntity = this;

+ 3 - 0
Assets/Scripts/GameLogic/Combat/Hero/CombatHeroGameObject.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Collections;
 using System.Collections.Generic;
+using Core.Triiger;
 using Fort23.UTool;
 using GameLogic.Combat.CombatTool;
 using GameLogic.Combat.Hero;
@@ -35,6 +36,7 @@ public class CombatHeroGameObject: IDisposable
 
     public void SetGameObject(GameObjectPool gameObjectPool)
     {
+       
         hpTransform =  GameObjectPool.own.transform.Find("hp");
         if (hpTransform == null)
         {
@@ -47,6 +49,7 @@ public class CombatHeroGameObject: IDisposable
         _combatHeroHitPoints.Init(_combatHeroEntity, hitPointMono);
         CombatController.currActiveCombat.CombatHeroController.AddHeroHitPoint(_combatHeroEntity.IsEnemy,_combatHeroHitPoints);
     }
+  
 
     public void HeroDie()
     {

+ 7 - 4
Assets/Scripts/GameLogic/Combat/Hero/State/CombatHeroIdleState.cs

@@ -35,10 +35,13 @@ namespace GameLogic.Combat.Hero.State
                 {
                     combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.rolling);
                 }
-                // if (combatHeroEntity.CombatHeroSkillControl.CanReleaseSkill() != null)
-                // {
-                //     combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.att);
-                // }
+                else
+                {
+                    if (combatHeroEntity.CombatHeroSkillControl.CanReleaseSkill() != null)
+                    {
+                        combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.att);
+                    }
+                }
             }
         }
     }

+ 8 - 5
Assets/Scripts/GameLogic/Combat/Hero/State/CombatHeroMoveState.cs

@@ -8,13 +8,14 @@ namespace GameLogic.Combat.Hero.State
         protected Vector3 lasetTaregtPoint;
 
         protected Vector3 lastMovePoint;
+
         public CombatHeroMoveState(CombatHeroEntity combatHeroEntity) : base(combatHeroEntity)
         {
         }
 
         protected override void ProEnter()
         {
-            lasetTaregtPoint = new Vector3(999999,99999,99999);
+            lasetTaregtPoint = new Vector3(999999, 99999, 99999);
             combatHeroEntity.combatHeroAnimtion.Play("run");
             combatHeroEntity.CombatAIBasic.NavMeshAgent.updateRotation = false;
             combatHeroEntity.CombatAIBasic.NavMeshAgent.isStopped = true;
@@ -62,15 +63,17 @@ namespace GameLogic.Combat.Hero.State
                 return;
             }
 
+       
+
             if (!combatHeroEntity.CombatAIBasic.NavMeshAgent.isStopped)
             {
-                
-                Vector3 nextPos = combatHeroEntity.CombatAIBasic.NavMeshAgent.nextPosition;
+                Vector3 nextPos = myPos;
                 Vector3 p = nextPos - lastMovePoint;
-                lastMovePoint= myPos;
+                lastMovePoint = myPos;
                 if (p.sqrMagnitude > 0.00001)
                 {
-                    combatHeroEntity.combatHeroGameObject.rotation= Quaternion.Lerp(combatHeroEntity.combatHeroGameObject.rotation, Quaternion.LookRotation(p.normalized), 0.5f);
+                    combatHeroEntity.combatHeroGameObject.rotation = Quaternion.Lerp(
+                        combatHeroEntity.combatHeroGameObject.rotation, Quaternion.LookRotation(p.normalized), 0.5f);
                 }
             }
         }

+ 19 - 15
Assets/Scripts/GameLogic/Combat/Hero/State/CombatHeroRollingState.cs

@@ -32,6 +32,10 @@ namespace GameLogic.Combat.Hero.State
             try
             {
                 timeLineEventLogicGroup.SetCombatInfo(combatHeroEntity, null, null, new TriggerData(), null);
+                timeLineEventLogicGroup.TimeLineUpdateEnd= delegate
+                {
+                    combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.idle);
+                };
                 combatHeroEntity.combatHeroTimeLineControl.AddEventLogicGroup(timeLineEventLogicGroup);
             }
             catch (Exception e)
@@ -47,21 +51,21 @@ namespace GameLogic.Combat.Hero.State
 
         protected override void ProUpdate(float t)
         {
-            _currTime += t * speed;
-            Vector3 moveToTarget = Vector3.Lerp(startPos, targetPos, ACurve.Evaluate(_currTime));
-
-
-            combatHeroEntity.CombatAIBasic.NavMeshAgent.Raycast(moveToTarget, out NavMeshHit hit);
-            if (!hit.hit)
-            {
-                combatHeroEntity.combatHeroGameObject.SetPosition(moveToTarget);
-            }
-
-            if (_currTime >= 1)
-            {
-                combatHeroEntity.CombatAIBasic.ChangeState(CombatHeroStateType.idle);
-                return;
-            }
+            // _currTime += t * speed;
+            // // Vector3 moveToTarget = Vector3.Lerp(startPos, targetPos, ACurve.Evaluate(_currTime));
+            // //
+            // //
+            // // combatHeroEntity.CombatAIBasic.NavMeshAgent.Raycast(moveToTarget, out NavMeshHit hit);
+            // // if (!hit.hit)
+            // // {
+            // //     combatHeroEntity.combatHeroGameObject.SetPosition(moveToTarget);
+            // // }
+            //
+            // if (_currTime >= 1)
+            // {
+            //    
+            //     return;
+            // }
         }
     }
 }

+ 5 - 2
Assets/Scripts/GameLogic/Combat/Hero/State/CombatHeroStateBasic.cs

@@ -1,17 +1,20 @@
+using Core.State;
+
 namespace GameLogic.Combat.Hero.State
 {
     public class CombatHeroStateBasic : IState
     {
         public CombatHeroEntity combatHeroEntity;
 
-         
+        private IStateEnterData iStateEnterData;
         public CombatHeroStateBasic(CombatHeroEntity combatHeroEntity)
         {
             this.combatHeroEntity = combatHeroEntity;
         }
 
-        public void Enter()
+        public void Enter(IStateEnterData iStateEnterData)
         {
+            this.iStateEnterData = iStateEnterData;
             ProEnter();
         }
 

+ 2 - 0
Fort23.Core.csproj

@@ -148,6 +148,7 @@
     <Compile Include="Assets\Scripts\Core\AssetLoadTool\Asset\LoadAssetCallBackData.cs" />
     <Compile Include="Assets\Scripts\Core\UI\UTool\CTween\CustomTweenManager.cs" />
     <Compile Include="Assets\Scripts\Core\Curve\CurveInfo.cs" />
+    <Compile Include="Assets\Scripts\Core\Triiger\OnAnimatorMoveEvent.cs" />
     <Compile Include="Assets\Scripts\Core\Pool\GPool\GameObjectPool.cs" />
     <Compile Include="Assets\Scripts\Core\Triiger\OnTriggerEnter2DEventTrigger.cs" />
     <Compile Include="Assets\Scripts\Core\State\StateControl.cs" />
@@ -162,6 +163,7 @@
     <Compile Include="Assets\Scripts\Core\UI\UTool\UILoadSpriteHand.cs" />
     <Compile Include="Assets\Scripts\Core\kcp\KcpOutputWriter.cs" />
     <Compile Include="Assets\Scripts\Core\UI\UTool\UIAdapter\UIAdapterForSafeArea.cs" />
+    <Compile Include="Assets\Scripts\Core\State\IStateEnterData.cs" />
     <Compile Include="Assets\Scripts\Core\kcp\KcpSegment.cs" />
     <Compile Include="Assets\Scripts\Core\UI\UTool\ISpriteLoad.cs" />
     <Compile Include="Assets\Scripts\Core\CameraEffect\StressReceiver.cs" />