From 3708d0a07ce43c3d98a0171eacfa9c370c873f96 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 2 Nov 2020 19:53:12 +0800 Subject: =?UTF-8?q?*=E5=8F=97=E5=87=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Test/ArmorSoldierScript.cs | 28 +++++++++-------- Assets/Scripts/Test/SaionjiScript.cs | 14 +++++---- Assets/Scripts/Test/SaionjiScript_Ability.cs | 45 +++++++++++++++------------- 3 files changed, 48 insertions(+), 39 deletions(-) (limited to 'Assets/Scripts/Test') diff --git a/Assets/Scripts/Test/ArmorSoldierScript.cs b/Assets/Scripts/Test/ArmorSoldierScript.cs index e4b051e1..924d7874 100644 --- a/Assets/Scripts/Test/ArmorSoldierScript.cs +++ b/Assets/Scripts/Test/ArmorSoldierScript.cs @@ -2,21 +2,17 @@ using System.Collections.Generic; using UnityEngine; -public class ArmorSoldierScript : MonoBehaviour +public class ArmorSoldierScript : Avatar { - // Start is called before the first frame update - void Start() - { - - } - - // Update is called once per frame - void Update() - { - - } + int Anim_HurtFront; - private void OnAnimatorMove() + private void Start() + { + base.Init(); + Anim_HurtFront = Animator.StringToHash("Hurt_Front"); + } + + private void OnAnimatorMove() { Animator animator = GetComponent(); @@ -34,4 +30,10 @@ public class ArmorSoldierScript : MonoBehaviour } } + public void Hurt() + { + Animator animator = GetComponent(); + animator.CrossFade(Anim_HurtFront, 0); + } + } diff --git a/Assets/Scripts/Test/SaionjiScript.cs b/Assets/Scripts/Test/SaionjiScript.cs index 10f2e9e3..90e4a7e0 100644 --- a/Assets/Scripts/Test/SaionjiScript.cs +++ b/Assets/Scripts/Test/SaionjiScript.cs @@ -21,6 +21,8 @@ public partial class SaionjiScript : Avatar // Start is called before the first frame update void Start() { + base.Init(); + animator = GetComponent(); //animator.speed = 0; PhysicsWorld.Instance.AddAnimator(animator); @@ -35,11 +37,11 @@ public partial class SaionjiScript : Avatar SetupAbilities(); } - private void Update() - { - //if (EnableAbilitySystem) - // m_AbilitySystem.OnUpdate(); - } + //private void Update() + //{ + // //if (EnableAbilitySystem) + // // m_AbilitySystem.OnUpdate(); + //} // 更新顺序: // internal animator update -> OnAnimatorMove() -> physics @@ -57,7 +59,7 @@ public partial class SaionjiScript : Avatar if(stateInfo.IsTag("IgnoreRootMotion")) { // ignore root motion - Debug.Log("ignore root motion "); + //Debug.Log("ignore root motion "); } else { diff --git a/Assets/Scripts/Test/SaionjiScript_Ability.cs b/Assets/Scripts/Test/SaionjiScript_Ability.cs index 8934b5da..d8233f56 100644 --- a/Assets/Scripts/Test/SaionjiScript_Ability.cs +++ b/Assets/Scripts/Test/SaionjiScript_Ability.cs @@ -4,10 +4,6 @@ using UnityEngine; public partial class SaionjiScript : Avatar { - /// - /// ability system - /// - AbilitySystem m_AbilitySystem = new AbilitySystem(); ConditionBase Not(ConditionBase cond) { @@ -19,7 +15,6 @@ public partial class SaionjiScript : Avatar return new ConditionAnd(c1, c2); } - ConditionBase Ands(params ConditionBase[] cond) { List conditions = new List(); @@ -71,13 +66,21 @@ public partial class SaionjiScript : Avatar AttackAbilityConfig config; - //招式会绑定一个motion + //招式会绑定一个motion + HitDefination hitDef = new HitDefination + { + }; AttackAbility attk1 = new AttackAbility(animator, Anim_LightAttack1, m_Body); - AttackAbility attk2 = new AttackAbility(animator, Anim_LightAttack2, m_Body); - AttackAbility attk3 = new AttackAbility(animator, Anim_LightAttack3, m_Body); - AttackAbility attk4 = new AttackAbility(animator, Anim_LightAttack4, m_Body); - AttackAbility attk5 = new AttackAbility(animator, Anim_LightAttack5, m_Body); - AttackAbility attkRush = new AttackAbility(animator, Anim_LightAttackRush, m_Body); + attk1.AddHitDefination(hitDef); + AttackAbility attk2 = new AttackAbility(animator, Anim_LightAttack2, m_Body); + attk2.AddHitDefination(hitDef); + AttackAbility attk3 = new AttackAbility(animator, Anim_LightAttack3, m_Body); + attk3.AddHitDefination(hitDef); + AttackAbility attk4 = new AttackAbility(animator, Anim_LightAttack4, m_Body); + attk4.AddHitDefination(hitDef); + AttackAbility attk5 = new AttackAbility(animator, Anim_LightAttack5, m_Body); + attk5.AddHitDefination(hitDef); + AttackAbility attkRush = new AttackAbility(animator, Anim_LightAttackRush, m_Body); config = new AttackAbilityConfig() { animator = this.animator, @@ -164,7 +167,7 @@ public partial class SaionjiScript : Avatar //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // idle ability - trigger = new Trigger(condUpCmd, toJump) ; + trigger = new Trigger(condTriangleCmd, toJump) ; idle.AddTrigger(trigger); trigger = new Trigger(And(condTowardRight, condDRC), new List { wipeCmdRecord, switchToSuperKick }); idle.AddTrigger(trigger); @@ -187,10 +190,12 @@ public partial class SaionjiScript : Avatar idle.AddTrigger(triggerTurnRight); idle.AddTrigger(triggerTurnLeft); - // move ability - trigger = new Trigger(Or(Ands(condRightButtonHold, condTowardRight, condUpCmd), Ands(condLeftButtonHold, condTowardLeft, condUpCmd)), toJumpForward); - move.AddTrigger(trigger); - trigger = new Trigger(And(condTowardRight, And(condRightCmd, condRight2Cmd)), new List { wipeCmdRecord, switchToDash, }); + // move ability + //trigger = new Trigger(Or(Ands(condRightButtonHold, condTowardRight, condTriangleCmd), Ands(condLeftButtonHold, condTowardLeft, condTriangleCmd)), toJumpForward); + //move.AddTrigger(trigger); + trigger = new Trigger(condTriangleCmd, toJump); + move.AddTrigger(trigger); + trigger = new Trigger(And(condTowardRight, And(condRightCmd, condRight2Cmd)), new List { wipeCmdRecord, switchToDash, }); move.AddTrigger(trigger); trigger = new Trigger(And(condTowardLeft, And(condLeftCmd, condLeft2Cmd)), new List { wipeCmdRecord, switchToDash }); move.AddTrigger(trigger); @@ -217,8 +222,8 @@ public partial class SaionjiScript : Avatar jump.AddTrigger(trigger); trigger = new Trigger(And(condLeftButtonHold, condCheckJump), new List { towardLeft, new ActionSetVelocityX(m_Body,-4) }, TriggerOnlyOnce.Off, TriggerSwallow.Off); jump.AddTrigger(trigger); - trigger = new Trigger(Ands(condCheckJump, Not(condRightButtonHold), Not(condLeftButtonHold)), new ActionSetVelocityX(m_Body, 0), TriggerOnlyOnce.Off, TriggerSwallow.Off); - jump.AddTrigger(trigger); + //trigger = new Trigger(Ands(condCheckJump, Not(condRightButtonHold), Not(condLeftButtonHold)), new ActionSetVelocityX(m_Body, 0), TriggerOnlyOnce.Off, TriggerSwallow.Off); + //jump.AddTrigger(trigger); trigger = new Trigger(condJumpOnGround, new ActionSetVelocity(m_Body, Vector3.zero), TriggerOnlyOnce.On, TriggerSwallow.Off); jump.AddTrigger(trigger); trigger = new Trigger(Ands(new ConditionJumpDone(jump, 0.4f), condJumpOnGround, Or(condRightButtonHold, condLeftButtonHold)), switchToMove); @@ -244,8 +249,8 @@ public partial class SaionjiScript : Avatar attk1.AddTrigger(trigger); attk1.AddTrigger(triggerTurnRight); attk1.AddTrigger(triggerTurnLeft); - trigger = new Trigger(condIsHit, new ActionLog("hit!!!")); - attk1.AddLateTrigger(trigger); + //trigger = new Trigger(condIsHit, new ActionLog("hit!!!")); + //attk1.AddLateTrigger(trigger); //ConditionMotionRange condAttkRushGhostRange = new ConditionMotionRange(animator, 0f, 0.8f); //trigger = new Trigger(condAttkRushGhostRange, enableGhost, false); -- cgit v1.1-26-g67d0