Exemple #1
0
        //an initial create-map method
        public override void Generate(int seed, RDungeonFloor entry, List<FloorBorder> floorBorders, Dictionary<int, List<int>> borderLinks)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed = seed;
            this.entry = entry;
            FloorBorders = floorBorders;
            BorderLinks = borderLinks;

            BorderPoints = new Loc2D[1];

            rand = new Random(seed);

            MapArray = new Tile[10, 10];

            MapLayer ground = new MapLayer(Width, Height);
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                    GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                }
            }

            BorderPoints[0] = new Loc2D(0, 0);
        }
Exemple #2
0
 public DisplayMap()
 {
     MapArray = new Tile[1, 1];
     MapArray[0, 0] = new Tile(Enums.TileType.Void, 0, 0, 0);
     GroundLayers = new List<TileAnim[,]>();
     PropBackLayers = new List<TileAnim[,]>();
     PropFrontLayers = new List<TileAnim[,]>();
     FringeLayers = new List<TileAnim[,]>();
 }
Exemple #3
0
        //an initial create-map method
        public override void Generate(int seed, RDungeonFloor entry, List<FloorBorder> floorBorders, Dictionary<int, List<int>> borderLinks)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed = seed;
            this.entry = entry;
            FloorBorders = floorBorders;
            BorderLinks = borderLinks;

            BorderPoints = new Loc2D[floorBorders.Count];

            rand = new Random(seed);

            MapArray = new Tile[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];
            GridArray = new GridType[entry.FloorSettings["CellX"] * entry.FloorSettings["CellWidth"] + 2, entry.FloorSettings["CellY"] * entry.FloorSettings["CellHeight"] + 2];

            Rooms = new DungeonArrayRoom[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"]]; //array of all rooms
            VHalls = new DungeonArrayHall[entry.FloorSettings["CellX"], entry.FloorSettings["CellY"] - 1]; //vertical halls
            HHalls = new DungeonArrayHall[entry.FloorSettings["CellX"] - 1, entry.FloorSettings["CellY"]]; //horizontal halls
            StartRoom = new Loc2D(-1, -1);     //marks spawn point

            bool isDone;   // bool used for various purposes

            //initialize map array to empty
            for (int y = 0; y < Height; y++) {
                for (int x = 0; x < Width; x++) {
                    GridArray[x, y] = GridType.Blocked;
                }
            }

            //initialize all rooms+halls to closed by default
            for (int x = 0; x < entry.FloorSettings["CellX"]; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++) {
                    Rooms[x, y] = new DungeonArrayRoom();
                }
            }

            for (int x = 0; x < entry.FloorSettings["CellX"]; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"] - 1; y++) {
                    VHalls[x, y] = new DungeonArrayHall();
                }
            }

            for (int x = 0; x < entry.FloorSettings["CellX"] - 1; x++) {
                for (int y = 0; y < entry.FloorSettings["CellY"]; y++) {
                    HHalls[x, y] = new DungeonArrayHall();
                }
            }

            // path generation algorithm
            StartRoom = new Loc2D(rand.Next(0, entry.FloorSettings["CellX"]), rand.Next(0, entry.FloorSettings["CellY"])); // randomly determine start room
            Loc2D wanderer = StartRoom;

            int pathsMade = 0;
            int pathsNeeded = rand.Next(0, 6) + 5; // magic numbers, determine what the dungeon looks like (in general, paths)
            Direction4 prevDir = Direction4.None; // direction of movement
            do {
                if (rand.Next(0, (2 + pathsMade)) == 0) {//will end the current path and start a new one from the start
                    if (rand.Next(0, 2) == 0) {//determine if the room should be open or a hall
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    } else {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                    pathsMade++;
                    wanderer = StartRoom;
                    prevDir = Direction4.None;
                } else {
                    bool working = true;
                    do {
                        Loc2D sample = wanderer;
                        Direction4 nextDir = (Direction4)rand.Next(0, 4);
                        if (nextDir != prevDir) {//makes sure there is no backtracking
                            Operations.MoveInDirection4(ref sample, nextDir, 1);
                            prevDir = Operations.ReverseDir(nextDir);
                            if (sample.X >= 0 && sample.X < entry.FloorSettings["CellX"] && sample.Y >= 0 && sample.Y < entry.FloorSettings["CellY"]) {// a is the room to be checked after making a move between rooms
                                openHallBetween(wanderer, sample);
                                wanderer = sample;
                                working = false;
                            }
                        } else {
                            prevDir = Direction4.None;
                        }
                    } while (working);

                    if (rand.Next(0, 2) == 0) {//determine if the room should be open or a hall
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Open;
                    } else {
                        Rooms[wanderer.X, wanderer.Y].Opened = DungeonArrayRoom.RoomState.Hall;
                    }
                }
            } while (pathsMade < pathsNeeded);

            Rooms[StartRoom.X, StartRoom.Y].Opened = DungeonArrayRoom.RoomState.Open;

            //Determine key rooms
            isDone = false;
            do { //determine ending room randomly
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open) {
                    EndRoom = new Loc2D(x, y);
                    isDone = true;
                }
            } while (!isDone);

            StartRoom = new Loc2D(-1, -1);

            isDone = false;
            do { //determine starting room randomly
                int x = rand.Next(0, Rooms.GetLength(0));
                int y = rand.Next(0, Rooms.GetLength(1));
                if (Rooms[x, y].Opened == DungeonArrayRoom.RoomState.Open) {
                    StartRoom = new Loc2D(x, y);
                    isDone = true;
                }
            } while (!isDone);

            // begin part 2, creating ASCII map
            //create rooms

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        createRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        drawRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < Rooms.GetLength(0); i++) {
                for (int j = 0; j < Rooms.GetLength(1); j++) {
                    if (Rooms[i, j].Opened != DungeonArrayRoom.RoomState.Closed) {
                        padSingleRoom(i, j);
                    }
                }
            }

            for (int i = 0; i < VHalls.GetLength(0); i++) {
                for (int j = 0; j < VHalls.GetLength(1); j++) {
                    if (VHalls[i, j].Open) {
                        createVHall(i, j);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++) {
                for (int j = 0; j < HHalls.GetLength(1); j++) {
                    if (HHalls[i, j].Open) {
                        createHHall(i, j);
                    }
                }
            }

            for (int i = 0; i < VHalls.GetLength(0); i++) {
                for (int j = 0; j < VHalls.GetLength(1); j++) {
                    if (VHalls[i, j].Open) {
                        DrawHalls(VHalls[i, j]);
                    }
                }
            }

            for (int i = 0; i < HHalls.GetLength(0); i++) {
                for (int j = 0; j < HHalls.GetLength(1); j++) {
                    if (HHalls[i, j].Open) {
                        DrawHalls(HHalls[i, j]);
                    }
                }
            }

            addSEpos(StartRoom, true);
            addSEpos(EndRoom, false);

            //texturing
            MapLayer ground = new MapLayer(Width, Height);
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++) {
                for (int x = 0; x < Width; x++) {
                    if (GridArray[x, y] == GridType.End) {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.ChangeFloor, 1, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    } else if (GridArray[x, y] == GridType.Blocked) {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Blocked, 0, 0, 0);

                        bool[] blockedDirs = new bool[8];
                        for (int n = 0; n < 8; n++) {
                            blockedDirs[n] = IsBlocked(x, y, (Direction8)n);
                        }
                        if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 0;
                            if (!blockedDirs[(int)Direction8.DownLeft])
                                layer += 8 * 2;

                            if (!blockedDirs[(int)Direction8.UpLeft])
                                layer += 1;

                            if (!blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            if (!blockedDirs[(int)Direction8.DownRight])
                                layer += 2;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 6;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 7;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 4;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 5;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 34;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right]) {
                            int layer = 35;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 32;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right]) {
                            int layer = 33;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        } else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(36, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(37, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(38, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(39, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(44, 0), 0);
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(45, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(46, 0), 0);

                    } else {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    }
                }
            }

            GenItems();
            SpawnNpcs();
        }
Exemple #4
0
 public Tile(Tile tile)
 {
     this.Data = tile.Data;
 }
Exemple #5
0
        public void Load(BinaryReader reader)
        {
            //read from memory stream
            Title = reader.ReadString();
            Music = reader.ReadString();
            Indoors = reader.ReadBoolean();
            Darkness = reader.ReadInt32();
            Weather = (Enums.Weather)reader.ReadInt32();
            TimeLimit = reader.ReadInt32();
            MinNpcs = reader.ReadInt32();
            MaxNpcs = reader.ReadInt32();
            NpcSpawnTime = reader.ReadInt32();

            int npcSpawnCount = reader.ReadInt32();
            for (int i = 0; i < NpcSpawns.Count; i++)
            {
                NpcSpawnData spawnData = new NpcSpawnData();
                spawnData.Data.Species = reader.ReadInt32();
                spawnData.Data.Form = reader.ReadInt32();
                spawnData.Data.Gender = (Enums.Gender)reader.ReadInt32();
                spawnData.Data.Shiny = (Enums.Coloration)reader.ReadInt32();

                spawnData.Loc.X = reader.ReadInt32();
                spawnData.Loc.Y = reader.ReadInt32();

                spawnData.MinLevel = reader.ReadInt32();
                spawnData.MaxLevel = reader.ReadInt32();

                for (int j = 0; j < spawnData.Moves.Length; i++)
                {
                    spawnData.Moves[j] = reader.ReadInt32();
                }

                spawnData.AppearanceRate = reader.ReadInt32();

                NpcSpawns.Add(spawnData);
            }

            int width = reader.ReadInt32();
            int height = reader.ReadInt32();

            MapArray = new Tile[width, height];
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    MapArray[x, y] = new Tile();
                    MapArray[x, y].Data.Type = (Enums.TileType)reader.ReadInt32();
                    MapArray[x, y].Data.Data1 = reader.ReadInt32();
                    MapArray[x, y].Data.Data2 = reader.ReadInt32();
                    MapArray[x, y].Data.Data3 = reader.ReadInt32();
                    MapArray[x, y].Data.String1 = reader.ReadString();
                    MapArray[x, y].Data.String2 = reader.ReadString();
                    MapArray[x, y].Data.String3 = reader.ReadString();
                }
            }

            int groundLayerCount = reader.ReadInt32();
            for (int i = 0; i < groundLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                GroundLayers.Add(layerAnim);
            }

            int propBackLayerCount = reader.ReadInt32();
            for (int i = 0; i < propBackLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                PropBackLayers.Add(layerAnim);
            }

            int propFrontLayerCount = reader.ReadInt32();
            for (int i = 0; i < propFrontLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                PropFrontLayers.Add(layerAnim);
            }

            int fringeLayerCount = reader.ReadInt32();
            for (int i = 0; i < fringeLayerCount; i++)
            {
                string name = reader.ReadString();
                MapLayer layerAnim = new MapLayer(name, width, height);
                Game.UpdateLoadMsg("Loading Map... (Layer " + layerAnim.Name + ")");
                for (int y = 0; y < Height; y++)
                {
                    for (int x = 0; x < Width; x++)
                    {
                        layerAnim.Tiles[x, y] = new TileAnim();
                        layerAnim.Tiles[x, y].Load(reader);
                    }
                }
                FringeLayers.Add(layerAnim);
            }
        }
Exemple #6
0
        public void CreateBlank(int width, int height)
        {
            MapArray = new Tile[width, height];
            for (int i = 0; i < width; i++)
            {
                for (int j = 0; j < height; j++)
                {
                    MapArray[i, j] = new Tile();
                }
            }

            MapLayer layer = new MapLayer("Ground", Width, Height);
            GroundLayers.Add(layer);
            layer = new MapLayer("Mask1", Width, Height);
            GroundLayers.Add(layer);
            layer = new MapLayer("Mask2", Width, Height);
            GroundLayers.Add(layer);
            layer = new MapLayer("Fringe1", Width, Height);
            FringeLayers.Add(layer);
            layer = new MapLayer("Fringe2", Width, Height);
            FringeLayers.Add(layer);
        }
Exemple #7
0
        public void Generate(int seed, string fileName)
        {
            //TODO: make sure that this algorithm follows floorBorders and borderLinks constraints

            this.seed = seed;
            this.entry = entry;
            FloorBorders = null;
            BorderLinks = null;

            BorderPoints = new Loc2D[1];

            rand = new Random(seed);

            //load from file

            MapArray = new Tile[100, 100];

            MapLayer ground = new MapLayer(Width, Height);
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                    GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                }
            }

            BorderPoints[0] = new Loc2D(99, 0);
        }
Exemple #8
0
        private void ConvertToMapArray()
        {
            MapArray = new Tile[AgeArray.GetLength(0), AgeArray.GetLength(1)];
            MapLayer ground = new MapLayer(AgeArray.GetLength(0), AgeArray.GetLength(1));
            GroundLayers.Add(ground);
            for (int y = 0; y < Height; y++)
            {
                for (int x = 0; x < Width; x++)
                {
                    if (AgeArray[x, y] != -1)
                    {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Blocked, 0, 0, 0);

                        bool[] blockedDirs = new bool[8];
                        for (int n = 0; n < 8; n++)
                        {
                            blockedDirs[n] = IsBlocked(x, y, (Direction8)n);
                        }
                        if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 0;
                            if (!blockedDirs[(int)Direction8.DownLeft])
                                layer += 8 * 2;

                            if (!blockedDirs[(int)Direction8.UpLeft])
                                layer += 1;

                            if (!blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            if (!blockedDirs[(int)Direction8.DownRight])
                                layer += 2;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 6;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 7;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 4;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 5;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 1 * 8;

                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 2 * 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 34;
                            if (blockedDirs[(int)Direction8.UpRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 35;
                            if (blockedDirs[(int)Direction8.DownRight])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 32;
                            if (blockedDirs[(int)Direction8.DownLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                        {
                            int layer = 33;
                            if (blockedDirs[(int)Direction8.UpLeft])
                                layer += 8;

                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(), 0);
                        }
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(36, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(37, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(38, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(39, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(44, 0), 0);
                        else if (blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(45, 0), 0);
                        else if (!blockedDirs[(int)Direction8.Down] && !blockedDirs[(int)Direction8.Left] && !blockedDirs[(int)Direction8.Up] && !blockedDirs[(int)Direction8.Right])
                            GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(46, 0), 0);

                    }
                    else
                    {
                        MapArray[x, y] = new Tile(PMDToolkit.Enums.TileType.Walkable, 0, 0, 0);
                        GroundLayers[0].Tiles[x, y] = new TileAnim(new Loc2D(47, 0), 0);
                    }
                }
            }
        }