public void MatModifier() { MeshRenderer mrd = GetComponent <MeshRenderer>(); if (NaturalElementInstance.tag == "Tree") { mrd.material = greenMat; } if (altitude > 4) { MeshRenderer natureElemRend = NaturalElementInstance.GetComponentInChildren <MeshRenderer>(); natureElemRend.material = snowMat; if (!NaturalElementInstance.GetComponent <BuildSystem>() && altitude > 5) { mrd.material = snowMat; } } }
public void TryPlaceNaturalElem(GameObject naturalElem) { Vector3 naturalPlace = new Vector3(transform.position.x, transform.position.y + naturalElem.transform.lossyScale.y / 2.0f, transform.position.z); NaturalElementInstance = Instantiate(naturalElem, naturalPlace, Quaternion.identity, transform); IsBuildable = false; GameManagement.instance.NatureEvolution.AddNatureElem(NaturalElementInstance); MatModifier(); if (NaturalElementInstance.GetComponent <RessourcesConsummer>()) { GameManagement.instance.RemoveResources(NaturalElementInstance.GetComponent <RessourcesConsummer>()); } if (NaturalElementInstance.GetComponentInChildren <BuildSystem>()) { GameManagement.instance.GridCreator.AddNewBuildSystem(NaturalElementInstance.transform); } }