Esempio n. 1
0
        public static bool MoveSouth()
        {
            Room temp = Program.pl.currentRoom.GetSouthRoom();

            if (temp != null)
            {
                if (temp.GetType() == typeof(RoomClosed) && ((RoomClosed)temp).IsClosed())
                {
                    if (RoomClosed.UseKey())
                    {
                        ((RoomClosed)temp).OpenRoom();
                        if (Program.pl.GetMaldicion(4))
                        {
                            Program.pl.currentRoom.SetVisible(0);
                        }
                        Program.pl.currentRoom = temp;
                        Program.buffer.InsertText("Vas al sur");
                        Program.pl.lastRoom = 0;
                        return(true);
                    }
                    else
                    {
                        if (!Program.pl.GetMaldicion(4))
                        {
                            temp.SetVisible(1);
                        }
                        return(false);
                    }
                }
                else
                {
                    if (Program.pl.GetMaldicion(4))
                    {
                        Program.pl.currentRoom.SetVisible(0);
                    }
                    Program.pl.currentRoom = temp;
                    Program.buffer.InsertText("Vas al sur");
                    Program.pl.lastRoom = 0;
                    return(true);
                }
            }
            else
            {
                Program.buffer.InsertText("No hay habitación al sur");
                return(false);
            }
        }
Esempio n. 2
0
        public static bool MoveEast()
        {
            Room temp = Program.ObteJuego().pl.currentRoom.GetEastRoom();

            if (temp != null)
            {
                if (temp.GetType() == typeof(RoomClosed) && ((RoomClosed)temp).IsClosed())
                {
                    if (RoomClosed.UseKey())
                    {
                        ((RoomClosed)temp).OpenRoom();
                        if (Program.ObteJuego().pl.GetMaldicion(4))
                        {
                            Program.ObteJuego().pl.currentRoom.SetVisible(0);
                        }
                        Program.ObteJuego().pl.currentRoom = temp;
                        ConsoleBuffer.ObteBuffer().InsertText("Vas al este");
                        Program.ObteJuego().pl.lastRoom = 1;
                        return(true);
                    }
                    else
                    {
                        if (!Program.ObteJuego().pl.GetMaldicion(4))
                        {
                            temp.SetVisible(1);
                        }
                        return(false);
                    }
                }
                else
                {
                    if (Program.ObteJuego().pl.GetMaldicion(4))
                    {
                        Program.ObteJuego().pl.currentRoom.SetVisible(0);
                    }
                    Program.ObteJuego().pl.currentRoom = temp;
                    ConsoleBuffer.ObteBuffer().InsertText("Vas al este");
                    Program.ObteJuego().pl.lastRoom = 1;
                    return(true);
                }
            }
            else
            {
                ConsoleBuffer.ObteBuffer().InsertText("No hay habitación al este");
                return(false);
            }
        }
Esempio n. 3
0
 public void CloseRoom(Guid roomId)
 {
     new CloseRoomPacket(_streamWriter.BaseStream, roomId, Login).Send();
     _context.Post(p => RoomClosed?.Invoke(this, new RoomClosedEventHandlerArgs(roomId)), null);
 }
Esempio n. 4
0
        public static void StartLevel(int cantidad)
        {
            actualRooms = new List <Room>();
            List <Vector2> actualVectors;

            if (Program.ObteJuego().level > 5)
            {
                double prob = CustomMath.RandomUnit();
                if (prob < 95d / 300d)
                {
                    actualVectors = GenerateLevelVersion2(cantidad);
                }
                else if (prob < 190d / 300d)
                {
                    actualVectors = GenerateLevel(cantidad);
                }
                else if (prob < 285d / 300d)
                {
                    actualVectors = GenerateLevelVersion3(cantidad);
                }
                else
                {
                    actualVectors = GenerateLevelVersion4(cantidad);
                }
            }
            else
            {
                actualVectors = GenerateLevel(cantidad);
            }
            for (int i = 0; i < actualVectors.Count; i++)
            {
                actualRooms.Add(new Room(actualVectors[i].x, actualVectors[i].y));
            }
            //First Room is visible
            actualRooms[0].SetVisible(2);

            //SET DOORS
            for (int i = 0; i < actualRooms.Count; i++)
            {
                if (!(actualRooms[i].GetNorthRoom() != null && actualRooms[i].GetWestRoom() != null && actualRooms[i].GetSouthRoom() != null && actualRooms[i].GetEastRoom() != null))
                {
                    for (int j = i + 1; j < actualRooms.Count; j++)
                    {
                        if (actualRooms[i].GetNorthRoom() == null)
                        {
                            if (actualRooms[i].GetPosX() == actualRooms[j].GetPosX() && actualRooms[i].GetPosY() + 1 == actualRooms[j].GetPosY())
                            {
                                actualRooms[i].SetNorth(actualRooms[j]);
                                actualRooms[j].SetSouth(actualRooms[i]);
                            }
                        }
                        if (actualRooms[i].GetWestRoom() == null)
                        {
                            if (actualRooms[i].GetPosX() - 1 == actualRooms[j].GetPosX() && actualRooms[i].GetPosY() == actualRooms[j].GetPosY())
                            {
                                actualRooms[i].SetWest(actualRooms[j]);
                                actualRooms[j].SetEast(actualRooms[i]);
                            }
                        }
                        if (actualRooms[i].GetSouthRoom() == null)
                        {
                            if (actualRooms[i].GetPosX() == actualRooms[j].GetPosX() && actualRooms[i].GetPosY() - 1 == actualRooms[j].GetPosY())
                            {
                                actualRooms[i].SetSouth(actualRooms[j]);
                                actualRooms[j].SetNorth(actualRooms[i]);
                            }
                        }
                        if (actualRooms[i].GetEastRoom() == null)
                        {
                            if (actualRooms[i].GetPosX() + 1 == actualRooms[j].GetPosX() && actualRooms[i].GetPosY() == actualRooms[j].GetPosY())
                            {
                                actualRooms[i].SetEast(actualRooms[j]);
                                actualRooms[j].SetWest(actualRooms[i]);
                            }
                        }
                        if (actualRooms[i].GetNorthRoom() != null && actualRooms[i].GetWestRoom() != null && actualRooms[i].GetSouthRoom() != null && actualRooms[i].GetEastRoom() != null)
                        {
                            j = actualRooms.Count;
                        }
                    }
                }
            }

            /*--------------------------------------Crear salas especiales------------------------------------------*/
            List <Room> exitRooms = new List <Room>();
            /*se usa para la cantidad de puertas que debe tener una sala*/
            int temp = 3;

            do
            {
                for (int i = 1; i < actualRooms.Count; i++)
                {
                    int noDoors = 0;
                    if (actualRooms[i].GetEastRoom() == null)
                    {
                        noDoors++;
                    }

                    if (actualRooms[i].GetWestRoom() == null)
                    {
                        noDoors++;
                    }

                    if (actualRooms[i].GetNorthRoom() == null)
                    {
                        noDoors++;
                    }

                    if (actualRooms[i].GetSouthRoom() == null)
                    {
                        noDoors++;
                    }
                    if (noDoors == temp)
                    {
                        /*solo habitaciones con 3 salidas*/
                        exitRooms.Add(actualRooms[i]);
                    }
                }
                if (exitRooms.Count == 0)
                {
                    temp--;
                }
            } while (exitRooms.Count == 0);

            /*Salida_____________*/
            int  num  = CustomMath.RandomIntNumber(exitRooms.Count - 1);
            Room exit = exitRooms[num];

            exitRooms.RemoveAt(num);//Elimina la sala de las posibilidades de salida
            RoomExit texit = new RoomExit(exit.GetPosX(), exit.GetPosY());

            texit.SetEast(exit.GetEastRoom());
            texit.SetWest(exit.GetWestRoom());
            texit.SetNorth(exit.GetNorthRoom());
            texit.SetSouth(exit.GetSouthRoom());
            if (texit.GetNorthRoom() != null)
            {
                texit.GetNorthRoom().SetSouth(texit);
            }
            if (texit.GetSouthRoom() != null)
            {
                texit.GetSouthRoom().SetNorth(texit);
            }
            if (texit.GetWestRoom() != null)
            {
                texit.GetWestRoom().SetEast(texit);
            }
            if (texit.GetEastRoom() != null)
            {
                texit.GetEastRoom().SetWest(texit);
            }
            actualRooms.Remove(exit);
            actualRooms.Add(texit);

            /*Habitacion cerrada__________*/
            bool existsClosedRoom = false;

            if (temp == 3 && CustomMath.RandomUnit() < (Program.ObteJuego().level - 1) / 3f && exitRooms.Count > 0)
            {
                existsClosedRoom = true;
                num = CustomMath.RandomIntNumber(exitRooms.Count - 1); //num se esta reutilizando de salida
                Room tempRoom = exitRooms[num];
                exitRooms.RemoveAt(num);                               //Elimina la sala cerrada de las posibilidades
                Room newRoom;
                newRoom = new RoomClosed(tempRoom.GetPosX(), tempRoom.GetPosY());
                newRoom.SetEast(tempRoom.GetEastRoom());
                newRoom.SetWest(tempRoom.GetWestRoom());
                newRoom.SetNorth(tempRoom.GetNorthRoom());
                newRoom.SetSouth(tempRoom.GetSouthRoom());
                if (newRoom.GetNorthRoom() != null)
                {
                    newRoom.GetNorthRoom().SetSouth(newRoom);
                }
                if (newRoom.GetSouthRoom() != null)
                {
                    newRoom.GetSouthRoom().SetNorth(newRoom);
                }
                if (newRoom.GetWestRoom() != null)
                {
                    newRoom.GetWestRoom().SetEast(newRoom);
                }
                if (newRoom.GetEastRoom() != null)
                {
                    newRoom.GetEastRoom().SetWest(newRoom);
                }
                actualRooms.Remove(tempRoom);
                actualRooms.Add(newRoom);
            }

            /*Tesoro____________*/

            int          limit    = (Program.ObteJuego().level > 5)? 3 : (Program.ObteJuego().level + 1) / 2;
            RoomTreasure treasure = null;

            while (limit > 0)
            {
                num = CustomMath.RandomIntNumber(actualRooms.Count - 1, 1);//num se esta reutilizando de salida
                if (actualRooms[num].GetType() == typeof(Room))
                {
                    Room r = actualRooms[num];
                    treasure = new RoomTreasure(r.GetPosX(), r.GetPosY());
                    treasure.SetEast(r.GetEastRoom());
                    treasure.SetWest(r.GetWestRoom());
                    treasure.SetNorth(r.GetNorthRoom());
                    treasure.SetSouth(r.GetSouthRoom());
                    if (treasure.GetNorthRoom() != null)
                    {
                        treasure.GetNorthRoom().SetSouth(treasure);
                    }
                    if (treasure.GetSouthRoom() != null)
                    {
                        treasure.GetSouthRoom().SetNorth(treasure);
                    }
                    if (treasure.GetWestRoom() != null)
                    {
                        treasure.GetWestRoom().SetEast(treasure);
                    }
                    if (treasure.GetEastRoom() != null)
                    {
                        treasure.GetEastRoom().SetWest(treasure);
                    }
                    actualRooms.Remove(r);
                    actualRooms.Add(treasure);
                    limit--;
                }
            }
            if (CustomMath.RandomUnit() < 0.5)
            {
                RoomBless bless;
                Room      r;
                do
                {
                    r = actualRooms[CustomMath.RandomIntNumber(actualRooms.Count - 1, 1)];
                } while (r.GetType() != typeof(Room));

                bless = new RoomBless(r.GetPosX(), r.GetPosY());
                bless.SetEast(r.GetEastRoom());
                bless.SetWest(r.GetWestRoom());
                bless.SetNorth(r.GetNorthRoom());
                bless.SetSouth(r.GetSouthRoom());
                if (bless.GetNorthRoom() != null)
                {
                    bless.GetNorthRoom().SetSouth(bless);
                }
                if (bless.GetSouthRoom() != null)
                {
                    bless.GetSouthRoom().SetNorth(bless);
                }
                if (bless.GetWestRoom() != null)
                {
                    bless.GetWestRoom().SetEast(bless);
                }
                if (bless.GetEastRoom() != null)
                {
                    bless.GetEastRoom().SetWest(bless);
                }
                actualRooms.Remove(r);
                actualRooms.Add(bless);
            }
            /*Miscelaneous*/

            if (existsClosedRoom)
            {
                bool control = true;
                do
                {
                    num = CustomMath.RandomIntNumber(actualRooms.Count - 1, 1);
                    if (actualRooms[num].GetType() == typeof(Room))
                    {
                        actualRooms[num].GetItem(new Item("Llave vieja"));
                        control = false;
                    }
                } while (control);
            }
        }