public void MowLawn(Vector3 position) { GardenType block = ReturnBlockFromPosition(position); block.meshRenderer.material = materials[0]; block.floorType = FloorType.MOWED; }
bool AdjacentToGrass(Vector3 position) { GardenType gardenType = new GardenType(); List <FloorType> checkFloorTypes = new List <FloorType>() { FloorType.MOWED, FloorType.UNMOWED }; if (position.x > 0) { gardenType = ReturnGardenTypeFromPosition(position + Vector3.left); if (gardenType != null) { if (CheckIfHasFloorTypes(gardenType, checkFloorTypes)) { return(true); } } } if (position.x < x) { gardenType = ReturnGardenTypeFromPosition(position - Vector3.left); if (gardenType != null) { if (CheckIfHasFloorTypes(gardenType, checkFloorTypes)) { return(true); } } } if (position.z > 0) { gardenType = ReturnGardenTypeFromPosition(position - Vector3.forward); if (gardenType != null) { if (CheckIfHasFloorTypes(gardenType, checkFloorTypes)) { return(true); } } } if (position.z < z) { gardenType = ReturnGardenTypeFromPosition(position + Vector3.forward); if (gardenType != null) { if (CheckIfHasFloorTypes(gardenType, checkFloorTypes)) { return(true); } } } return(false); }
bool CheckIfHasFloorTypes(GardenType gardenType, List <FloorType> floorTypes) { foreach (FloorType floor in floorTypes) { if (gardenType.floorType == floor) { return(true); } } return(false); }
public void CreateBlock(Vector3 position, FloorType floorType) { GameObject blockClone = Instantiate(block, position, Quaternion.identity); blockClone.transform.SetParent(this.transform); GardenType gardenType = new GardenType(); gardenType.position = position; gardenType.floorType = floorType; gardenType.meshRenderer = blockClone.GetComponent <MeshRenderer>(); blockClone.GetComponent <MeshRenderer>().material = materials[(int)floorType]; blocks.Add(gardenType); }
void FindGardenBlocks() { foreach (Transform child in transform) { GardenType gardenBlock = new GardenType(); gardenBlock.position = child.position; Material mat = child.GetComponent <MeshRenderer>().sharedMaterials[0]; if (mat == materials[0]) { gardenBlock.floorType = FloorType.MOWED; } if (mat == materials[1]) { gardenBlock.floorType = FloorType.UNMOWED; } if (mat == materials[2]) { gardenBlock.floorType = FloorType.BLOCKER; } gardenBlock.meshRenderer = child.GetComponent <MeshRenderer>(); gardenBlocks.Add(gardenBlock); } }
public bool ForwardBump(Vector3 position) { GardenType block = ReturnBlockFromPosition(position); return(block.floorType == FloorType.BLOCKER); }