public Enemigo(DatoEnemigo datoEnemigo, int level) { this.level = level; nombre = datoEnemigo.nombre; hpM = (int)((datoEnemigo.hpM * level / 100 + 10)); hp = hpM; att = (int)((6 + datoEnemigo.att * level / 100) * (1 - CustomMath.RandomUnit() * 0.1f)); def = (int)((5 + datoEnemigo.def * level / 100) * (1 - CustomMath.RandomUnit() * 0.1f)); speed = (int)((5 + datoEnemigo.speed * level / 100) * (1 - CustomMath.RandomUnit() * 0.1f)); manaM = (int)((5 + datoEnemigo.manaM * level / 100) * (1 - CustomMath.RandomUnit() * 0.1f)); mana = manaM; attMa = (int)((5 + datoEnemigo.attMa * level / 100) * (1 - CustomMath.RandomUnit() * 0.1f)); avoidPerc = datoEnemigo.avoidPerc; hitPerc = datoEnemigo.hitPerc; }
public int ReceiveDamage(int att, int def, bool notRandom = false) { int damage; if (notRandom) { damage = (int)(Math.Sin(Math.Atan2(att, def)) * att); } else { damage = (int)(Math.Sin(Math.Atan2(att, def)) * att * (1 - (CustomMath.RandomIntNumber(20, 0) / 200f))); } damage = (damage == 0) ? 1 : damage; hp -= damage; return(damage); }
/*_____________Maldiciones_______________*/ public void ObtenMaldicion() { bool maldito = true; for (int i = 0; i < mal.Length; i++) { if (mal[i] == null) { maldito = false; } } if (maldito == false) { Maldicion temp = new Maldicion(CustomMath.RandomIntNumber(Maldicion.cantidadMaldiciones - 1)); for (int i = 0; i < mal.Length; i++) { if (mal[i] != null && temp.GetId() == mal[i].GetId()) { temp = new Maldicion(CustomMath.RandomIntNumber(Maldicion.cantidadMaldiciones - 1)); i = -1; } } Program.buffer.InsertText("Has obtenido la " + temp.GetName()); for (int i = 0; i < mal.Length; i++) { if (mal[i] == null) { mal[i] = temp; i = mal.Length; } } } else { Program.buffer.InsertText("Tienes tantas maldiciones que tu cuerpo no es capaz de aguantar más"); ExcesoMaldito++; Program.buffer.InsertText("Has perdido parte de tu vida maxima"); if (GetMHealth() <= 0) { Program.buffer.InsertText("El peso de las maldiciones exprime tu ultima gota de tu alma"); Program.buffer.InsertText("Caes muerto en el suelo"); Program.buffer.InsertText("Pulsa cualquier boton para continuar"); Console.ReadKey(); } } }
public void InsertText(string newText) { if (Program.pl.GetMaldicion(0)) { string prohibido = "\"\\<>|[]0987654321¿?!¡,;.:'_-+*()"; string[] mald = newText.Split(' '); newText = ""; for (int i = 0; i < mald.Length; i++) { if (mald[i].Length >= 3) { int numeroCoin = 0; for (int j = 0; j < mald[i].Length; j++) { for (int k = 0; k < prohibido.Length; k++) { if (prohibido[k] == mald[i][j]) { numeroCoin++; k = prohibido.Length; } } } if (numeroCoin != mald[i].Length) { int r1, r2; bool check; do { check = false; r1 = CustomMath.RandomIntNumber(mald[i].Length - 1); for (int j = 0; j < prohibido.Length; j++) { if (mald[i][r1] == prohibido[j]) { check = true; } } } while (check); do { check = false; r2 = CustomMath.RandomIntNumber(mald[i].Length - 1); for (int j = 0; j < prohibido.Length; j++) { if (mald[i][r2] == prohibido[j]) { check = true; } } } while (check); char temp = mald[i][r1]; if (r1 + 1 < mald[i].Length) { mald[i] = mald[i].Substring(0, r1) + mald[i][r2] + mald[i].Substring(r1 + 1); } else { mald[i] = mald[i].Substring(0, r1) + mald[i][r2]; } if (r2 + 1 < mald[i].Length) { mald[i] = mald[i].Substring(0, r2) + temp + mald[i].Substring(r2 + 1); } else { mald[i] = mald[i].Substring(0, r2) + temp; } } } newText += mald[i]; if (i + 1 < mald.Length) { newText += " "; } } } if (newText.Length > width - 22) { for (int i = textBox.Length - 1; i >= 1; i--) { textBox[i] = textBox[i - 1]; } int limit = newText.Length - 1; while (limit >= 0 && (limit > width - 22 || !newText[limit].Equals(' '))) { limit--; } if (limit == -1 || limit == 0) { textBox[0] = newText.Substring(limit + 1, width - 22); InsertText(newText.Substring(width - 22)); } else { textBox[0] = newText.Substring(0, limit); InsertText(newText.Substring(limit)); } } else { for (int i = textBox.Length - 1; i >= 1; i--) { textBox[i] = textBox[i - 1]; } textBox[0] = newText; } }
public static string RandomDescr(string path) { string[] frases = ReadFile(path); return(frases[CustomMath.RandomIntNumber(frases.Length - 1)]); }
//pantalla principal, donde pasa toda la magia public static void MainScreen() { CommandMethod method; string textInput; //Dibuja el fondo de primeras buffer.Print(1, 0, "PRINCIPAL"); buffer.PrintBackground(); buffer.InsertText(pl.currentRoom.GetDescriptionTotal()); buffer.PrintText(height - 3); SmallMap(); buffer.PrintScreen(); do { //Pon el cursos en la posicion de escribir Console.SetCursorPosition(1, 18); //Espera input textInput = Console.ReadLine(); //Espacio para facilitar lectura buffer.InsertText(""); //Lo inserta en el lineTexto buffer.InsertText(textInput); //Si el comando es valido if (Comando.CheckCommand(textInput)) { // obten el metodo method = Comando.ReturnCommand(textInput); //si ha obtenido metodo if (method != null) { bool temp = method(); if ((method.Method.Name.Equals("MoveNorth") || method.Method.Name.Equals("MoveSouth") || method.Method.Name.Equals("MoveWest") || method.Method.Name.Equals("MoveEast")) && temp) { pl.currentRoom.SetVisible(2); if (pl.GetMaldicion(1)) { if (pl.GetHealth() > 1 && CustomMath.RandomUnit() < 0.1f) { buffer.InsertText("Te has tropezado y has perdido 1 punto de vida"); pl.ReceiveDamage(1, 0); } } if (pl.currentRoom.ene != null) { buffer.InsertText("Un enemigo ha aparecido"); buffer.Print(1, 0, "PRINCIPAL"); buffer.PrintBackground(); buffer.PrintText(17); SmallMap(); buffer.PrintScreen(); Console.ReadKey(); ConsoleBuffer cbMain = buffer; buffer = new ConsoleBuffer(width, height, height - 5); inCombat = true; EscenaCombate.Combate(pl.currentRoom.ene); inCombat = false; buffer = cbMain; if (pl.IsDead()) { textInput = "exit"; } } buffer.InsertText(pl.currentRoom.GetDescriptionTotal()); } } else { //En caso contrario avisa buffer.InsertText("Not implemented"); } } else { buffer.InsertText("Comando no valido"); } if (goNextLevel) { level++; goNextLevel = false; // hola Level.StartLevel(GetRoomsPerLevel()); lvlLayout = Level.actualRooms; pl.currentRoom = lvlLayout[0]; buffer.ClearBox(); if (pl.GetMaldicion(3)) { if (CustomMath.RandomUnit() < 0.5) { buffer.InsertText("Tu invalidez ha hecho que ruedes escaleras abajo de manera muy sonora y cómica. Milagrosamente no has recibido ningún daño. La escalera por la que has rebotado se ha destruido"); } else { buffer.InsertText("Tu invalidez ha hecho que tus piernas dejen de responder y tengas que bajar usando las manos. Después de media hora has conseguido bajar. Al tocar el suelo del siguiente piso tus piernas vuelven a responder. La escalera por la que te has arrastrado se ha destruido"); } } else { buffer.InsertText("Cuando bajas escuchas un fuerte estruendo. Al mirar arriba las escaleras acaban en el techo de la sala"); } buffer.InsertText(pl.currentRoom.GetDescriptionTotal()); if (pl.GetMaldicion(4)) { buffer.InsertText("Sientes como un peso se levanta de ti"); for (int i = 0; i < pl.GetArrMal().Length; i++) { if (pl.GetArrMal()[i].GetId() == 4) { pl.GetArrMal()[i] = null; i = pl.GetArrMal().Length; } } } } buffer.Print(1, 0, "PRINCIPAL"); buffer.PrintBackground(); buffer.PrintText(17); SmallMap(); buffer.PrintScreen(); } while (!textInput.Equals("exit") && !pl.IsDead()); }
private static void AtaqueDirigidoA(CombatClass atacante, CombatClass defensor, int hab = -1) { if (!atacante.IsDead()) { float rand = (float)CustomMath.RandomUnit(); float acc = atacante.GetHitPerc() + rand; if (hab == 3) { acc /= 2; } else if (hab == 4) { acc = 1; } if (acc >= defensor.GetAvoidPerc()) { int ataque = atacante.GetAtt(); int defensa = defensor.GetDef(); if (hab == -2) { defensa = (int)(defensa * 1.5); } else if (hab == 1) { ataque = (int)(ataque * 1.5); } else if (hab == 3) { ataque = ataque * 3; } else if (hab == 4) { ataque = CustomMath.RandomIntNumber(3, 1) + atacante.GetAttMa() / 2; defensa = 0; } int danorecibido = defensor.ReceiveDamage(ataque, defensa, (hab == 4)); try { if (atacante.GetType() == typeof(Player)) { buffer.InsertText("Has hecho " + danorecibido + " de daño a " + ((Enemigo)defensor).GetName()); } else { if (pl.GetMaldicion(5)) { danorecibido = CustomMath.RandomIntNumber(10000, 5000); buffer.InsertText(((Enemigo)atacante).GetName() + " te ha hecho " + danorecibido + " de daño"); } else { buffer.InsertText(((Enemigo)atacante).GetName() + " te ha hecho " + danorecibido + " de daño"); } } }catch (InvalidCastException e) { buffer.InsertText("Error: " + e.Message); buffer.InsertText("atacante: " + atacante.GetType().ToString()); buffer.InsertText("defensor: " + defensor.GetType().ToString()); } } else { if (atacante.GetType() == typeof(Player)) { buffer.InsertText("¡Has fallado!"); } else { buffer.InsertText("¡" + ((Enemigo)atacante).GetName() + " ha fallado!"); } } } }
private static void Attack(Player pl, Enemigo ene, int hab = -1) { if (pl.GetSpeed() > ene.GetSpeed()) { //Jugador Ataca NombreHabilidad(hab); if (hab == 0) { AtaqueDirigidoA(pl, ene, hab); } else if (hab == 2) { int rstH = 5 + pl.GetAttMa(); pl.RestoreHealth(rstH); if (pl.GetHealth() == pl.GetMHealth()) { buffer.InsertText("¡Te has recuperado al máximo!"); } } else if (hab == 4) { AtaqueDirigidoA(pl, ene, hab); AtaqueDirigidoA(pl, ene, hab); } if (hab != 2) { AtaqueDirigidoA(pl, ene, hab); } //Enemigo Ataca AtaqueDirigidoA(ene, pl); } else if (pl.GetSpeed() < ene.GetSpeed()) { //Enemigo Ataca AtaqueDirigidoA(ene, pl); //Jugador Ataca NombreHabilidad(hab); if (hab == 0) { AtaqueDirigidoA(pl, ene, hab); } else if (hab == 2) { int rstH = 5 + pl.GetAttMa(); pl.RestoreHealth(rstH); if (pl.GetHealth() == pl.GetMHealth()) { buffer.InsertText("¡Te has recuperado al máximo!"); } } else if (hab == 4) { AtaqueDirigidoA(pl, ene, hab); AtaqueDirigidoA(pl, ene, hab); } if (hab != 2) { AtaqueDirigidoA(pl, ene, hab); } } else { if (CustomMath.RandomUnit() < 0.5) { //Jugador Ataca NombreHabilidad(hab); if (hab == 0) { AtaqueDirigidoA(pl, ene, hab); } else if (hab == 2) { int rstH = 5 + pl.GetAttMa(); pl.RestoreHealth(rstH); if (pl.GetHealth() == pl.GetMHealth()) { buffer.InsertText("¡Te has recuperado al máximo!"); } } else if (hab == 4) { AtaqueDirigidoA(pl, ene, hab); AtaqueDirigidoA(pl, ene, hab); } if (hab != 2) { AtaqueDirigidoA(pl, ene, hab); } //Enemigo Ataca AtaqueDirigidoA(ene, pl); } else { //Enemigo Ataca AtaqueDirigidoA(ene, pl); //Jugador Ataca NombreHabilidad(hab); if (hab == 0) { AtaqueDirigidoA(pl, ene, hab); } else if (hab == 2) { int rstH = 5 + pl.GetAttMa(); pl.RestoreHealth(rstH); if (pl.GetHealth() == pl.GetMHealth()) { buffer.InsertText("¡Te has recuperado al máximo!"); } } else if (hab == 4) { AtaqueDirigidoA(pl, ene, hab); AtaqueDirigidoA(pl, ene, hab); } if (hab != 2) { AtaqueDirigidoA(pl, ene, hab); } } } }
public static void Combate(Enemigo ene) { StartCombate(); buffer.InsertText("¡Ha aparecido un " + ene.GetName() + "!"); BackgroundCombat(); string[] comandos = { "atacar", "defender", "huir", "consumir", "habilidad" }; bool huir = false; int itemHuir = -1; while (!(pl.IsDead() || ene.IsDead() || huir)) { Console.SetCursorPosition(1, 18); string decide = Console.ReadLine().ToLower(); buffer.InsertText(""); buffer.InsertText(decide); if (decide.Equals(comandos[0])) { Attack(pl, ene); } else if (decide.Equals(comandos[1])) { buffer.InsertText("Te has puesto en guardia"); AtaqueDirigidoA(ene, pl, -2); } else if (decide.Equals(comandos[2])) { float rand = (float)CustomMath.RandomUnit(); float probHuida = (pl.GetMaldicion(3)) ? 0.25f + pl.GetSpeed() / (float)(2 * (pl.GetSpeed() + ene.GetSpeed())) : 0.25f + pl.GetSpeed() / (float)(pl.GetSpeed() + ene.GetSpeed()); if (rand < probHuida) { buffer.InsertText("¡Has huido!"); huir = true; } else { if (pl.GetMaldicion(3) && rand < (probHuida - 0.25f) * 2 + 0.25f) { buffer.InsertText("Notas como las piernas no te responden y eres incapaz de moverte"); } else { buffer.InsertText("¡No has podido huir!"); AtaqueDirigidoA(ene, pl); } } } else if (decide.Equals(comandos[3])) { int i = Comando.ConsumeItemCombat(); if (i > -1) { if (pl.GetBag()[i].GetType() == typeof(ItemScroll)) { ItemScroll itemScroll = (ItemScroll)pl.GetBag()[i]; if (itemScroll.GetId() == 1) { itemHuir = i; huir = true; } } if (itemHuir == -1) { pl.ConsumeItem(i); AtaqueDirigidoA(ene, pl); } } } else if (decide.Equals(comandos[4])) { buffer.InsertText("¿Que habilidad quieres usar?"); buffer.InsertText("[0]-> Ataque Veloz [1]-> Golpe Aplastador [2]-> Curación Menor [3]-> MegaGolpe [4]-> Dardos Mágicos"); buffer.Print(1, buffer.height - 2, ">"); BackgroundCombat(); Console.SetCursorPosition(2, Program.buffer.height - 2); bool obj = int.TryParse(Console.ReadLine(), out int num); if (!obj) { Program.buffer.InsertText("Solo acepta numeros"); } else if (num >= 0 && num <= 4) { bool used = true; if (num == 0 && pl.GetMana() - 10 >= 0) { pl.SetMana(pl.GetMana() - 10); } else if (num == 1 && pl.GetMana() - 5 >= 0) { pl.SetMana(pl.GetMana() - 5); } else if (num == 2 && pl.GetMana() - 5 >= 0) { pl.SetMana(pl.GetMana() - 5); } else if (num == 3 && pl.GetMana() - 10 >= 0) { pl.SetMana(pl.GetMana() - 10); } else if (num == 4 && pl.GetMana() - 10 >= 0) { pl.SetMana(pl.GetMana() - 10); } else { buffer.InsertText("No tienes suficiente maná"); used = false; } if (used) { Attack(pl, ene, num); } } else { Program.buffer.InsertText("Ese número no es válido"); } } else { buffer.InsertText("Comando no valido"); } BackgroundCombat(); } if (pl.IsDead()) { buffer.InsertText("Has muerto..."); } else if (ene.IsDead()) { buffer.InsertText(""); int exp = 5 + 3 * ene.GetLevel(); buffer.InsertText("¡Has derrotado a " + ene.GetName() + "!"); int money = CustomMath.RandomIntNumber(5 + 5 * Program.GetLevel(), 5 + 2 * Program.GetLevel()); buffer.InsertText("Has conseguido " + money + " monedas"); pl.GainMoney(money); pl.currentRoom.ene = null; } if (huir && itemHuir == -1) { ene.RestoreHealth(); pl.currentRoom.SetVisible(1); switch (pl.lastRoom) { case 0: Comando.MoveNorth(); break; case 1: Comando.MoveWest(); break; case 2: Comando.MoveSouth(); break; case 3: Comando.MoveEast(); break; default: throw new Exception("Error a la hora de huir"); } } else if (huir) { ene.RestoreHealth(); pl.ConsumeItem(itemHuir); } buffer.InsertText("pulsa cualquier boton para continuar"); BackgroundCombat(); Console.ReadKey(); }
public static List <Vector2> GenerateLevelVersion4(int cantidad) { List <Vector2> actualVectors = new List <Vector2>(); List <Vector2> posibilidades = new List <Vector2>() { new Vector2(0, 0) }; while (actualVectors.Count < cantidad) { //Paso 3.1 Vector2 vv, vv1, vv2, vh1, vh2; //Paso 1 -- Añade sala aleatoria de lista de posibilidades int index = CustomMath.RandomIntNumber(posibilidades.Count - 1); actualVectors.Add(posibilidades[index]); //paso 3.2 vv = posibilidades[index]; vv1 = new Vector2(vv.x, vv.y - 1); vv2 = new Vector2(vv.x, vv.y + 1); vh1 = new Vector2(vv.x - 1, vv.y); vh2 = new Vector2(vv.x + 1, vv.y); //Paso 2 -- Borra la sala añadida de la lista de posibilidades posibilidades.RemoveAt(index); //Paso 3 -- quita las no posibles de la lista for (int i = 0; i < posibilidades.Count; i++) { if (posibilidades[i].Equals(vv1) || posibilidades[i].Equals(vv2) || posibilidades[i].Equals(vh1) || posibilidades[i].Equals(vh2)) { posibilidades.RemoveAt(i); } } bool up = true, down = true, left = true, right = true; for (int i = 0; i < actualVectors.Count; i++) { if (up) { if (actualVectors[i].Equals(vv2)) { up = false; } } if (down) { if (actualVectors[i].Equals(vv1)) { down = false; } } if (right) { if (actualVectors[i].Equals(vh2)) { right = false; } } if (left) { if (actualVectors[i].Equals(vh1)) { left = false; } } } if (up) { posibilidades.Add(vv2); } if (right) { posibilidades.Add(vh2); } if (down) { posibilidades.Add(vv1); } if (left) { posibilidades.Add(vh1); } } return(actualVectors); }
public static void StartLevel(int cantidad) { actualRooms = new List <Room>(); List <Vector2> actualVectors; if (Program.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.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); } List <Room> normalRooms = new List <Room>(); foreach (Room n in actualRooms) { if (n.GetType() == typeof(Room)) { normalRooms.Add(n); } } /*Tesoro____________*/ int limit = (Program.level > 5) ? 3 : (Program.level + 1) / 2; RoomGema gema = null; while (limit > 0 && normalRooms.Count > 0) { num = CustomMath.RandomIntNumber(actualRooms.Count - 1, 1);//num se esta reutilizando de salida if (normalRooms.Contains(actualRooms[num])) { Room r = actualRooms[num]; gema = new RoomGema(r.GetPosX(), r.GetPosY()); gema.SetEast(r.GetEastRoom()); gema.SetWest(r.GetWestRoom()); gema.SetNorth(r.GetNorthRoom()); gema.SetSouth(r.GetSouthRoom()); if (gema.GetNorthRoom() != null) { gema.GetNorthRoom().SetSouth(gema); } if (gema.GetSouthRoom() != null) { gema.GetSouthRoom().SetNorth(gema); } if (gema.GetWestRoom() != null) { gema.GetWestRoom().SetEast(gema); } if (gema.GetEastRoom() != null) { gema.GetEastRoom().SetWest(gema); } actualRooms.Remove(r); normalRooms.Remove(r);//Eliminalo de las posibles posiciones actualRooms.Add(gema); limit--; } } limit = (Program.level > 9) ? 3 : (Program.level) / 3; RoomTreasure treasure = null; while (limit > 0 && normalRooms.Count > 0) { num = CustomMath.RandomIntNumber(actualRooms.Count - 1, 1);//num se esta reutilizando de salida if (normalRooms.Contains(actualRooms[num])) { 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); normalRooms.Remove(r);//Eliminalo de las posibles posiciones 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); normalRooms.Remove(r); actualRooms.Add(bless); } /*Miscelaneous*/ if (existsClosedRoom) { bool control = true; do { num = CustomMath.RandomIntNumber(normalRooms.Count - 1, 1); if (actualRooms[num].GetType() != typeof(RoomClosed)) { control = !actualRooms[num].GetItem(new Item("Llave vieja")); } } while (control); } int maxEnemies = (int)(Program.level + 0.16 * Program.level * Program.level); for (int i = 0; i < maxEnemies; i++) { int x = CustomMath.RandomIntNumber(normalRooms.Count - 1, 1); normalRooms[x].ene = new Enemigo(Enemigo.eneList[CustomMath.RandomIntNumber(Enemigo.eneList.Length - 1)], Program.level); normalRooms.RemoveAt(x); } }