public static void CaveLoop() { caveplace currPlace = new caveplace(); Main.Player.applybonus(); while (Main.Player.hp > 0) { Enemy enemy = new Enemy(); Main.Player.levelup(); currPlace = Map.cavemap[Map.CavePosition]; if (Main.Player.hp > Main.Player.maxhp) { Main.Player.hp = Main.Player.maxhp; } if (Combat.CheckBattle() && currPlace.getEnemyList() != null) { enemy = currPlace.getEnemyList(); Combat.BattleLoop(enemy); } if (!Main.devmode) { Main.Player.applybonus(); } else { Main.Player.applydevbonus(); } if (!Main.devmode) { Interface.type("-------------------------------------"); Interface.type(Main.Player.name + "(" + Main.Player.race + ")," + " Level " + Main.Player.level + " " + Main.Player.pclass + ":"); Interface.type("HP: " + Main.Player.hp + "/" + Main.Player.maxhp); Interface.type("Attack: " + Main.Player.atk + " / Defense: " + Main.Player.def + " / Speed: " + Main.spdbuff + " / Intelligence: " + Main.Player.intl); Interface.type("Mana: " + (1 + (Main.Player.intl / 10))); Interface.type("Gold: " + Main.Player.g + " / Exp to Level: " + (Main.Player.xp_next - Main.Player.xp)); Interface.type("-------------------------------------"); } if (!Main.devmode) { Interface.type(currPlace.Description); } else { Interface.type(currPlace.ToString()); } ConsoleKeyInfo command = Interface.readkey(); if (command.KeyChar == 'x') { Interface.type("\r\nAre you sure?"); char surecommand = Interface.readkey().KeyChar; if (surecommand == 'y') { End.GameOver(); } } else if (command.Key == ConsoleKey.Escape) { Environment.Exit(0); } else if (command.KeyChar == '-' && Main.devmode) { string input = Interface.readinput(); if (input == "e") { End.Endgame(); } else if (input == "c") { string combat_input = Interface.readinput(); Type etype = Type.GetType("Realm." + combat_input); Enemy e = (Enemy)Activator.CreateInstance(etype); Combat.BattleLoop(e); } else if (input == "n") { Main.Player.name = Interface.readinput(); } else if (input == "a") { string add_input = Interface.readinput(); Type atype = Type.GetType("Realm." + add_input); Item i = (Item)Activator.CreateInstance(atype); if (Main.Player.backpack.Count <= 10) { Main.Player.backpack.Add(i); } else { Interface.type("Not enough space."); } Interface.type("Obtained '" + i.name + "'!"); } else if (input == "p") { string p_input = Interface.readinput(); Type atype = Type.GetType("Realm." + p_input); Item i = (Item)Activator.CreateInstance(atype); Main.Player.primary = i; } else if (input == "t") { string place_input = Interface.readinput(); Type ptype = Type.GetType("Realm." + place_input); Place p = (Place)Activator.CreateInstance(ptype); } } else { currPlace.handleInput(command.KeyChar); } Main.loop_number++; } }
public static void MainLoop() { game_state = 0; Place currPlace; while (Player.hp > 0) { if (slimecounter == 100) { ach.Get("100slimes"); } if (goblincounter == 100) { ach.Get("100goblins"); } if (banditcounter == 100) { ach.Get("100bandits"); } if (drakecounter == 100) { ach.Get("100drakes"); } Tuple <int, int> xy = Map.CoordinatesOf(typeof(Nomad)); Map.map[xy.Item1, xy.Item2] = new Place(); Tuple <int, int> nextNomad = Map.getRandomBlankTile(); Map.map[nextNomad.Item1, nextNomad.Item2] = new Nomad(); foreach (Place p in Map.map) { if (p.GetType() == typeof(Place)) { p.is_npc_active = false; } } Tuple <int, int> randomTile = Map.getRandomBlankTile(); if (rand.NextDouble() <= .1) { Map.map[randomTile.Item1, randomTile.Item2].is_npc_active = true; } if (devmode) { Interface.type("Dev Powers!", ConsoleColor.DarkMagenta); Player.primary = new phantasmal_claymore(); Player.secondary = new spectral_bulwark(); Player.armor = new illusory_plate(); Player.accessory = new void_cloak(); hasmap = true; } Player.applybonus(); Enemy enemy = new Enemy(); Player.levelup(); currPlace = Map.map[Map.PlayerPosition.x, Map.PlayerPosition.y]; if (Player.hp > Player.maxhp) { Player.hp = Player.maxhp; } if (loop_number >= 1) { if (Combat.CheckBattle() && currPlace.getEnemyList() != null && !devmode) { enemy = currPlace.getEnemyList(); Combat.BattleLoop(enemy); } } Item pc = new phantasmal_claymore(); Item sb = new spectral_bulwark(); Item ip = new illusory_plate(); Item vc = new void_cloak(); if ((Player.backpack.Contains(pc) && Player.backpack.Contains(sb) && Player.backpack.Contains(ip) && Player.backpack.Contains(vc)) || devmode) { if (!Player.abilities.commandChars.Contains('*')) { Player.abilities.AddCommand(new Combat.EndtheIllusion("End the Illusion", '*')); } ach.Get("set"); } if (devmode) { Interface.type(Map.PlayerPosition.x + " " + Map.PlayerPosition.y); } if (!devmode) { Player.applybonus(); } else { Player.applydevbonus(); } if (gbooks >= 3 && !Player.abilities.commandChars.Contains('@')) { Interface.type("Having read all of the Ramsay books, you are enlightened in the ways of Gordon Ramsay."); Player.abilities.AddCommand(new Combat.HellsKitchen("Hell's Kitchen", '@')); } if (!devmode) { Interface.type(currPlace.Description); } else { Interface.type(currPlace.ToString()); } char[] currcommands = currPlace.getAvailableCommands(); Interface.typeOnSameLine("\r\nYour current commands are x", ConsoleColor.Cyan); foreach (char c in currcommands) { Interface.typeOnSameLine(", " + c, ConsoleColor.Cyan); } Interface.type(""); ConsoleKeyInfo command = Interface.readkey(); if (command.KeyChar == 'x') { Interface.type("\r\nAre you sure?", ConsoleColor.Red); char surecommand = Interface.readkey().KeyChar; if (surecommand == 'y') { End.GameOver(); } } else if (command.Key == ConsoleKey.Escape) { Environment.Exit(0); } else if (command.KeyChar == '-' && devmode) { string input = Interface.readinput(); if (input == "end") { End.Endgame(); } else if (input == "combat") { string combat_input = Interface.readinput(); Type etype = Type.GetType("Realm." + combat_input); try { Enemy e = (Enemy)Activator.CreateInstance(etype); Combat.BattleLoop(e); } catch (ArgumentNullException) { Interface.type("Invalid Enemy."); } } else if (input == "name") { Player.name = Interface.readinput(); } else if (input == "additem") { string add_input = Interface.readinput(); Type atype = Type.GetType("Realm." + add_input); try { Item i = (Item)Activator.CreateInstance(atype); if (Player.backpack.Count <= 10) { Player.backpack.Add(i); Interface.type("Obtained '" + i.name + "'!"); } else { Interface.type("Not enough space."); } } catch (ArgumentNullException) { Interface.type("Invalid Item."); } } else if (input == "droploot") { if (Main.rand.NextDouble() <= .1d) { Main.Player.backpack.Add(MainItemList[Main.rand.Next(0, MainItemList.Count - 1)]); Interface.type("Obtained " + MainItemList[Main.rand.Next(0, MainItemList.Count - 1)].name + "!", ConsoleColor.Green); } else { Interface.type("Nothing dropped."); } } else if (input == "teleport") { int xcoord = Int32.Parse(Interface.readinput()); int ycoord = Int32.Parse(Interface.readinput()); Map.PlayerPosition.x = xcoord; Map.PlayerPosition.y = ycoord; } else if (input == "level") { Main.Player.level = Convert.ToInt32(Interface.readinput()); } else if (input == "levelup") { Main.Player.xp += Main.Player.xp_next; } else if (input == "getach") { ach.Get(Interface.readinput()); } else if (input == "suicide") { End.GameOver(); } } else { currPlace.handleInput(command.KeyChar); } loop_number++; } }