void placeBoulders()
 {
     for (int i = 0; i < tileCountX; i++)
     {
         for (int j = 0; j < tileCountY; j++)
         {
             Sprite spr = map.GetSprite(new Vector3Int(i - 1, j - 1, 0));
             if (spr.name == "hd_0")
             {
                 place.CreateObject(boulder, i, j);
             }
         }
     }
 }
Esempio n. 2
0
    private void Update()
    {
        if (!(tool.GetMode() == ToolModes.farmMode))
        {
            return;
        }

        place.GetMouseTile(out int tileX, out int tileY);

        indicator.transform.position = new Vector2(tileX, tileY);

        if (!place.InBounds(tileX, tileY) || !place.NearPlayer(tileX, tileY, 2))
        {
            indicatorRenderer.color = red;
            return;
        }

        if (tileMap.GetTile(new Vector3Int(tileX - 1, tileY - 1, 0)).name != "dirtc")
        {
            indicatorRenderer.sprite = tiles[0].sprite;
            indicatorRenderer.color  = green;
            if (Input.GetMouseButtonDown(1))
            {
                tileMap.SetTile(new Vector3Int(tileX - 1, tileY - 1, 0), tiles[0]);
            }
        }
        else
        {
            indicatorRenderer.sprite = plant.GetComponent <SpriteRenderer>().sprite;

            if (tileLayout.GetTile(tileX, tileY).getObjectOnTile() == null)
            {
                indicatorRenderer.color = orange;
                if (Input.GetMouseButtonDown(0))
                {
                    Tutorial.Instance.TriggerDialogue(6);
                    place.CreateObject(plant, tileX, tileY);
                }
                if (Input.GetMouseButtonDown(1))
                {
                    tileMap.SetTile(new Vector3Int(tileX - 1, tileY - 1, 0), tiles[1]);
                }
            }
            else
            {
                indicatorRenderer.color = red;
                if (Input.GetMouseButtonDown(1))
                {
                    if (tileLayout.GetTile(tileX, tileY).getObjectOnTile().tag == "Plant")
                    {
                        if (tileLayout.GetTile(tileX, tileY).getObjectOnTile().GetComponent <Plants>().getStages() == 5)
                        {
                            Tutorial.Instance.TriggerDialogue(10);
                            Tutorial.Instance.TriggerDialogue(11);
                            Debug.Log("yay");
                        }
                        place.DestroyObject(tileX, tileY);
                    }
                    else
                    {
                        tileMap.SetTile(new Vector3Int(tileX - 1, tileY - 1, 0), tiles[1]);
                    }
                }
            }
        }
    }