summaryrefslogtreecommitdiff
path: root/GameCode/UnitAttackAnimator.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2023-11-02 11:51:31 +0800
committerchai <215380520@qq.com>2023-11-02 11:51:31 +0800
commit7f493f682503f5186308de7b8f74b5b49233cfe4 (patch)
tree8a91e2056bc79788ee4735dce88b8d516ba12beb /GameCode/UnitAttackAnimator.cs
+init
Diffstat (limited to 'GameCode/UnitAttackAnimator.cs')
-rw-r--r--GameCode/UnitAttackAnimator.cs31
1 files changed, 31 insertions, 0 deletions
diff --git a/GameCode/UnitAttackAnimator.cs b/GameCode/UnitAttackAnimator.cs
new file mode 100644
index 0000000..01b95c2
--- /dev/null
+++ b/GameCode/UnitAttackAnimator.cs
@@ -0,0 +1,31 @@
+using UnityEngine;
+
+public class UnitAttackAnimator : MonoBehaviour
+{
+ public AutoAttack unit;
+
+ public OneShotAnimationBase attackAnimation;
+
+ public OneShotAnimationBase[] additionalAttackAnimations;
+
+ private void Start()
+ {
+ if ((bool)unit)
+ {
+ unit.onAttackTriggered.AddListener(OnAttack);
+ }
+ }
+
+ private void OnAttack()
+ {
+ if ((bool)attackAnimation)
+ {
+ attackAnimation.Trigger();
+ }
+ OneShotAnimationBase[] array = additionalAttackAnimations;
+ for (int i = 0; i < array.Length; i++)
+ {
+ array[i].Trigger();
+ }
+ }
+}