blob: eb69a5654e190a14833551863b8a24ea3b4379c3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;
}
}
|