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/KillBox.cs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 GameCode/KillBox.cs (limited to 'GameCode/KillBox.cs') diff --git a/GameCode/KillBox.cs b/GameCode/KillBox.cs new file mode 100644 index 0000000..eb69a56 --- /dev/null +++ b/GameCode/KillBox.cs @@ -0,0 +1,40 @@ +using UnityEngine; + +public class KillBox : MonoBehaviour +{ + public bool alwaysOn; + + public float toggleTime = 0.3f; + + private float timeActivated = -10f; + + public bool readyToKill; + + private BoxCollider2D box; + + private void Start() + { + box = GetComponent(); + } + + private void Update() + { + readyToKill = timeActivated + toggleTime > Time.time; + if (!readyToKill) + { + return; + } + for (int i = 0; i < PlayerManager.instance.players.Count; i++) + { + if (box.OverlapPoint(PlayerManager.instance.players[i].transform.position)) + { + PlayerManager.instance.players[i].data.healthHandler.TakeDamage(Vector2.up * 1000f, base.transform.position); + } + } + } + + public void Activate() + { + timeActivated = Time.time; + } +} -- cgit v1.1-26-g67d0