Example #1
0
    private void Start()
    {
        tilemap = gameObject.GetComponent <Tilemap>();

        // Set oldMousePos to a default position
        oldMousePos = new Vector3Int(0, 0, 0);

        // Get the bounds of the Tilemap grid
        BoundsInt bounds = tilemap.cellBounds;

        // Create an 1D array of all the tiles in the Tilemap
        TileBase[] tileArray = tilemap.GetTilesBlock(bounds);

        // Establish valid tower placement tiles
        validTiles = new bool[tileArray.Length];
        for (int i = 0; i < tileArray.Length; i++)
        {
            if (tileArray[i] == normalTile)
            {
                validTiles[i] = true;
            }
        }

        towerScript = tower.GetComponent <TowerMovement>();
    }
    private void Start()
    {
        tilemap     = gameObject.GetComponent <Tilemap>();
        oldMousePos = new Vector3Int(0, 0, 0);

        BoundsInt bounds = tilemap.cellBounds;

        TileBase[] tileArray = tilemap.GetTilesBlock(bounds);
        validTiles = new bool[tileArray.Length];

        for (int i = 0; i < tileArray.Length; i++)
        {
            if (tileArray[i] == normalTile)
            {
                validTiles[i] = true;
            }
        }

        towerScript = tower.GetComponent <TowerMovement>();
    }