public bool Recheck() { bool result = false; Collider[] objs = Physics.OverlapSphere(this.transform.position, this.radius / 2f); foreach (Collider col in objs) { GameUnit unit = col.gameObject.GetComponentInParent <GameUnit>(); if (unit != null && !unit.Equals(this.parent) && !unit.hasAuthority && !this.enemiesInRange.Contains(unit)) { this.enemiesInRange.Add(unit); result = true; } } return(result); }
public void OnTriggerExit(Collider other) { GameUnit unit = other.GetComponent <GameUnit>(); if (unit != null) { Renderer unitRenderer = unit.GetComponent <Renderer>(); if ((!unit.hasAuthority && this.enemiesInAttackRange.Contains(unit) && !unit.Equals(this.parent)) || (!unitRenderer.enabled && this.enemiesInAttackRange.Contains(unit))) { this.enemiesInAttackRange.Remove(unit); this.exitedList.Add(unit); } } else { AIUnit AIunit = other.GetComponent <AIUnit>(); if (AIunit != null && this.otherEnemies.Contains(AIunit)) { this.otherEnemies.Remove(AIunit); } } }
public void OnTriggerEnter(Collider other) { GameUnit unit = other.GetComponent <GameUnit>(); if (unit != null) { Renderer unitRenderer = unit.GetComponent <Renderer>(); if (!unit.hasAuthority && unitRenderer.enabled && !this.enemiesInAttackRange.Contains(unit) && !unit.Equals(this.parent)) { this.enemiesInAttackRange.Add(unit); } } AIUnit AIunit = other.GetComponent <AIUnit>(); if (AIunit != null && !this.otherEnemies.Contains(AIunit)) { this.otherEnemies.Add(AIunit); } if (this.exitedList.Count > 0) { this.exitedList.Clear(); } if (this.exitedEnemies.Count > 0) { this.exitedEnemies.Clear(); } }