public void BuildingUpgrade() { if (!healthScript) { healthScript = GetComponent <HealthScript>(); } if (!grabBuildingStats) { grabBuildingStats = GameObject.FindGameObjectWithTag("SellMenu").GetComponent <GrabBuildingStats>(); } Level++; Damage += Damage / 2; AttackCoolDown -= AttackCoolDown / 3; AttackRange += AttackRange / 4; healthScript.MaxHealth += healthScript.MaxHealth / 2; healthScript.HealthGenAmount += healthScript.HealthGenAmount / 2; Gold += Gold; Wood += Wood; Stone += Stone; CalculateRepairCosts(); grabBuildingStats.SellMenuStats(); }
public void CalculateRepairCosts() { if (!healthScript) { healthScript = GetComponent <HealthScript>(); } if (!grabBuildingStats) { grabBuildingStats = GameObject.FindGameObjectWithTag("SellMenu").GetComponent <GrabBuildingStats>(); } float healthGainPerWood = healthScript.MaxHealth / Wood; float healthGainPerStone = healthScript.MaxHealth / Stone; float repairHealth = healthScript.MaxHealth - healthScript.CurrentHealth; WoodRepairCost = Mathf.RoundToInt(repairHealth / healthGainPerWood); StoneRepairCost = Mathf.RoundToInt(repairHealth / healthGainPerStone); if (!healthScript.IsAlive) { Destroy(gameObject); } grabBuildingStats.UpdateRepairCostAndHealth(); }
void Start() { GrabBuildingStats = SellMenu.GetComponent <GrabBuildingStats>(); SelectedBuilding = PrefabBase; gameControllerScript = GameObject.FindGameObjectWithTag("GameController").GetComponent <GameControllerScript>(); grabPlayerStats = GameObject.FindGameObjectWithTag("PlayerStats").GetComponent <GrabPlayerStats>(); }