Exemplo n.º 1
0
        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;
                }
            }
        }
Exemplo n.º 2
0
        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;
            }
        }