public void TakeDamage(int dmg) { _health -= dmg; if (_health <= 0) { _health = 0; AudioManager.GetInstance().PlayPlayerDeathSfx(); LooseLevel(); } _displayUI.UpdateHealthUI(_health); AudioManager.GetInstance().PlayPlayerHitSfx(); }
//called from tower ui button clicked public void SellTowerOn() { Tower currTower = _nodeSelected.GetComponentInChildren <Tower>(); if (currTower != null) { _gameManager.AddToMoney((int)(currTower.GetCost() / 1.5f)); currTower.RemoveTower(); //destroy gameObject _towerToBuild = null; _nodeSelected.ClearNode(); AudioManager.GetInstance().PlayTowerSoldSfx(); } HideTowerCanvas(); }
//called from Node Script - return if build success or not public bool BuildTowerOn() { if (_towerToBuild != null) { int towerCost = _towerToBuild.GetComponent <Tower>().GetCost(); if (_gameManager.SpendMoney(towerCost)) { SpawnTower(); AudioManager.GetInstance().PlayTowerDownSfx(); return(true); } } return(false); }