using System.Collections.Generic; using System.Linq; using UnityEngine; public class TeamPlayerStat : MonoBehaviour //goes onto each bot and controls the behaivor of the team player stat { public int radius; private int modifiedRadius; public Light teamPlayerLight; private List<GameObject> botsInRange = new List<GameObject>(); private void Awake() { teamPlayerLight.enabled = false; gameObject.SetActive(false); } public void EnableStat(int tpStat) { gameObject.SetActive(true); modifiedRadius = radius + tpStat; GetComponent<SphereCollider>().radius = modifiedRadius; } public void DisableStat() { teamPlayerLight.enabled = false; gameObject.SetActive(false); } private void OnTriggerEnter(Collider other) { if (other.gameObject.tag == "Target" && other.gameObject.GetComponent<BotStats>()) { other.gameObject.GetComponent<BotStats>().GiveTeamPlayerBuff(); } } private void OnTriggerStay(Collider other) { if (other.gameObject.tag == "Target" && other.gameObject.GetComponent<BotStats>()) { botsInRange.Add(other.gameObject); botsInRange = botsInRange.Distinct().ToList(); other.gameObject.GetComponent<BotStats>().tpStatObject.teamPlayerLight.enabled = true; } } private void OnTriggerExit(Collider other) { if (other.gameObject.tag == "Target" && other.gameObject.GetComponent<BotStats>()) { other.gameObject.GetComponent<BotStats>().RemoveTeamPlayerBuff(); other.gameObject.GetComponent<BotStats>().tpStatObject.teamPlayerLight.enabled = false; botsInRange.Remove(other.gameObject); } } }