private IEnumerator TrackingCoroutine() { while (_gameEnum == GameEnum.Play) { yield return(null); float _closestDistance = float.MaxValue; TowerComponent _closestTower = null; _towerList.ForEach(tower => { float _distance = tower.GetDistance(boat); if (_distance < _closestDistance) { _closestDistance = _distance; _closestTower = tower; } }); if (_closestTower != null && _closestTower != _currentClosestTower) { _trackerHandler.TriggerEvent(_closestTower); _currentClosestTower = _closestTower; } } }
private void OnTrackerChanged(object value = null) { if (value == null) { return; } TowerComponent _tower = value as TowerComponent; if (_tower.Equals(this)) { spriteRenderer.color = Color.green; } else { spriteRenderer.color = Color.white; } }