Ejemplo n.º 1
0
        public void OnButtonSpawnTower(TowerProperties tower)
        {
            if (CannotAffordTower(tower))
            {
                OnDisplayMessage?.Invoke("not enough money.");
                return;
            }

            switch (TowerPlacementState)
            {
            case TowerPlacementState.NotPlacingTower:
                TowerPlacementState = TowerPlacementState.PlacingTower;
                SpawnTower(tower);
                break;

            case TowerPlacementState.PlacingTower:
                Destroy(_currentTowerGO);
                SpawnTower(tower);
                break;

            case TowerPlacementState.CannotPlaceTower:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 2
0
 public void CancelPlacingTower()
 {
     Destroy(_currentTowerGO);
     _currentTowerGO     = null;
     _curTowerController = null;
     TowerPlacementState = TowerPlacementState.NotPlacingTower;
 }
Ejemplo n.º 3
0
 private void InitializeControllerValues()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
         return;
     }
     TowerPlacementState = TowerPlacementState.NotPlacingTower;
     _curTowerController = null;
 }
Ejemplo n.º 4
0
        private void Update()
        {
            if (IsPlacingTower)
            {
                _currentTowerGO.transform.position = InputController.TowerPlacementPosition;
            }

            if (TryPlaceTower)
            {
                OnTowerPlaced?.Invoke(_curTowerController);
                TowerPlacementState = TowerPlacementState.NotPlacingTower;
                _gameController.DecrementMoney(_curTowerController.TowerProperties.Cost);
                _curTowerController = null;
                _currentTowerGO     = null;
            }
        }
Ejemplo n.º 5
0
 private void GameOver()
 {
     CancelPlacingTower();
     TowerPlacementState = TowerPlacementState.CannotPlaceTower;
 }