示例#1
0
    public override void CreateRoom(List <GameObject> tiles)
    {
        Tile  newtile;
        float xpos = Position.x, ypos = Position.y, zpos = Position.z;

        newtile = new Tile("Corner_Top_Left", tiles.Where(obj => obj.name == "Corner_Top_Left").First(), new Vector3(xpos, ypos, zpos));
        RoomTiles.Add(newtile);
    }
示例#2
0
    public override void   CreateRoom(List <GameObject> tiles)
    {
        Tile  newtile;
        float xpos = Position.x, ypos = Position.y, zpos = Position.z;

        for (int i = 0; i < Tiles_number_x; i++)
        {
            for (int j = 0; j < Tiles_number_z; j++)
            {
                if (i == (Tiles_number_x - 1) / 2 && j == (Tiles_number_z - 1) / 2)
                {
                    newtile = new Tile("Portal", tiles.Where(obj => obj.name == "Portal").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (i == 0 && j == 0)
                {
                    newtile = new Tile("Left_Top_Corner", tiles.Where(obj => obj.name == "Left_Top_Corner").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (i == 0 && j == Tiles_number_z - 1)
                {
                    newtile = new Tile("Right_Top_Corner", tiles.Where(obj => obj.name == "Right_Top_Corner").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (i == Tiles_number_x - 1 && j == 0)
                {
                    newtile = new Tile("Left_Bottom_Corner", tiles.Where(obj => obj.name == "Left_Bottom_Corner").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (i == Tiles_number_x - 1 && j == Tiles_number_z - 1)
                {
                    newtile = new Tile("Right_Bottom_Corner", tiles.Where(obj => obj.name == "Right_Bottom_Corner").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (i == 0)
                {
                    newtile = new Tile("Top_Wall", tiles.Where(obj => obj.name == "Top_Wall").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (i == Tiles_number_x - 1)
                {
                    newtile = new Tile("Bottom_Wall", tiles.Where(obj => obj.name == "Bottom_Wall").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (j == 0)
                {
                    newtile = new Tile("Left_Wall", tiles.Where(obj => obj.name == "Left_Wall").First(), new Vector3(xpos, ypos, zpos));
                }
                else if (j == Tiles_number_z - 1)
                {
                    newtile = new Tile("Right_Wall", tiles.Where(obj => obj.name == "Right_Wall").First(), new Vector3(xpos, ypos, zpos));
                }
                else
                {
                    newtile = new Tile("Center", tiles.Where(obj => obj.name == "Center").First(), new Vector3(xpos, ypos, zpos));
                }

                RoomTiles.Add(newtile);

                xpos += Tile.X_length;
            }
            xpos  = Position.x;
            zpos -= Tile.Z_length;
        }
    }
示例#3
0
    public void GenerateSection(int roomsPerSection, RoomType roomType = RoomType.None, bool first = false)
    {
        RoomTiles tiles = tileGenerator.RandomRoomType();

        for (int roomsGenerated = 0; roomsGenerated < roomsPerSection; roomsGenerated++)
        {
            WorldTile worldTile = tiles.GetRandomTile();

            GenerateTile(worldTile, maxTriesPerRoom);
        }
    }
示例#4
0
    public override void CreateRoom(List <GameObject> tiles)
    {
        Tile  newtile;
        float xpos = Position.x, ypos = Position.y, zpos = Position.z;

        for (int i = 0; i < Tiles_number_x; i++)
        {
            newtile = new Tile("Horizontal_Wall", tiles.Where(obj => obj.name == "Corridor_Horizontal").First(), new Vector3(xpos, ypos, zpos));
            RoomTiles.Add(newtile);
            xpos += Tile.X_length;
        }
    }
示例#5
0
        internal static IList <(string Name, Coordinate Coordinates)> PopulateBlock(this RoomTiles tiles, int blockRow, int blockCol)
        {
            var rowOffset  = blockRow * tiles.TilesPerBlock + 1;
            var colOffset  = blockCol * tiles.TilesPerBlock + 1;
            var emptyTiles = new List <(string Name, Coordinate Coordinates)>();

            for (var row = 0; row < tiles.TilesPerBlock; row++)
            {
                for (var column = 0; column < tiles.TilesPerBlock; column++)
                {
                    var coordinates = new Coordinate(row + rowOffset, column + colOffset);

                    emptyTiles.Add((string.Empty, coordinates));
                }
            }

            return(emptyTiles);
        }
示例#6
0
        public void Close()
        {
            if (!ProjectLoaded)
            {
                return;
            }

            Rooms.Clear();
            DoorSets.Clear();
            Doors.Clear();
            ScrollSets.Clear();
            PlmSets.Clear();
            ScrollPlmDatas.Clear();
            Backgrounds.Clear();
            Fxs.Clear();
            SaveStations.Clear();
            LevelDatas.Clear();
            EnemySets.Clear();
            EnemyGfxs.Clear();
            ScrollAsms.Clear();
            DoorAsms.Clear();
            SetupAsms.Clear();
            MainAsms.Clear();
            TileSets.Clear();
            TileTables.Clear();
            TileSheets.Clear();
            Palettes.Clear();
            AreaMaps.Clear();
            PlmTypes.Clear();
            EnemyTypes.Clear();

            CurrentRom      = null;
            ProjectPath     = String.Empty;
            RomFileName     = String.Empty;
            ProjectFileName = String.Empty;

            RoomTiles.Clear();
            MapTiles.Clear();
            BackgroundImage = null;

            ChangesMade   = false;
            ProjectLoaded = false;
            ProjectClosed?.Invoke(this, null);
        }
示例#7
0
        public static Bitmap GetLayer2(int room, int flags)
        {
            var rInfo   = RoomInfo.RoomInfoEntries[room];
            var rGfxPal = RoomGfxPal.RoomGfxPalEntries[room];

            // Get the width and height (in 16*16 tiles)
            int w = rInfo.Width;
            int h = rInfo.Height;

            // Create the bitmap
            Bitmap     bmp = new Bitmap(w << 4, h << 4, PixelFormat.Format8bppIndexed);
            BitmapData bd  = bmp.LockBits(ImageLockMode.WriteOnly);

            // Get the graphics
            var gfx  = RoomGfx.GetTilesets(rGfxPal);
            int hash = gfx.GetHashCode();

            // Get the tiles
            var tiles = RoomTiles.GetTiles(room);

            if (tiles == null)
            {
                return(null);
            }

            // Get the map
            var map = new byte[1][];

            for (int i = 1; i < 2; i++)
            {
                map[i - 1] = RoomMap.GetMap(room, i);
            }

            // Get the palette
            var pal = RoomPal.GetPalette(rGfxPal.Pal);

            bmp.CopyPalette(pal, true);

            // For each layer...
            for (int layer = 1; layer >= 1; layer--)
            {
                // Check if it's in the flags for rendering this layer
                if (((flags & (1 << layer)) != 0) && (map[layer - 1] != null))
                {
                    // Make sure the map is big enough: some of them aren't!
                    if (map[layer - 1].Length >= (w * h * 2))
                    {
                        // We're drawing it, so for each entry in the map...
                        for (int mapy = 0; mapy < h; mapy++)
                        {
                            for (int mapx = 0; mapx < w; mapx++)
                            {
                                // Get the 16x16 tile number
                                ushort ch     = map[layer - 1].ReadUShort((mapx + (mapy * w)) * 2);
                                ushort tile16 = (ushort)(ch & 0x3FF);

                                if ((tile16 >> 6) < 12)
                                {
                                    int tpal = (ch >> 10) & 0xF;

                                    bool tflipx = (ch & 0x4000) != 0;
                                    bool tflipy = (ch & 0x8000) != 0;

                                    // For this tile... get the four 8x8 subtiles
                                    int[,] tile8   = new int[2, 2];
                                    bool[,] sflipx = new bool[2, 2];
                                    bool[,] sflipy = new bool[2, 2];

                                    uint magic = tiles.ReadUInt(tile16 * 8);

                                    tile8[0, 0] = tiles[(tile16 * 8) + 4];
                                    tile8[0, 1] = tiles[(tile16 * 8) + 5];
                                    tile8[1, 0] = tiles[(tile16 * 8) + 6];
                                    tile8[1, 1] = tiles[(tile16 * 8) + 7];

                                    for (int i = 0; i < 2; i++)
                                    {
                                        for (int j = 0; j < 2; j++)
                                        {
                                            sflipx[i, j] = (tile8[i, j] & 0x40) != 0;
                                            sflipy[i, j] = (tile8[i, j] & 0x80) != 0;

                                            tile8[i, j] &= 0x3F;
                                            tile8[i, j] |= (ch & 0x3C0);
                                        }
                                    }

                                    // magic appears to contain some sort of tile mask...
                                    uint mask = (magic >> 16) & 0xF;
                                    if ((mask & 0x1) == 0)
                                    {
                                        tile8[0, 0] = -1;
                                    }
                                    if ((mask & 0x2) == 0)
                                    {
                                        tile8[0, 1] = -1;
                                    }
                                    if ((mask & 0x4) == 0)
                                    {
                                        tile8[1, 0] = -1;
                                    }
                                    if ((mask & 0x8) == 0)
                                    {
                                        tile8[1, 1] = -1;
                                    }

                                    // For each of these subtiles...
                                    for (int tiley = 0; tiley < 2; tiley++)
                                    {
                                        for (int tilex = 0; tilex < 2; tilex++)
                                        {
                                            if (tile8[tiley, tilex] >= 0)
                                            {
                                                int tileset = tile8[tiley, tilex] >> 6;
                                                int subtile = tile8[tiley, tilex] & 0x3F;

                                                int tileoffset = subtile << 5;

                                                var pixels = gfx[tileset].Read4BppTile(tileoffset);

                                                int tx = tflipx ? 1 - tilex : tilex;
                                                int ty = tflipy ? 1 - tiley : tiley;

                                                GfxProvider.RenderToBitmap(bd, pixels,
                                                                           (mapx << 4) + (tx << 3),
                                                                           (mapy << 4) + (ty << 3),
                                                                           sflipx[tiley, tilex] ^ tflipx,
                                                                           sflipy[tiley, tilex] ^ tflipy,
                                                                           tpal, true);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            bmp.UnlockBits(bd);
            return(bmp);
        }