From 766cdff5ffa72b65d7f106658d1603f47739b2ba Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Fri, 27 Oct 2023 11:05:14 +0800 Subject: + init --- GameCode/EmpowerStopBlockObjectFollow.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 GameCode/EmpowerStopBlockObjectFollow.cs (limited to 'GameCode/EmpowerStopBlockObjectFollow.cs') diff --git a/GameCode/EmpowerStopBlockObjectFollow.cs b/GameCode/EmpowerStopBlockObjectFollow.cs new file mode 100644 index 0000000..dd64869 --- /dev/null +++ b/GameCode/EmpowerStopBlockObjectFollow.cs @@ -0,0 +1,25 @@ +using System; +using UnityEngine; + +public class EmpowerStopBlockObjectFollow : MonoBehaviour +{ + private void Start() + { + Block componentInParent = GetComponentInParent(); + componentInParent.BlockAction = (Action)Delegate.Combine(componentInParent.BlockAction, new Action(Block)); + } + + private void OnDestroy() + { + Block componentInParent = GetComponentInParent(); + componentInParent.BlockAction = (Action)Delegate.Remove(componentInParent.BlockAction, new Action(Block)); + } + + private void Block(BlockTrigger.BlockTriggerType triggerTyp) + { + if (triggerTyp == BlockTrigger.BlockTriggerType.Empower && (bool)GetComponent()) + { + GetComponent().mostRecentlySpawnedObject.GetComponent().enabled = false; + } + } +} -- cgit v1.1-26-g67d0