Пример #1
0
    public void PlaceTile(GameTile tile, Vector2Int pos, Quaternion rotation)
    {
        //Check if it already exists
        if (placedTiles.Contains(pos))
        {
            return;
        }
        if (tilemap.HasTile((Vector3Int)pos))
        {
            return;
        }
        if (GetTilesLeft() <= 0)
        {
            return;
        }

        //Add
        tilemap.SetTile((Vector3Int)pos, tile);
        placedTiles.Add(pos);

        //Rotate
        var instance = tilemap.GetInstantiatedObject((Vector3Int)pos);

        instance.transform.rotation = rotation;
    }
Пример #2
0
    public Vector3 randomEmpty()
    {
        Vector3Int x;

        for (x = new Vector3Int(Random.Range(-16, 16), Random.Range(-16, 16), 0); WallMap.HasTile(x); x = new Vector3Int(Random.Range(-16, 16), Random.Range(-16, 16), 0))
        {
            ;
        }
        return(Zone.GetCellCenterWorld(x));
    }
Пример #3
0
    public Vector3Int squareAroundPlayer(Vector2 dimensions)
    {
        List <Vector3Int> cells = new List <Vector3Int>();

        Vector3Int BL = Ground.WorldToCell(Camera.main.transform.position - (Vector3)dimensions / 2);
        Vector3Int TR = Ground.WorldToCell(Camera.main.transform.position + (Vector3)dimensions / 2);

        for (int y = BL.y; y <= TR.y; y++)
        {
            for (int x = BL.x; x <= TR.x; x++)
            {
                if ((BL.x == x || BL.y == y || TR.x == x || TR.y == y) && !WallMap.HasTile(Vector3Int.right * x + Vector3Int.up * y) && Ground.HasTile(Vector3Int.right * x + Vector3Int.up * y))
                {
                    cells.Add(Vector3Int.up * y + Vector3Int.right * x);
                }
            }
        }
        return(cells[Random.Range(0, cells.Count)]);
    }
Пример #4
0
    static int HasTile(IntPtr L)
    {
        try
        {
            ToLua.CheckArgsCount(L, 2);
            UnityEngine.Tilemaps.Tilemap obj  = (UnityEngine.Tilemaps.Tilemap)ToLua.CheckObject(L, 1, typeof(UnityEngine.Tilemaps.Tilemap));
            UnityEngine.Vector3Int       arg0 = StackTraits <UnityEngine.Vector3Int> .Check(L, 2);

            bool o = obj.HasTile(arg0);
            LuaDLL.lua_pushboolean(L, o);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }