//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> // <param name="other"></param> private void OnTriggerEnter(Collider other) { // Valid unit or building if (other.CompareTag("Unit") || other.CompareTag("Building")) { // Valid worldObject check _WorldObjectInFocus = other.gameObject.GetComponent <WorldObject>(); if (_WorldObjectInFocus != null) { // This component is attached to a unit/AI object if (_UnitAttached != null) { if (_WorldObjectInFocus.Team != _UnitAttached.Team && _WorldObjectInFocus.Team != GameManager.Team.Undefined && // Enemy team? _WorldObjectInFocus._ObjectState == Abstraction.WorldObjectStates.Active && // Active in the world? _WorldObjectInFocus.CanBeTargetted == true) // Can be targetted? // Try to add to weighted list { _UnitAttached.AddPotentialTarget(_WorldObjectInFocus); } } // This component is attached to a tower object if (_TowerAttached != null) { if (_WorldObjectInFocus.Team != _TowerAttached.Team && _WorldObjectInFocus.Team != GameManager.Team.Undefined && // Enemy team? _WorldObjectInFocus._ObjectState == Abstraction.WorldObjectStates.Active && // Active in the world? _WorldObjectInFocus.CanBeTargetted == true) // Can be targetted? // Try to add to weighted list { _TowerAttached.AddPotentialTarget(_WorldObjectInFocus); } } } } }
//////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// /// </summary> /// <param name="other"></param> private void OnTriggerEnter(Collider other) { // Valid worldObject _WorldObjectInFocus = other.gameObject.GetComponent <WorldObject>(); if (_WorldObjectInFocus != null) { // This component is attached to a unit/AI object if (_UnitAttached != null) { // Enemy team? if (_WorldObjectInFocus.Team != _UnitAttached.Team && _WorldObjectInFocus.Team != GameManager.Team.Undefined) { // Not a building slot? BuildingSlot slot = _WorldObjectInFocus.GetComponent <BuildingSlot>(); if (slot == null) { // Active in the world? if (_WorldObjectInFocus._ObjectState == WorldObject.WorldObjectStates.Active) { // Try to add to weighted list _UnitAttached.AddPotentialTarget(_WorldObjectInFocus); } } } } // This component is attached to a tower object if (_TowerAttached != null) { // Enemy team? if (_WorldObjectInFocus.Team != _TowerAttached.Team && _WorldObjectInFocus.Team != GameManager.Team.Undefined) { // Not a building slot? BuildingSlot slot = _WorldObjectInFocus.GetComponent <BuildingSlot>(); if (slot == null) { // Active in the world? if (_WorldObjectInFocus._ObjectState == WorldObject.WorldObjectStates.Active) { // Try to add to weighted list _TowerAttached.AddPotentialTarget(_WorldObjectInFocus); } } } } } }