public void TreesFall() { GameObject[] allPower = GameObject.FindGameObjectsWithTag("Power"); List <GameObject> nextToTrees = new List <GameObject>(); for (int i = 0; i < allPower.Length; i++) { if (build.isObjectNextToTree(allPower[i])) { nextToTrees.Add(allPower[i]); } } if (nextToTrees == null) { return; } int rollRandom = Random.Range(0, nextToTrees.Count); GameObject[] toArray = nextToTrees.ToArray(); //Following function removes gameobject next to tree //previously this was the destroy function if (rollRandom < nextToTrees.Count && toArray[rollRandom] != null) { GameObject.Find("GameManager").GetComponent <BuildFunctions>().RemoveObjectFunction(toArray[rollRandom]); } currentEvent = allRandomEvents.treesFall; }
public void Clouds() { solarMultiplier = cloudsMultiplier; currentEvent = allRandomEvents.cloudyDay; var objects = GameObject.FindGameObjectsWithTag("solar"); var objectCount = objects.Length; for (int i = 0; i < objectCount; i++) { objects[i].GetComponent <SolarScript>().daysToBeBroken = 2; } }
public void SmogEvent() { currentEvent = allRandomEvents.smog; solarMultiplier = smogSolarEffect; var objects = GameObject.FindGameObjectsWithTag("solar"); var objectCount = objects.Length; for (int i = 0; i < objectCount; i++) { objects[i].GetComponent <SolarScript>().daysToBeBroken = 2; } }
public void GasLeak() { gasLeak = true; currentEvent = allRandomEvents.gasLeak; var objects = GameObject.FindGameObjectsWithTag("gasPlant"); var objectCount = objects.Length; for (int i = 0; i < objectCount; i++) { if (objects[i].GetComponent <NaturalGasScript>().broken == false) { objects[i].GetComponent <NaturalGasScript>().broken = true; objects[i].GetComponent <NaturalGasScript>().daysToBeBroken = 3;//days needs to have an extra for reasons break; } } }
public void WindmillBreak() { brokeWindmill = true; currentEvent = allRandomEvents.windmillBreaks; var objects = GameObject.FindGameObjectsWithTag("turbine"); var objectCount = objects.Length; for (int i = 0; i < objectCount; i++) { if (objects[i].GetComponent <TurbineScript>().broken == false) { objects[i].GetComponent <TurbineScript>().broken = true; objects[i].GetComponent <TurbineScript>().daysToBeBroken = 2;//days needs to have an extra for reasons break; } } }
public void Protest() { protest = true; currency -= NaturalGasScript.cost; currentEvent = allRandomEvents.protests; var objects = GameObject.FindGameObjectsWithTag("gasPlant"); var objectCount = objects.Length; for (int i = 0; i < objectCount; i++) { if (objects[i].GetComponent <NaturalGasScript>().broken == false) { objects[i].GetComponent <NaturalGasScript>().daysToBeBroken = 2;//days needs to have an extra for reasons currency -= NaturalGasScript.cost; break; } } }
public void UnheathlyAir() { coalMultiplier = unhealthyAirMultiplier; gasMultiplier = unhealthyAirMultiplier; currentEvent = allRandomEvents.unhealthyAir; var objects = GameObject.FindGameObjectsWithTag("coal"); var objectCount = objects.Length; for (int i = 0; i < objectCount; i++) { objects[i].GetComponent <CoalScript>().daysToBeBroken = 2; } objects = GameObject.FindGameObjectsWithTag("gasPlant"); objectCount = objects.Length; for (int i = 0; i < objectCount; i++) { objects[i].GetComponent <NaturalGasScript>().daysToBeBroken = 2;//days needs to have an extra for reasons } }