diff options
Diffstat (limited to 'Assets/Scripts/Unit/Components')
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAfterImage.cs | 41 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta | 11 | ||||
-rw-r--r-- | Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs | 28 |
3 files changed, 70 insertions, 10 deletions
diff --git a/Assets/Scripts/Unit/Components/UnitAfterImage.cs b/Assets/Scripts/Unit/Components/UnitAfterImage.cs new file mode 100644 index 00000000..369f63c9 --- /dev/null +++ b/Assets/Scripts/Unit/Components/UnitAfterImage.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AfterImageSpawner +{ + private float m_CurTime; + + private float m_Duration; + + public void OnUpdate() + { + float dt = Time.deltaTime; + m_CurTime += dt; + + + } + +} + +[DisallowMultipleComponent] +public class UnitAfterImage : UnitComponent +{ + + private List<AfterImageSpawner> m_Spawners; + + public override void OnUpdate() + { + base.OnUpdate(); + + if(m_Spawners != null) + { + for(int i = 0; i < m_Spawners.Count; ++i) + { + m_Spawners[i].OnUpdate(); + } + } + + } + +}
\ No newline at end of file diff --git a/Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta b/Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta new file mode 100644 index 00000000..21cdf37f --- /dev/null +++ b/Assets/Scripts/Unit/Components/UnitAfterImage.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 567816c152acc834f9bd41efec9ee51c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs index 33bd4d4e..dbd4dd49 100644 --- a/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs +++ b/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs @@ -71,6 +71,8 @@ public class PCAnimation : UnitAnimation public bool applyRootMotion { get; set; }// 动态设置root motion public bool applyRootCurve { get; set; } // 程序生成的root motion + public bool updateAnimationAuto { get; private set; } // 自动更新动画 + public override void Initialize() { base.Initialize(); @@ -89,7 +91,9 @@ public class PCAnimation : UnitAnimation } applyRootMotion = true; - } + + updateAnimationAuto = true; + } public override void OnUpdate() { @@ -97,11 +101,8 @@ public class PCAnimation : UnitAnimation UpdateLayer(); UpdateAnimation(); - - if (applyRootMotion) - UpdateRootMotion(); - if (applyRootCurve) - UpdateRootCurve(); + UpdateRootMotion(); + UpdateRootCurve(); } void UpdateLayer() @@ -116,18 +117,25 @@ public class PCAnimation : UnitAnimation void UpdateAnimation() { - m_Animator.speed = 1; - m_Animator.Update(Time.deltaTime); - m_Animator.speed = 0; - } + if(updateAnimationAuto)
+ {
+ m_Animator.speed = 1;
+ m_Animator.Update(Time.deltaTime);
+ m_Animator.speed = 0; + }
+ } void UpdateRootMotion() { + if (!applyRootMotion) + return; m_Owner.unitRootMotion.UpdateRootMotion(); } void UpdateRootCurve() { + if (!applyRootCurve) + return; } public void AnimIdle() |