// confirm TileEventHandler operations public void OperationConfirmed() { _towerBuildPanel.DisAppear(); if (_upgradeCase) { if (!EnoughGoldToUpgrade()) // not enough gold to upgrade { _notificationPanel.DisAppear(); _notificationPanel.SetNotificationType("NotEnoughMoney"); _notificationPanel.Appear(); _buildCheckPanel.DisAppear(); } else { _tileEventHandler.OperationConfirmed(); } } else { _tileEventHandler.OperationConfirmed(); _buildCheckPanel.DisAppear(); _towerInfoPanel.DisAppear(); _towerOperationPanel.DisAppear(); _notificationPanel.DisAppear(); _gameBoard.ClearHighlightTiles(); } }
void OnMouseDown() { //Debug.Log("CSH: Clicked useless tile."); _buildCheckPanel.DisAppear(); _towerInfoPanel.DisAppear(); _notificationPanel.DisAppear(); _towerBuildPanel.DisAppear(); _towerOperationPanel.DisAppear(); _gameBoard.ClearHighlightTiles(); }
public void OperationDenied() { if (null == _gameBoard) { _gameBoard = GameManager.Instance.CurrentLevelManager.GameBoardSystem; _towerBuildPanel = TowerBuildPanel.Instance; _buildCheckPanel = BuildCheckPanel.Instance; _towerInfoPanel = TowerInfoPanel.Instance; _towerOperationPanel = TowerOperationPanel.Instance; _notificationPanel = NotificationPanel.Instance; } _towerBuildPanel.DisAppear(); _buildCheckPanel.DisAppear(); _towerInfoPanel.DisAppear(); _towerOperationPanel.DisAppear(); _notificationPanel.DisAppear(); _gameBoard.ClearHighlightTiles(); }
void Update() { // disappear all panels when fousing to enter a batte during building OR operation tower phase if (!_clearBeforeBattle && _levelManager.CurrentGamePhase() == GameBoard.GamePhase.BattlePhase) { _towerBuildPanel.DisAppear(); _towerOperationPanel.DisAppear(); _towerInfoPanel.DisAppear(); _buildCheckPanel.DisAppear(); _notificationPanel.DisAppear(); _gameBoard.ClearHighlightTiles(); _clearBeforeBattle = true; return; } // make the above code work for the entire game if (_levelManager.CurrentGamePhase() == GameBoard.GamePhase.BuildingPhase) { _clearBeforeBattle = false; } if (_confirmed) { switch (TowerOperation) { case Operation.Nop: break; case Operation.TankTower: // ask tower controller to build(check avaliable gold) _towerGameObject = _towerController.BuildTower(this, GridX, GridY, _towerIndex); if (null == _towerGameObject) { //Debug.Log("TEH: not enough money or blocking the path"); } else { _towerExist = true; _currentTowerType = 0; _tankTowerPtr = _towerGameObject.GetComponent <TankTower>(); // get scripts _tankTowerPtr.Setup(this); // check if it blocks the last path if (!_gameBoard.BuildTower(_tankTowerPtr)) { SellTower(true); _towerExist = false; _notificationPanel.SetNotificationType("Block"); _notificationPanel.Appear(); } else { _levelManager.UseGold(_tankTowerPtr.BuildCost); _towerController.AddTileEventHandler(this); } } break; case Operation.RangeTower: // ask tower controller to build(check avaliable gold) _towerGameObject = _towerController.BuildTower(this, GridX, GridY, _towerIndex); if (null == _towerGameObject) { //Debug.Log("TEH: not enough money or blocking the path"); } else { _towerExist = true; _currentTowerType = 1; _rangeTowerPtr = _towerGameObject.GetComponent <RangeTower>(); // get scripts _rangeTowerPtr.Setup(this); // check if it blocks the last path if (!_gameBoard.BuildTower(_rangeTowerPtr)) { SellTower(true); _towerExist = false; _notificationPanel.SetNotificationType("Block"); _notificationPanel.Appear(); } else { _levelManager.UseGold(_rangeTowerPtr.BuildCost); _towerController.AddTileEventHandler(this); } } break; case Operation.SlowTower: // ask tower controller to build(check avaliable gold) _towerGameObject = _towerController.BuildTower(this, GridX, GridY, _towerIndex); if (null == _towerGameObject) { //Debug.Log("TEH: not enough money or blocking the path"); } else { _towerExist = true; _currentTowerType = 2; _slowTowerPtr = _towerGameObject.GetComponent <SlowTower>(); // get scripts _slowTowerPtr.Setup(this); // check if it blocks the last path if (!_gameBoard.BuildTower(_slowTowerPtr)) { SellTower(true); _towerExist = false; _notificationPanel.SetNotificationType("Block"); _notificationPanel.Appear(); } else { _levelManager.UseGold(_slowTowerPtr.BuildCost); _towerController.AddTileEventHandler(this); } } break; case Operation.HealTower: // ask tower controller to build(check avaliable gold) _towerGameObject = _towerController.BuildTower(this, GridX, GridY, _towerIndex); if (null == _towerGameObject) { //Debug.Log("TEH: not enough money or blocking the path"); } else { _towerExist = true; _currentTowerType = 3; _healTowerPtr = _towerGameObject.GetComponent <HealTower>(); // get scripts _healTowerPtr.Setup(this); // check if it blocks the last path if (!_gameBoard.BuildTower(_healTowerPtr)) { SellTower(true); _towerExist = false; //_notificationPanel.DisAppear(); _notificationPanel.SetNotificationType("Block"); _notificationPanel.Appear(); } else { _levelManager.UseGold(_healTowerPtr.BuildCost); _towerController.AddTileEventHandler(this); _towerController.AddHealTileEventHandler(this); } } break; case Operation.GoldTower: // ask tower controller to build(check avaliable gold) _towerGameObject = _towerController.BuildTower(this, GridX, GridY, _towerIndex); if (null == _towerGameObject) { //Debug.Log("TEH: not enough money or blocking the path"); } else { _towerExist = true; _currentTowerType = 4; _goldTowerPtr = _towerGameObject.GetComponent <GoldTower>(); // get scripts _goldTowerPtr.Setup(this); // check if it blocks the last path if (!_gameBoard.BuildTower(_goldTowerPtr)) { SellTower(true); _towerExist = false; _notificationPanel.SetNotificationType("Block"); _notificationPanel.Appear(); } else { _levelManager.UseGold(_goldTowerPtr.BuildCost); _towerController.AddTileEventHandler(this); } } break; case Operation.Upgrade: if (0 == _currentTowerType) { _tankTowerPtr.Upgrade(); } if (1 == _currentTowerType) { _rangeTowerPtr.Upgrade(); } if (2 == _currentTowerType) { _slowTowerPtr.Upgrade(); } if (3 == _currentTowerType) { _healTowerPtr.Upgrade(); } if (4 == _currentTowerType) { _goldTowerPtr.Upgrade(); } break; case Operation.Repair: if (0 == _currentTowerType) { if (_tankTowerPtr.RepairCost > _levelManager.GetGold()) { _notificationPanel.SetNotificationType("NotEnoughMoney"); _notificationPanel.Appear(); break; } _tankTowerPtr.Repair(); } if (1 == _currentTowerType) { if (_rangeTowerPtr.RepairCost > _levelManager.GetGold()) { _notificationPanel.SetNotificationType("NotEnoughMoney"); _notificationPanel.Appear(); break; } _rangeTowerPtr.Repair(); } if (2 == _currentTowerType) { if (_slowTowerPtr.RepairCost > _levelManager.GetGold()) { _notificationPanel.SetNotificationType("NotEnoughMoney"); _notificationPanel.Appear(); break; } _slowTowerPtr.Repair(); } if (3 == _currentTowerType) { if (_healTowerPtr.RepairCost > _levelManager.GetGold()) { _notificationPanel.SetNotificationType("NotEnoughMoney"); _notificationPanel.Appear(); break; } _healTowerPtr.Repair(); } if (4 == _currentTowerType) { if (_goldTowerPtr.RepairCost > _levelManager.GetGold()) { _notificationPanel.SetNotificationType("NotEnoughMoney"); _notificationPanel.Appear(); break; } _goldTowerPtr.Repair(); } break; case Operation.Sell: SellTower(false); break; } _confirmed = false; } }