From ac2b469bd76d7d91d10894184cbddad0796ce7bc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 16 Nov 2020 14:38:55 +0800 Subject: *statecontroller --- Assets/Scripts/Avatar/Actions/ActionJump.cs | 2 +- Assets/Scripts/Avatar/Actions/ActionJumpForward.cs | 2 +- Assets/Scripts/Avatar/Actions/ActionSwitchAbility.cs | 8 ++++---- Assets/Scripts/Avatar/Avatar.cs | 12 ++++++------ Assets/Scripts/Avatar/Avatar_Hurt.cs | 12 ++++++------ Assets/Scripts/Avatar/StateSystem.cs | 4 ++-- 6 files changed, 20 insertions(+), 20 deletions(-) (limited to 'Assets/Scripts/Avatar') diff --git a/Assets/Scripts/Avatar/Actions/ActionJump.cs b/Assets/Scripts/Avatar/Actions/ActionJump.cs index b281a7b3..364dd7de 100644 --- a/Assets/Scripts/Avatar/Actions/ActionJump.cs +++ b/Assets/Scripts/Avatar/Actions/ActionJump.cs @@ -7,7 +7,7 @@ public class ActionJump : ActionSwitchState { private JumpState m_JumpState; - public ActionJump(StateSystem system, JumpState jumpState) + public ActionJump(StateController system, JumpState jumpState) : base(system, jumpState) { m_JumpState = jumpState; diff --git a/Assets/Scripts/Avatar/Actions/ActionJumpForward.cs b/Assets/Scripts/Avatar/Actions/ActionJumpForward.cs index d130411f..2fb28dc4 100644 --- a/Assets/Scripts/Avatar/Actions/ActionJumpForward.cs +++ b/Assets/Scripts/Avatar/Actions/ActionJumpForward.cs @@ -7,7 +7,7 @@ public class ActionJumpForward : ActionSwitchState { private JumpState m_JumpState; - public ActionJumpForward(StateSystem system, JumpState jumpState) + public ActionJumpForward(StateController system, JumpState jumpState) : base(system, jumpState) { m_JumpState = jumpState; diff --git a/Assets/Scripts/Avatar/Actions/ActionSwitchAbility.cs b/Assets/Scripts/Avatar/Actions/ActionSwitchAbility.cs index 89327951..caa927c8 100644 --- a/Assets/Scripts/Avatar/Actions/ActionSwitchAbility.cs +++ b/Assets/Scripts/Avatar/Actions/ActionSwitchAbility.cs @@ -5,17 +5,17 @@ using UnityEngine; // 基础的切换 state public class ActionSwitchState : ActionBase { - StateSystem m_StateSystem; + StateController m_StateController; StateBase m_TargetState; - public ActionSwitchState(StateSystem stateSystem, StateBase targetState) + public ActionSwitchState(StateController stateSystem, StateBase targetState) { - m_StateSystem = stateSystem; + m_StateController = stateSystem; m_TargetState = targetState; } public override void Execute() { - m_StateSystem.SwitchToState(m_TargetState); + m_StateController.SwitchToState(m_TargetState); } } diff --git a/Assets/Scripts/Avatar/Avatar.cs b/Assets/Scripts/Avatar/Avatar.cs index 601fafab..0ee7555f 100644 --- a/Assets/Scripts/Avatar/Avatar.cs +++ b/Assets/Scripts/Avatar/Avatar.cs @@ -16,7 +16,7 @@ public partial class Avatar : MonoBehaviour, IInteractable public Hitbox[] m_Hitbox; public Hurtbox[] m_Hurtbox; - protected StateSystem m_StateSystem = new StateSystem(); + protected StateController m_StateController = new StateController(); // 预定义的state,角色必须定义的 protected StateBase m_StateLightHurt; @@ -84,13 +84,13 @@ public partial class Avatar : MonoBehaviour, IInteractable public void OnUpdate() { - m_StateSystem.OnUpdate(); + m_StateController.OnUpdate(); } // 在物理模拟之后调用 public void OnPhysicsUpdate() { - m_StateSystem.OnPhysicsUpdate(); + m_StateController.OnPhysicsUpdate(); } public virtual Vector3 GetEffectPosition() @@ -101,13 +101,13 @@ public partial class Avatar : MonoBehaviour, IInteractable // 获得当前击打如果有的话 public Hit GetHit() { - return m_StateSystem.GetHit(); + return m_StateController.GetHit(); } public virtual void OnHit(HitInfo hitInfo) { //Debug.Log("Hit"); - m_StateSystem.OnHit(hitInfo); + m_StateController.OnHit(hitInfo); } public virtual void OnHurt(HurtInfo hurtInfo) @@ -116,7 +116,7 @@ public partial class Avatar : MonoBehaviour, IInteractable HitDefination hitDef = hurtInfo.hitDef; if (hitDef != null) ApplyHit(hitDef); - m_StateSystem.OnHurt(hurtInfo); + m_StateController.OnHurt(hurtInfo); } diff --git a/Assets/Scripts/Avatar/Avatar_Hurt.cs b/Assets/Scripts/Avatar/Avatar_Hurt.cs index f82ffbb6..eebc9a78 100644 --- a/Assets/Scripts/Avatar/Avatar_Hurt.cs +++ b/Assets/Scripts/Avatar/Avatar_Hurt.cs @@ -14,13 +14,13 @@ public partial class Avatar : MonoBehaviour, IInteractable // 切换到受击状态 switch(hit.type) { - case HitType.Light: m_StateSystem.SwitchToState(m_StateLightHurt); break; - case HitType.Midium: m_StateSystem.SwitchToState(m_StateMidiumHurt); break; - case HitType.Heavy: m_StateSystem.SwitchToState(m_StateHeavyHurt); break; - case HitType.Ground: m_StateSystem.SwitchToState(m_StateGroundHurt); break; - case HitType.Air: m_StateSystem.SwitchToState(m_StateAirHurt); break; + case HitType.Light: m_StateController.SwitchToState(m_StateLightHurt); break; + case HitType.Midium: m_StateController.SwitchToState(m_StateMidiumHurt); break; + case HitType.Heavy: m_StateController.SwitchToState(m_StateHeavyHurt); break; + case HitType.Ground: m_StateController.SwitchToState(m_StateGroundHurt); break; + case HitType.Air: m_StateController.SwitchToState(m_StateAirHurt); break; default: - m_StateSystem.SwitchToState(m_StateLightHurt); + m_StateController.SwitchToState(m_StateLightHurt); break; } diff --git a/Assets/Scripts/Avatar/StateSystem.cs b/Assets/Scripts/Avatar/StateSystem.cs index 42e35445..12ba6fe4 100644 --- a/Assets/Scripts/Avatar/StateSystem.cs +++ b/Assets/Scripts/Avatar/StateSystem.cs @@ -5,7 +5,7 @@ using UnityEngine; /// /// 每个角色拥有一个state system /// -public class StateSystem +public class StateController { /// /// 当前执行的state @@ -24,7 +24,7 @@ public class StateSystem private UberState m_UberState; - public StateSystem() + public StateController() { } -- cgit v1.1-26-g67d0