From f325841eff10ae492ce6c634d4b07cf058a068c6 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 16 Nov 2020 08:30:54 +0800 Subject: *state system --- Assets/Scripts/Test/ArmorSoldierScript_States.cs | 53 ++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Assets/Scripts/Test/ArmorSoldierScript_States.cs (limited to 'Assets/Scripts/Test/ArmorSoldierScript_States.cs') diff --git a/Assets/Scripts/Test/ArmorSoldierScript_States.cs b/Assets/Scripts/Test/ArmorSoldierScript_States.cs new file mode 100644 index 00000000..67eca581 --- /dev/null +++ b/Assets/Scripts/Test/ArmorSoldierScript_States.cs @@ -0,0 +1,53 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public partial class ArmorSoldierScript : Avatar, IInteractable +{ + + void SetupStates() + { + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // states + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + IdleState idle = new IdleState(m_Animator, Anim_Idle); + + HurtState lightHurt = new HurtState(m_Animator, Anim_LightHurt); + HurtState midiumHurt = new HurtState(m_Animator, Anim_MidiumHurt); + HurtState heavyHurt = new HurtState(m_Animator, Anim_HeavyHurt); + HurtState groundHurt = new HurtState(m_Animator, Anim_GroundHurt); + HurtState airHurt = new HurtState(m_Animator, Anim_AirHurt); + m_StateLightHurt = lightHurt; + m_StateMidiumHurt = midiumHurt; + m_StateHeavyHurt = heavyHurt; + m_StateGroundHurt = groundHurt; + m_StateAirHurt = airHurt; + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // conditions + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ConditionInAir condInAir = new ConditionInAir(m_BodyCollider); + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // actions + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + ActionSwitchState switchToIdle = new ActionSwitchState(m_StateSystem, idle); + + Trigger trigger = null; + + + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + // state setup + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + + // air hurt + ConditionMotionAtEnd airAtEnd = new ConditionMotionAtEnd(m_Animator, Anim_AirHurt); + trigger = new Trigger(And(airAtEnd, Not(condInAir)), switchToIdle); + airHurt.AddTrigger(trigger); + + m_StateSystem.ForceStart(idle); + } + +} \ No newline at end of file -- cgit v1.1-26-g67d0