From a5c191cf74238084d9bd9f805b4b6755f70d956d Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 1 Sep 2021 08:30:42 +0800 Subject: =?UTF-8?q?*=E6=94=B9=E5=8F=98=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Unit/Component/PCAnimation.cs | 217 --------------------------- 1 file changed, 217 deletions(-) delete mode 100644 Assets/Scripts/Unit/Component/PCAnimation.cs (limited to 'Assets/Scripts/Unit/Component/PCAnimation.cs') diff --git a/Assets/Scripts/Unit/Component/PCAnimation.cs b/Assets/Scripts/Unit/Component/PCAnimation.cs deleted file mode 100644 index 9c2a77ec..00000000 --- a/Assets/Scripts/Unit/Component/PCAnimation.cs +++ /dev/null @@ -1,217 +0,0 @@ -#define ANIM_CROSS_FADE -using System; -using System.Collections; -using System.Collections.Generic; -using UnityEngine; - -public class PCAnimation : UnitAnimation -{ - public enum ELayer - { - Basic = 0, - Attack, - SwordAttack, - GunAttack, - UpperBody, - LowerBody, - Count, - } - - - // 动作名,和animator里的state对应 - public enum EAnimState - { - // layer 0 - Idle = 0, - Move, - Jump, - Hit, - Attack, - Rise, - Stinger, - Turn, - Landing, - - AirAttack0, - AirAttack1, - AirAttack2, - AirAttack3, - - Attack0, - Attack1, - Attack2, - Attack3, - } - -#if !ANIM_CROSS_FADE - // 切换动画 - public enum ETrigger - { - ToIdle, - ToMove, - ToJump, - ToAttack, - ToAirAttack, - ToLanding, - } -#endif - - private UnitActionData m_ActionData; - - public bool applyRootMotion { get; set; }// 动态设置root motion - public bool applyRootCurve { get; set; } // 程序生成的root motion - - public override void Initialize() - { - base.Initialize(); - - m_Animator = this.m_Owner.unitObj.GetComponent(); - - m_Animator.speed = 0; - - m_LayerInfo = new AnimatorLayerInfo[2]; - m_LayerInfo[0] = new AnimatorLayerInfo(this, m_Animator, (int)ELayer.Basic); - //m_LayerInfo[1] = new AnimatorLayerInfo(this, m_Animator, ELayer.Attack); - - if (m_Animator == null) - { - LogHelper.LogError("没有挂Animator组件"); - } - - applyRootMotion = true; - } - - public override void OnUpdate() - { - base.OnUpdate(); - - UpdateLayer(); - UpdateAnimation(); - - if (applyRootMotion) - UpdateRootMotion(); - if (applyRootCurve) - UpdateRootCurve(); - } - - void UpdateLayer() - { - m_LayerInfo[0].OnUpdate(); - return; - for (int i = 0; i < m_LayerInfo.Length; ++i) - { - m_LayerInfo[i].OnUpdate(); - } - } - - void UpdateAnimation() - { - m_Animator.speed = 1; - m_Animator.Update(Time.deltaTime); - m_Animator.speed = 0; - } - - void UpdateRootMotion() - { - m_Owner.unitRootMotion.UpdateRootMotion(); - } - - void UpdateRootCurve() - { - } - - public void AnimIdle() - { -#if ANIM_CROSS_FADE - m_Animator.CrossFade("Idle", 0.2f, 0); -#else - ResetAllTriggers(); - m_Animator.SetTrigger(ETrigger.ToIdle.ToString()); -#endif - } - - public void AnimMove() - { -#if ANIM_CROSS_FADE - m_Animator.CrossFade("Move", 0.01f, 0); -#else - ResetAllTriggers(); - m_Animator.SetTrigger(ETrigger.ToMove.ToString()); -#endif - } - - public void AnimJump() - { -#if ANIM_CROSS_FADE - m_Animator.CrossFade("Jump", 0.01f); -#else - ResetAllTriggers(); - SetTrigger(ETrigger.ToJump); -#endif - } - - public void AnimAirAttack(int id) - { - m_Owner.unitCollider.OnAnimationChange(); -#if ANIM_CROSS_FADE - m_Animator.CrossFade("AirAttack" + id, 0.05f); -#else - ResetAllTriggers(); - SetTrigger(ETrigger.ToAirAttack); -#endif - } - - public void AnimAttack(int id) - { - m_Owner.unitCollider.OnAnimationChange(); - m_Animator.CrossFade("Attack" + id, 0.05f); - } - - public void AnimAirDash() - { - if (layers[0].stateInfo.IsName("AirDash")) - { - m_Animator.Play("AirDash", 0, 0); - } - else - { - m_Animator.CrossFade("AirDash", 0.05f); - } - } - - public void AnimLanding() - { -#if ANIM_CROSS_FADE - m_Animator.CrossFade("Landing", 0.05f); -#else - ResetAllTriggers(); - SetTrigger(ETrigger.ToLanding); -#endif - } - - public void AnimLandingGround() - { -#if ANIM_CROSS_FADE - m_Animator.CrossFade("LandingGround", 0.00f); -#else - ResetAllTriggers(); - SetTrigger(ETrigger.ToLanding); -#endif - } - -#if !ANIM_CROSS_FADE - void ResetAllTriggers() - { - var values = Enum.GetValues(typeof(ETrigger)); - foreach (var e in values) - { - m_Animator.ResetTrigger(e.ToString()); - } - } -#endif - - private void Play(string animState, float fade = 0.1f, float offset = 0f, int layer = 0) - { - m_Animator.CrossFade(animState, fade, layer, offset); - } -} -- cgit v1.1-26-g67d0