public void RebuildStructures(NodeTouch node) { if (structureToBuild == null) { return; } GameObject structure = (GameObject)Instantiate(structureToBuild.prefab, node.GetBuildPosition(), structureToBuild.prefab.transform.rotation); node.nodeInfo.idBuilding = (int)structureToBuild.id; node.structureThere = structureToBuild; Debug.Log("CONSTRUIDO"); //SoundManager.soundManager.PlayConstruction(); //Hide the node node.gameObject.GetComponent <MeshRenderer>().enabled = false; if (!structureToBuild.isWater) { node.buildingThere = structure; } else { node.haveWater = true; } structureToBuild.nodeAsociate = node; structureToBuild = null; //GameObject aux = Instantiate(buildParticlePrefab, node.transform.position, Quaternion.identity); //buildParticle = aux.GetComponentInChildren<ParticleSystem>(); //buildParticle.Play(); }
public void BuildCityHall(NodeTouch node) { GameObject structure = Instantiate(cityHall, node.GetBuildPosition(), cityHall.transform.rotation); node.buildingThere = structure; Debug.Log("City hall did it"); node.gameObject.GetComponent <MeshRenderer>().enabled = false; if (GameControl.control.tutorial == true) { player.IncreaseMoney(startingMoney); } node.nodeInfo.idBuilding = (int)idBuildings.cityhall; structureToBuild = null; haveCityHall = true; DeselectNode(); if (GameControl.control.tutorial && SceneManager.GetActiveScene().buildIndex == 1) { GameObject.Find("TutorialArrows").GetComponent <Tutorial>().FirtsIndicator(); } /*GameObject tut = GameObject.Find("TutorialArrows"); * if(tut != null) * { * tut.GetComponent<Tutorial>().FirtsIndicator(); * }*/ }
public void SetTargetReplaceFactory(NodeTouch t) { target = t; transform.position = target.GetBuildPosition(); uiReplaceFactory.SetActive(true); }
public void DeselectNode() { selectedNode = null; nodeUI.HideReplaceFactory(); nodeUI.HideHouses(); HideInfoPanel(); HideConstructionPanel(); HideInfoPanelBuildings(); //Grid.SetActive(false); createEnvironment.HideRenderNodes(); }
void HouseInstantiate(Node node) { NodeTouch aux = node.nodeGameobject.GetComponent <NodeTouch>(); int rdn = Random.Range(0, differentHouses.Count); housePrefab = differentHouses[rdn]; GameObject spawnHouse = Instantiate(housePrefab, aux.GetBuildPosition(), housePrefab.transform.rotation); aux.buildingThere = spawnHouse; node.objectInNode = spawnHouse; node.idBuilding = (int)idBuildings.houses; aux.gameObject.GetComponent <MeshRenderer>().enabled = false; houses.Add(spawnHouse); }
public void SetTargetHouses(NodeTouch t) { target = t; transform.position = target.GetBuildPosition(); uiHouses.SetActive(true); }
public void BuildStructureOn(NodeTouch node) { if (structureToBuild == null) { return; } if (!HasEnoughMoney()) { Debug.Log("Not enough money!"); player.NotEnoughMoneyPlay(); return; } if (node.haveWater && !structureToBuild.needWater) { Debug.Log("The structure can't build in water"); return; } player.DecreaseMoney(structureToBuild.cost); player.IncreaseHappiness(structureToBuild.amountOfHappiness); player.IncreasePollution(structureToBuild.amountOfPollution); player.IncreaseEnergy(structureToBuild.amountOfEnergy); if (player.activeQuest.Count != 0) { player.activeQuest[0].goal.BuildGoal(structureToBuild); } GameObject structure = (GameObject)Instantiate(structureToBuild.prefab, node.GetBuildPosition(), structureToBuild.prefab.transform.rotation); node.nodeInfo.idBuilding = (int)structureToBuild.id; node.structureThere = structureToBuild; Debug.Log("CONSTRUIDO"); SoundManager.soundManager.PlayConstruction(); //Hide the node node.gameObject.GetComponent <MeshRenderer>().enabled = false; if (!structureToBuild.isWater) { node.buildingThere = structure; } else { node.haveWater = true; } structureToBuild.nodeAsociate = node; if (structureToBuild.id == idBuildings.diner) { if (SceneManager.GetActiveScene().name == "CoalIsland") { inventoryBuilding.coalFactoryStructure.timeMoney *= 0.75f; } } structureToBuild = null; GameObject aux = Instantiate(buildParticlePrefab, node.transform.position, Quaternion.identity); buildParticle = aux.GetComponentInChildren <ParticleSystem>(); buildParticle.Play(); }
public void SelectNode(NodeTouch node) { if (node.tag == "CityPlace" && haveCityHall == false) { BuildCityHall(node); return; } if (haveCityHall) { if (selectedNode == node) { //node.gameObject.GetComponent<MeshRenderer>().enabled = false; DeselectNode(); return; } if (node.isUnlock == false) { DeselectNode(); return; } /* * if (structureToBuild == null && node.buildingThere == null) * { * buildPanel.SetActive(true); * HideInfoPanel(); * selectedNode = node; * return; * } * */ if (structureToBuild != null && node.buildingThere == null) { BuildStructureOn(node); //buildPanel.SetActive(false); DeselectNode(); structureToBuild = null; return; } if (node.buildingThere == null) { DeselectNode(); return; } //If in the node are something if (node.buildingThere != null && node.buildingThere.tag != "House" && node.buildingThere.tag != "CityHall") { selectedNode = node; //infoPanel.SetActive(true); if (destroyActivate) { //destroyPanelSelection.SetActive(true); DestroyThisBuilding(); HideEverything(); return; } //HideConstructionPanel(); HideEverything(); ShowInfoPanelBuildings(); return; } //if(node.buildingThere != null && node.buildingThere.tag == "Monuments" && destroyActivate) //{ // Debug.Log("Demolish monument"); // DestroyThisBuilding(); // HideEverything(); // return; //} } }