diff options
Diffstat (limited to 'GameCode/BounceTrigger.cs')
-rw-r--r-- | GameCode/BounceTrigger.cs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/GameCode/BounceTrigger.cs b/GameCode/BounceTrigger.cs new file mode 100644 index 0000000..8d7a1b5 --- /dev/null +++ b/GameCode/BounceTrigger.cs @@ -0,0 +1,22 @@ +using System; +using UnityEngine; + +public class BounceTrigger : MonoBehaviour +{ + private BounceEffect[] bounceEffects; + + private void Start() + { + bounceEffects = GetComponents<BounceEffect>(); + RayHitReflect componentInParent = GetComponentInParent<RayHitReflect>(); + componentInParent.reflectAction = (Action<HitInfo>)Delegate.Combine(componentInParent.reflectAction, new Action<HitInfo>(Reflect)); + } + + public void Reflect(HitInfo hit) + { + for (int i = 0; i < bounceEffects.Length; i++) + { + bounceEffects[i].DoBounce(hit); + } + } +} |