Exemplo n.º 1
0
    void HoeGround()
    {
        GrassBehaviour tile = GameMasterScript.GetGrassTile(this.transform.position);

        if (tile.GetCanBeHoed())
        {
            tile.HoeGround();
        }
    }
Exemplo n.º 2
0
    void CollectPlant()
    {
        GrassBehaviour tile = GameMasterScript.GetGrassTile(this.transform.position);

        if (tile.GetHasPlant())
        {
            GameMasterScript.RemovePlant(tile.GetPlantFromTile());
            tile.CleanTile();
        }
    }
Exemplo n.º 3
0
    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);
        }
    }
Exemplo n.º 4
0
    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);
    }