Exemple #1
0
 private void ResetStack()
 {
     roomStack.Clear();
     hashPositions.Clear();
     foreach (IRoom room in Grid.Keys)
     {
         MapRoom mapRoom = Grid[room];
         roomStack.Push(new RoomPositionInfo(room, mapRoom.Position.X, mapRoom.Position.Y, mapRoom.Position.Z));
         hashPositions.Add(mapRoom.Position.ToString());
     }
 }
Exemple #2
0
        private void AddRoom(IZone zone, IRoom room, int x, int y, int z)
        {
            roomStack.Push(new RoomPositionInfo(room, x, y, z));
            while (roomStack.Count != 0)
            {
                RoomPositionInfo roomPositionInfo = roomStack.Pop();
                room = roomPositionInfo.Room;
                x    = roomPositionInfo.X;
                y    = roomPositionInfo.Y;
                z    = roomPositionInfo.Z;


                if (Grid.ContainsKey(room))
                {
                    //return;
                }
                else
                {
                    MapRoom mapRoom = new MapRoom(zone, room, new Position(x, y, z));
                    Grid.Add(room, mapRoom);
                    hashPositions.Add(mapRoom.Position.ToString());
                }

                if (room.North != null)
                {
                    IExit exit = room.North;
                    if (exit.Zone == room.Zone)
                    {
                        IRoom newRoom = zone.Rooms[exit.Room];
                        if (!Grid.ContainsKey(newRoom))
                        {
                            Position currentPosition = Grid[room].Position;
                            while (CheckPosition(currentPosition.X, currentPosition.Y + 1, currentPosition.Z))
                            {
                                MigrateSouth(currentPosition.Y);
                            }

                            roomStack.Push(new RoomPositionInfo(newRoom, currentPosition.X, currentPosition.Y + 1, currentPosition.Z));
                        }
                    }
                }

                if (room.East != null)
                {
                    IExit exit = room.East;
                    if (exit.Zone == room.Zone)
                    {
                        IRoom newRoom = zone.Rooms[exit.Room];
                        if (!Grid.ContainsKey(newRoom))
                        {
                            Position currentPosition = Grid[room].Position;

                            while (CheckPosition(currentPosition.X + 1, currentPosition.Y, currentPosition.Z))
                            {
                                MigrateWest(currentPosition.X);
                            }
                            roomStack.Push(new RoomPositionInfo(newRoom, currentPosition.X + 1, currentPosition.Y, currentPosition.Z));
                        }
                    }
                }

                if (room.South != null)
                {
                    IExit exit = room.South;
                    if (exit.Zone == room.Zone)
                    {
                        IRoom newRoom = zone.Rooms[exit.Room];
                        if (!Grid.ContainsKey(newRoom))
                        {
                            Position currentPosition = Grid[room].Position;
                            while (CheckPosition(currentPosition.X, currentPosition.Y - 1, currentPosition.Z))
                            {
                                MigrateNorth(currentPosition.Y);
                            }
                            roomStack.Push(new RoomPositionInfo(newRoom, currentPosition.X, currentPosition.Y - 1, currentPosition.Z));
                        }
                    }
                }

                if (room.West != null)
                {
                    IExit exit = room.West;
                    if (exit.Zone == room.Zone)
                    {
                        IRoom newRoom = zone.Rooms[exit.Room];
                        if (!Grid.ContainsKey(newRoom))
                        {
                            Position currentPosition = Grid[room].Position;
                            while (CheckPosition(currentPosition.X - 1, currentPosition.Y, currentPosition.Z))
                            {
                                MigrateEast(currentPosition.X);
                            }
                            roomStack.Push(new RoomPositionInfo(newRoom, currentPosition.X - 1, currentPosition.Y, currentPosition.Z));
                        }
                    }
                }

                if (room.Up != null)
                {
                    IExit exit = room.Up;
                    if (exit.Zone == room.Zone)
                    {
                        IRoom newRoom = zone.Rooms[exit.Room];
                        if (!Grid.ContainsKey(newRoom))
                        {
                            Position currentPosition = Grid[room].Position;
                            while (CheckPosition(currentPosition.X, currentPosition.Y, currentPosition.Z + 1))
                            {
                                MigrateDown(currentPosition.Z);
                            }
                            roomStack.Push(new RoomPositionInfo(newRoom, currentPosition.X, currentPosition.Y, currentPosition.Z + 1));
                        }
                    }
                }

                if (room.Down != null)
                {
                    IExit exit = room.Down;
                    if (exit.Zone == room.Zone)
                    {
                        IRoom newRoom = zone.Rooms[exit.Room];
                        if (!Grid.ContainsKey(newRoom))
                        {
                            Position currentPosition = Grid[room].Position;
                            while (CheckPosition(currentPosition.X, currentPosition.Y, currentPosition.Z - 1))
                            {
                                MigrateUp(currentPosition.Z);
                            }
                            roomStack.Push(new RoomPositionInfo(newRoom, currentPosition.X, currentPosition.Y, currentPosition.Z - 1));
                        }
                    }
                }
            }
        }
Exemple #3
0
Fichier : Map.cs Projet : crybx/mud
        private void DrawConnections(MapGrid grid, Image <Rgba32> image, int z)
        {
            int maxHeight = image.Height;

            foreach (IRoom room in grid.Grid.Keys)
            {
                MapRoom mapRoom = grid.Grid[room];
                if (mapRoom.Position.Z == z)
                {
                    int xRoomPos = RoomPosition(mapRoom.Position.X);
                    int yRoomPos = RoomPosition(mapRoom.Position.Y);
                    if (room.North != null)
                    {
                        for (int x = 0; x < connectorThickeness; x++)
                        {
                            int xPos = xRoomPos + x + 4;

                            for (int y = 0; y < connectorSize / 2; y++)
                            {
                                int yPos = yRoomPos + roomSize + y;

                                image[xPos, ReverseY(yPos, image)] = Rgba32.Black;
                            }
                        }
                    }

                    if (room.East != null)
                    {
                        for (int x = 0; x < connectorSize / 2; x++)
                        {
                            int xPos = (xRoomPos + roomSize) + x;

                            for (int y = 0; y < connectorThickeness; y++)
                            {
                                int yPos = yRoomPos + y + 4;

                                image[xPos, ReverseY(yPos, image)] = Rgba32.Black;
                            }
                        }
                    }

                    if (room.South != null)
                    {
                        for (int x = 0; x < connectorThickeness; x++)
                        {
                            int xPos = xRoomPos + x + 4;

                            for (int y = 0; y < connectorSize / 2; y++)
                            {
                                int yPos = yRoomPos - y - 1;

                                image[xPos, ReverseY(yPos, image)] = Rgba32.Black;
                            }
                        }
                    }

                    if (room.West != null)
                    {
                        for (int x = 0; x < connectorSize / 2; x++)
                        {
                            int xPos = xRoomPos - x - 1;

                            for (int y = 0; y < connectorThickeness; y++)
                            {
                                int yPos = yRoomPos + y + 4;

                                image[xPos, ReverseY(yPos, image)] = Rgba32.Black;
                            }
                        }
                    }

                    if (room.Up != null)
                    {
                        for (int x = 0; x < connectorSize / 2; x++)
                        {
                            int xPos = xRoomPos + roomSize - 1 + x;
                            int yPos = yRoomPos + roomSize + x;

                            for (int i = 0; i < 2; i++)
                            {
                                image[xPos + i, ReverseY(yPos, image)] = Rgba32.Black;
                            }
                        }
                    }

                    if (room.Down != null)
                    {
                        for (int x = 0; x < connectorSize / 2; x++)
                        {
                            int xPos = xRoomPos - x;
                            int yPos = yRoomPos - x;
                            for (int i = 0; i < 2; i++)
                            {
                                image[xPos - i, ReverseY(yPos, image)] = Rgba32.Black;
                            }
                        }
                    }
                }
            }
        }