Example #1
0
 public static void Initialize()
 {
     FileIO.checkver();
     File.Delete(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\test.exe");
     Console.Title = "Realm: " + Interface.GetTitle();
     Interface.type(Main.version, ConsoleColor.White);
     Map.gencave();
     Achievement.LoadAchievements();
     if (!Save.LoadGame())
     {
         Interface.type("\"Greetings. Before we begin, I must know your name.\"");
         Interface.type("Please enter your name. ");
         Main.Player.name = Interface.readinput(true);
         if (Main.devmode)
         {
             Console.Clear();
             Main.Player.race   = Interface.readinput();
             Main.Player.pclass = Interface.readinput();
         }
         Main.ach.Get("name");
         Main.Tutorial();
     }
     else
     {
         Main.MainLoop();
     }
 }
Example #2
0
        public static void Tutorial()
        {
            List <string> racelist = new List <string> {
                "human", "elf", "rockman", "giant", "zephyr", "shade"
            };
            List <string> classlist = new List <string> {
                "warrior", "paladin", "mage", "thief"
            };
            List <string> secret = new List <string>();

            if (achieve["100slimes"])
            {
                secret.Add("Slime");
            }
            if (achieve["100goblins"])
            {
                secret.Add("Goblin");
            }
            if (achieve["100bandits"])
            {
                secret.Add("Bandit");
            }
            if (achieve["100drakes"])
            {
                secret.Add("Drake");
            }
            is_typing = true;
            Interface.type("Welcome, ");
            Interface.typeOnSameLine(Player.name, ConsoleColor.White);
            Interface.typeOnSameLine(", to Realm.");
            if (achieve["finalboss"])
            {
                Player.backpack.Add(new nightbringer());
            }
            if (!devmode)
            {
                Interface.type("Skip the tutorial? (y/n)");
                if (Interface.readkey().KeyChar == 'n')
                {
                    Interface.type("To do anything in Realm, simply press one of the listed commands.");
                    Interface.type("If at any time, you wish to you view you stats, press 'v'");
                    Interface.type("Make sure to visit every library! They offer many valuable abilities as well as experience.");
                    Interface.type("When in combat, select an availible move. All damage is randomized. Mana is refilled after each fight.");
                    Interface.type("While in the backpack, simply select a number corresponding to an item. You may swap this item in or out. Make sure to equip an item once you pick it up!");
                    Interface.type("At any specified time, you may press x, then y. This will cause you to commit suicide.");
                    Interface.type("At any specified time, you may press #. Doing so will save the game.");
                }
                Interface.type("In Realm, every player selects a race. Each race gives its own bonuses. You may choose from Human, Elf, Rockman, Giant, Zephyr, or Shade.");
                if (achieve["100slimes"] || achieve["100goblins"] || achieve["100bandits"] || achieve["100drakes"])
                {
                    Interface.type("Secret Races: ", ConsoleColor.Yellow);
                    for (int i = 0; i < secret.Count; i++)
                    {
                        if (i > 1)
                        {
                            Interface.typeOnSameLine(", ", ConsoleColor.Yellow);
                        }
                        Interface.type(secret[i], ConsoleColor.Yellow);
                    }
                    foreach (string s in secret)
                    {
                        racelist.Add(s);
                    }
                }
                Interface.type("Please enter a race. ");
                is_typing = false;
                string race = Interface.readinput();
                while (!racelist.Contains(race))
                {
                    Interface.type("Invalid. Please try again. ");
                    race = Interface.readinput();
                }
                Player.race = race;
                Interface.type("You have selected " + Interface.ToUpperFirstLetter(Player.race) + ".", ConsoleColor.Magenta);
                Interface.type("Each player also has a class. You may choose from Warrior, Paladin, Mage, or Thief.");
                Interface.type("Please enter a class. ");
                string pclass = Interface.readinput();
                while (!classlist.Contains(pclass))
                {
                    Interface.type("Invalid. Please try again. ");
                    pclass = Interface.readinput();
                }
                Player.pclass = pclass;
                Interface.type("You have selected " + Interface.ToUpperFirstLetter(Player.pclass) + ".", ConsoleColor.Magenta);
                Interface.type("You are now ready to play Realm. Good luck!");
                Interface.type("Press any key to continue.", ConsoleColor.White);
                Interface.readkey();
                Map.PlayerPosition.x = 0;
                Map.PlayerPosition.y = 6;
                if (Player.race == "giant")
                {
                    Player.hp = 15;
                }
            }
            MainLoop();
        }
Example #3
0
        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++;
            }
        }
Example #4
0
        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++;
            }
        }