diff options
author | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
---|---|---|
committer | chai <215380520@qq.com> | 2023-10-27 11:05:14 +0800 |
commit | 766cdff5ffa72b65d7f106658d1603f47739b2ba (patch) | |
tree | 34d7799a94dfa9be182825577583c0fa6dc935f7 /GameCode/KillBox.cs |
+ init
Diffstat (limited to 'GameCode/KillBox.cs')
-rw-r--r-- | GameCode/KillBox.cs | 40 |
1 files changed, 40 insertions, 0 deletions
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<BoxCollider2D>(); + } + + 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; + } +} |