You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.2 KiB
43 lines
1.2 KiB
using System.Collections; |
|
using System.Collections.Generic; |
|
using UnityEngine; |
|
|
|
public class TriggerCtrl : MonoBehaviour { |
|
|
|
private List<GameObject> fireMenList = new List<GameObject>(); |
|
public List<GameObject> FireMenList |
|
{ |
|
get { return fireMenList; } |
|
} |
|
|
|
|
|
private void OnTriggerEnter(Collider other) |
|
{ |
|
if (other.tag == "Player" && !fireMenList.Contains(other.gameObject)) |
|
{ |
|
fireMenList.Add(other.gameObject); |
|
} |
|
if (transform.parent.GetComponent<TrappedMoveFree>()) |
|
{ |
|
transform.parent.GetComponent<TrappedMoveFree>().FireManNear = true; |
|
} |
|
Debug.Log(fireMenList.Count + " Enter: " + other.name); |
|
|
|
} |
|
|
|
private void OnTriggerExit(Collider other) |
|
{ |
|
if (other.tag == "Player" && fireMenList.Contains(other.gameObject)) |
|
{ |
|
fireMenList.Remove(other.gameObject); |
|
} |
|
if (transform.parent.GetComponent<TrappedMoveFree>()) |
|
{ |
|
if (fireMenList.Count<=0) |
|
{ |
|
transform.parent.GetComponent<TrappedMoveFree>().FireManNear = false; |
|
} |
|
} |
|
Debug.Log(fireMenList.Count + " Exit: " + other.name); |
|
} |
|
}
|
|
|