void HoeGround() { GrassBehaviour tile = GameMasterScript.GetGrassTile(this.transform.position); if (tile.GetCanBeHoed()) { tile.HoeGround(); } }
void CollectPlant() { GrassBehaviour tile = GameMasterScript.GetGrassTile(this.transform.position); if (tile.GetHasPlant()) { GameMasterScript.RemovePlant(tile.GetPlantFromTile()); tile.CleanTile(); } }
void Plant() { GrassBehaviour tile = GameMasterScript.GetGrassTile(this.transform.position); if (tile.GetCanBePlantedOn()) { PlantGrow plant = Instantiate(GameMasterScript.GetPlant(EPlantRarity.ECommon), tile.transform.position, Quaternion.identity); tile.PlantOnTile(plant); } }
public GrassBehaviour GetGrassTile(Vector3 location) { GrassBehaviour selectedTile = null; float lastSmallestDist = float.MaxValue; foreach (GrassBehaviour tile in MapTiles) { if (Mathf.Abs(Vector3.Distance(location, tile.transform.position)) < lastSmallestDist) //smallest difference { selectedTile = tile; lastSmallestDist = Mathf.Abs(Vector3.Distance(location, tile.transform.position)); } } return(selectedTile); }