diff options
author | chai <chaifix@163.com> | 2020-11-16 14:38:55 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2020-11-16 14:38:55 +0800 |
commit | ac2b469bd76d7d91d10894184cbddad0796ce7bc (patch) | |
tree | cd17f7c3820d1ecd8dd5919292784a819d9c925e /Assets/Scripts | |
parent | 6a9c951e2ccbf768c87ed4226565a7117c8e2747 (diff) |
*statecontroller
Diffstat (limited to 'Assets/Scripts')
-rw-r--r-- | Assets/Scripts/Avatar/Actions/ActionJump.cs | 2 | ||||
-rw-r--r-- | Assets/Scripts/Avatar/Actions/ActionJumpForward.cs | 2 | ||||
-rw-r--r-- | Assets/Scripts/Avatar/Actions/ActionSwitchAbility.cs | 8 | ||||
-rw-r--r-- | Assets/Scripts/Avatar/Avatar.cs | 12 | ||||
-rw-r--r-- | Assets/Scripts/Avatar/Avatar_Hurt.cs | 12 | ||||
-rw-r--r-- | Assets/Scripts/Avatar/StateSystem.cs | 4 | ||||
-rw-r--r-- | Assets/Scripts/Test/ArmorSoldierScript_States.cs | 4 | ||||
-rw-r--r-- | Assets/Scripts/Test/SaionjiScript.cs | 8 | ||||
-rw-r--r-- | Assets/Scripts/Test/SaionjiScript_States.cs | 46 | ||||
-rw-r--r-- | Assets/Scripts/Test/SaionjiUberAbility.cs | 6 |
10 files changed, 52 insertions, 52 deletions
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; /// <summary> /// 每个角色拥有一个state system /// </summary> -public class StateSystem +public class StateController { /// <summary> /// 当前执行的state @@ -24,7 +24,7 @@ public class StateSystem private UberState m_UberState; - public StateSystem() + public StateController() { } diff --git a/Assets/Scripts/Test/ArmorSoldierScript_States.cs b/Assets/Scripts/Test/ArmorSoldierScript_States.cs index 07a4ce74..04532dd2 100644 --- a/Assets/Scripts/Test/ArmorSoldierScript_States.cs +++ b/Assets/Scripts/Test/ArmorSoldierScript_States.cs @@ -33,7 +33,7 @@ public partial class ArmorSoldierScript : Avatar, IInteractable //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // actions //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - ActionSwitchState switchToIdle = new ActionSwitchState(m_StateSystem, idle); + ActionSwitchState switchToIdle = new ActionSwitchState(m_StateController, idle); Trigger trigger = null;
@@ -52,7 +52,7 @@ public partial class ArmorSoldierScript : Avatar, IInteractable trigger = new Trigger(And(airAtEnd, Not(condInAir)), switchToIdle); airHurt.AddTrigger(trigger); - m_StateSystem.ForceStart(idle); + m_StateController.ForceStart(idle); } }
\ No newline at end of file diff --git a/Assets/Scripts/Test/SaionjiScript.cs b/Assets/Scripts/Test/SaionjiScript.cs index 4e3bf23f..ae8ee6ff 100644 --- a/Assets/Scripts/Test/SaionjiScript.cs +++ b/Assets/Scripts/Test/SaionjiScript.cs @@ -24,7 +24,7 @@ public partial class SaionjiScript : Avatar [SerializeField]
private Weapon m_Weapon;
- public bool EnableStateSystem;
+ public bool EnableStateController;
public EffectHandler[] Effects;
@@ -45,14 +45,14 @@ public partial class SaionjiScript : Avatar GetAnimHash();
- if (EnableStateSystem)
+ if (EnableStateController)
SetupStates();
}
//private void Update()
//{
- // //if (EnableStateSystem)
- // // m_StateSystem.OnUpdate();
+ // //if (EnableStateController)
+ // // m_StateController.OnUpdate();
//}
// 更新顺序:
diff --git a/Assets/Scripts/Test/SaionjiScript_States.cs b/Assets/Scripts/Test/SaionjiScript_States.cs index 0176b976..0c733cd6 100644 --- a/Assets/Scripts/Test/SaionjiScript_States.cs +++ b/Assets/Scripts/Test/SaionjiScript_States.cs @@ -90,28 +90,28 @@ public partial class SaionjiScript : Avatar ActionTowardLeft towardLeft = new ActionTowardLeft(this.transform); ActionTowardRight towardRight = new ActionTowardRight(this.transform); - ActionJump toJump = new ActionJump(m_StateSystem, jump); - ActionJumpForward toJumpForward = new ActionJumpForward(m_StateSystem, jump); - - ActionSwitchState switchToMove = new ActionSwitchState(m_StateSystem, move); - ActionSwitchState switchToIdle = new ActionSwitchState(m_StateSystem, idle); - ActionSwitchState switchToAttk1 = new ActionSwitchState(m_StateSystem, attk1); - ActionSwitchState switchToAttk2 = new ActionSwitchState(m_StateSystem, attk2); - ActionSwitchState switchToAttk3 = new ActionSwitchState(m_StateSystem, attk3); - ActionSwitchState switchToAttk4 = new ActionSwitchState(m_StateSystem, attk4); - ActionSwitchState switchToAttk5 = new ActionSwitchState(m_StateSystem, attk5); - ActionSwitchState switchToAttkRush = new ActionSwitchState(m_StateSystem, attkRush); - ActionSwitchState switchToSideKick = new ActionSwitchState(m_StateSystem, sideKick); - ActionSwitchState switchToSideKickRush = new ActionSwitchState(m_StateSystem, sideKickRush); - ActionSwitchState switchToDash = new ActionSwitchState(m_StateSystem, dash); - ActionSwitchState switchToSuperKick = new ActionSwitchState(m_StateSystem, superKick); - ActionSwitchState switchToGun1 = new ActionSwitchState(m_StateSystem, gun1); - ActionSwitchState switchToGun2 = new ActionSwitchState(m_StateSystem, gun2); - ActionSwitchState switchToGun3 = new ActionSwitchState(m_StateSystem, gun3); - ActionSwitchState switchToGun4 = new ActionSwitchState(m_StateSystem, gun4); - - ActionSwitchState switchToAirDash = new ActionSwitchState(m_StateSystem, airDash); - ActionSwitchState switchToAirAttk1 = new ActionSwitchState(m_StateSystem, airAttk1); + ActionJump toJump = new ActionJump(m_StateController, jump); + ActionJumpForward toJumpForward = new ActionJumpForward(m_StateController, jump); + + ActionSwitchState switchToMove = new ActionSwitchState(m_StateController, move); + ActionSwitchState switchToIdle = new ActionSwitchState(m_StateController, idle); + ActionSwitchState switchToAttk1 = new ActionSwitchState(m_StateController, attk1); + ActionSwitchState switchToAttk2 = new ActionSwitchState(m_StateController, attk2); + ActionSwitchState switchToAttk3 = new ActionSwitchState(m_StateController, attk3); + ActionSwitchState switchToAttk4 = new ActionSwitchState(m_StateController, attk4); + ActionSwitchState switchToAttk5 = new ActionSwitchState(m_StateController, attk5); + ActionSwitchState switchToAttkRush = new ActionSwitchState(m_StateController, attkRush); + ActionSwitchState switchToSideKick = new ActionSwitchState(m_StateController, sideKick); + ActionSwitchState switchToSideKickRush = new ActionSwitchState(m_StateController, sideKickRush); + ActionSwitchState switchToDash = new ActionSwitchState(m_StateController, dash); + ActionSwitchState switchToSuperKick = new ActionSwitchState(m_StateController, superKick); + ActionSwitchState switchToGun1 = new ActionSwitchState(m_StateController, gun1); + ActionSwitchState switchToGun2 = new ActionSwitchState(m_StateController, gun2); + ActionSwitchState switchToGun3 = new ActionSwitchState(m_StateController, gun3); + ActionSwitchState switchToGun4 = new ActionSwitchState(m_StateController, gun4); + + ActionSwitchState switchToAirDash = new ActionSwitchState(m_StateController, airDash); + ActionSwitchState switchToAirAttk1 = new ActionSwitchState(m_StateController, airAttk1); ActionWipeCmdRecord wipeCmdRecord = new ActionWipeCmdRecord(); @@ -376,7 +376,7 @@ public partial class SaionjiScript : Avatar trigger = new Trigger(new ConditionMotionAtEnd(animator, Anim_AirAttack1), new List<ActionBase> { new ActionSetVelocity(m_Body, Vector3.zero), new ActionUseGravity(m_Body), toJump}); airAttk1.AddTrigger(trigger); - m_StateSystem.ForceStart(idle); + m_StateController.ForceStart(idle); } }
\ No newline at end of file diff --git a/Assets/Scripts/Test/SaionjiUberAbility.cs b/Assets/Scripts/Test/SaionjiUberAbility.cs index aef538a2..a058b4a6 100644 --- a/Assets/Scripts/Test/SaionjiUberAbility.cs +++ b/Assets/Scripts/Test/SaionjiUberAbility.cs @@ -5,12 +5,12 @@ using UnityEngine; public class SaionjiUberState : UberState
{
Avatar m_Avatar;
- StateSystem m_StateSystem;
+ StateController m_StateController;
- public SaionjiUberState(Avatar avatar, StateSystem system)
+ public SaionjiUberState(Avatar avatar, StateController system)
{
m_Avatar = avatar;
- m_StateSystem = system;
+ m_StateController = system;
}
public override void OnUpdate()
|