Example #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Vector3    mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            Vector3Int coordinate    = theGrid.WorldToCell(mouseWorldPos);



            for (int i = coordinate.x; i < coordinate.x + 1; i++)
            {
                for (int j = coordinate.y; j < coordinate.y + 1; j++)
                {
                    place.x      = i;
                    place.y      = j;
                    saverCurrent = TheTileMap.GetTile(place);

                    if (saverCurrent == WorkTile)
                    {
                        if (money.Leavs >= 2 && money.Wood >= 2)
                        {
                            money.addLeaves(-2);
                            money.addWood(-2);


                            place.x      = 50 + i;
                            saver        = TheTileMap.GetTile(place);
                            saverCurrent = saver;

                            place.x = i;
                            TheTileMap.SetTile(place, saver);
                            map.SetWalking(place.x, place.y, 0);

                            CheckIfWalkableTile(place);
                            Checksides(place);
                        }
                    }
                }
            }
        }
    }