public void DestroyBuilding() { if (buildingSelected == null && mouseOverUI) { return; } Debug.Log("Destroy"); if (buildingSelected.tag == "House") { resource.AddWood(BuilderScript.houseCostWood / 2); resource.AddGold(BuilderScript.houseCostGold / 2); resource.RemoveMaxPop(BuilderScript.houseCostPop); resource.RemoveCurrentPop(BuilderScript.houseCostPop); resource.AddNonIdlePop(-BuilderScript.houseCostPop); resource.AddHouse(-1); Destroy(buildingSelected.transform.parent.gameObject); buildingSelected = null; } else if (buildingSelected.tag == "Farm") { Debug.Log("farm"); resource.AddWood(BuilderScript.farmCostWood / 2); resource.AddGold(BuilderScript.farmCostGold / 2); /*resource.RemoveCurrentPop(BuilderScript.farmCostPop); * resource.AddNonIdlePop(-BuilderScript.farmCostPop);*/ resource.AddFarm(-1); buildingSelected.GetComponent <FarmBehaviour>().DestroyBuilding(); buildingSelected = null; Debug.Log("Destroy farm"); } else if (buildingSelected.tag == "LumberMill") { resource.AddWood(BuilderScript.lumbMillCostWood / 2); resource.AddGold(BuilderScript.lumbMillCostGold / 2); buildingSelected.GetComponent <LumberMillBehaviour>().DestroyBuilding(); buildingSelected = null; } else if (buildingSelected.tag == "GoldMine") { resource.AddWood(BuilderScript.mineCostWood / 2); resource.AddGold(BuilderScript.mineCostGold / 2); buildingSelected.GetComponent <GoldMineBehaviour>().DestroyBuilding(); buildingSelected = null; } else if (buildingSelected.tag == "Warehouse") { resource.AddWood(BuilderScript.warehouseCostWood / 2); resource.AddGold(BuilderScript.warehouseCostGold / 2); resource.AddWareHouse(-1); resource.AddCurrentPop(BuilderScript.warehouseCostPop); resource.AddNonIdlePop(-BuilderScript.warehouseCostPop); Destroy(buildingSelected.transform.parent.gameObject); buildingSelected = null; } else if (buildingSelected.tag == "Bridge") { if (resource.wood > 100 * ResourceManager.bridgeCost) { //resource.wood -= 100 * resource.bridgeCost; resource.RemoveWood(100 * ResourceManager.bridgeCost); resource.RemoveGold(50 * ResourceManager.bridgeCost); ResourceManager.bridgeCost++; //buildingSelected.SetActive(false); buildingSelected.GetComponent <BridgeBehaviour>().RepareBridge(); } } else if (buildingSelected.tag == "Tower") { resource.AddWood(BuilderScript.towerCostWood / 2); resource.AddGold(BuilderScript.towerCostGold / 2); resource.AddTower(-1); resource.AddCurrentPop(BuilderScript.towerCostPop); resource.AddNonIdlePop(-BuilderScript.towerCostPop); buildingSelected.GetComponent <TowerBehaviour>().DestroyBuilding(); buildingSelected = null; } else if (buildingSelected.tag == "Barracks") { resource.AddWood(BuilderScript.barracksCostWood / 2); resource.AddGold(BuilderScript.barracksCostGold / 2); resource.AddBarracks(-1); resource.AddCurrentPop(BuilderScript.warehouseCostPop); resource.AddNonIdlePop(-BuilderScript.warehouseCostPop); Destroy(buildingSelected.transform.parent.gameObject); buildingSelected = null; } else if (buildingSelected.tag == "Church") { resource.AddWood(BuilderScript.churchCostWood / 2); resource.AddGold(BuilderScript.churchCostGold / 2); resource.AddChurch(-1); resource.AddCurrentPop(BuilderScript.churchCostPop); resource.AddNonIdlePop(-BuilderScript.churchCostPop); Destroy(buildingSelected.transform.parent.gameObject); buildingSelected = null; } else if (buildingSelected.tag == "FireStation") { resource.AddWood(BuilderScript.fireStationCostWood / 2); resource.AddGold(BuilderScript.fireStationCostGold / 2); resource.AddFireStation(-1); resource.AddCurrentPop(BuilderScript.fireStationCostPop); resource.AddNonIdlePop(-BuilderScript.fireStationCostPop); Destroy(buildingSelected.transform.parent.gameObject); buildingSelected = null; } else { Debug.Log("Edificio" + buildingSelected + "no se puede destruir"); } }
private void RemoveResources() { if (build.tag == "TownHall") { resource.RemoveWood(townHallCostWood); resource.RemoveGold(townHallCostGold); resource.AddTownHall(); } else if (build.tag == "Castle") { resource.RemoveWood(castleCostWood); resource.RemoveGold(castleCostWood); resource.AddCastle(); } else if (build.tag == "House") { resource.RemoveWood(houseCostWood); resource.RemoveGold(houseCostGold); resource.AddMaxPop(4); resource.AddCurrentPop(4); resource.AddHouse(); } else if (build.tag == "Farm") { resource.RemoveWood(farmCostWood); resource.AddFarm(); resource.RemoveCurrentPop(2); resource.AddNonIdlePop(2); } else if (build.tag == "LumberMill") { resource.RemoveWood(lumbMillCostWood); resource.AddLumberMill(); resource.RemoveCurrentPop(4); resource.AddNonIdlePop(4); } else if (build.tag == "GoldMine") { resource.RemoveWood(mineCostWood); resource.AddGoldMine(); resource.RemoveCurrentPop(4); resource.AddNonIdlePop(4); } else if (build.tag == "Warehouse") { resource.RemoveWood(warehouseCostWood); resource.RemoveGold(warehouseCostWood); resource.AddWareHouse(); resource.RemoveCurrentPop(8); resource.AddNonIdlePop(8); warehouseCostGold += 100; warehouseCostWood += 150; } else if (build.tag == "Tower") { resource.RemoveWood(towerCostWood); resource.RemoveGold(towerCostGold); resource.AddTower(); resource.RemoveCurrentPop(2); resource.AddNonIdlePop(2); } else if (build.tag == "Church") { resource.RemoveWood(churchCostWood); resource.RemoveGold(churchCostGold); resource.AddChurch(); resource.RemoveCurrentPop(4); resource.AddNonIdlePop(4); DesactiveOriginalBuilding(); } else if (build.tag == "FireStation") { resource.RemoveWood(fireStationCostWood); resource.RemoveGold(fireStationCostGold); resource.AddFireStation(); resource.RemoveCurrentPop(2); resource.AddNonIdlePop(2); if (resource.fireStation > 4) { DesactiveOriginalBuilding(); } } else if (build.tag == "Barracks") { resource.RemoveWood(churchCostWood); resource.RemoveGold(churchCostGold); resource.AddBarracks(); resource.RemoveCurrentPop(8); resource.AddNonIdlePop(8); } }