Exemplo n.º 1
0
 public RoomEditor()
 {
     game.rooms     = new List <Room>();
     game.creatures = new List <Creature>();
     game.rooms.Add(new Room("First Room", "First Room Description", 0, -1, -1, -1, -1));
     currentroom = 0;
     nextroom    = 0;
     saver       = new SaveMaker();
 }
Exemplo n.º 2
0
        public bool LoadRoomFile()
        {
            bool      success  = false;
            bool      finished = false;
            bool      picked   = false;
            string    gamefilename;
            SaveMaker saver = new SaveMaker();

            while (!finished)
            {
                Console.Write("\nWhat Game File?");

                gamefilename = Console.ReadLine();
                if (Utility.NotBlank(gamefilename))
                {
                    gamefilename += ".game";
                    if (File.Exists(gamefilename))
                    {
                        game = saver.LoadGameData(game, gamefilename);
                        Console.Write("\nGame file loaded!\n");
                        success  = true;
                        finished = true;
                    }
                    else
                    {
                        while (!picked)
                        {
                            Console.Write("\nFile does not exist.  Try again?");
                            choice = Console.ReadLine();
                            if (Utility.WordMatch(choice, "yes", picked))
                            {
                                picked   = true;
                                success  = false;
                                finished = false;
                            }
                            if (Utility.WordMatch(choice, "no", picked))
                            {
                                picked   = true;
                                success  = false;
                                finished = true;
                            }
                        }
                    }
                }
                else
                {
                    while (!picked)
                    {
                        Console.Write("\nNo name entered.  Try again?");
                        choice = Console.ReadLine();
                        if (Utility.WordMatch(choice, "yes", picked))
                        {
                            picked   = true;
                            success  = false;
                            finished = false;
                        }
                        if (Utility.WordMatch(choice, "no", picked))
                        {
                            picked   = true;
                            success  = false;
                            finished = true;
                        }
                    }
                }
            }
            return(success);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            SaveMaker saver     = new SaveMaker();
            string    choice    = "";
            string    option    = "";
            Adventure adventure = new Adventure();
            bool      picked    = false;

            int       strlen;
            Character character = new Character();

            while (!Utility.WordMatch(choice, "exit", picked))
            {
                Console.Write("NEW - create a new character\nVIEW - view current character\nLOAD - load previous character\nROOM - enter the room editor\nITEM - enter the item editor\nEXIT - exit game\nCREATURE - enter the creature editor\nBEGIN - begin adventure\n\nWelcome to Garlos.  What will you do?");
                choice = Console.ReadLine();
                strlen = choice.Length;

                if (Utility.WordMatch(choice, "view", picked))
                {
                    character.DisplayStats();
                    picked = true;
                }
                if (Utility.WordMatch(choice, "new", picked))
                {
                    Console.WriteLine("You will begin a new character!");
                    if (Utility.KeyWord(choice, "game"))
                    {
                        Console.WriteLine("game chosen??");
                        Console.ReadLine();
                    }
                    character.NewCharacter();

                    picked = true;
                }
                if (Utility.WordMatch(choice, "load", picked))
                {
                    if (Utility.NotBlank(Utility.GetKeyWord(choice)))
                    {
                        option = Utility.GetKeyWord(choice);
                    }
                    else
                    {
                        Console.Write("\nLoad which character?");
                        option = Console.ReadLine();
                    }
                    option += ".character";
                    if (Utility.NotBlank(option))
                    {
                        if (File.Exists(option))
                        {
                            try
                            {
                                Console.WriteLine("Your character will be loaded!");
                                character = saver.LoadData(character, option);
                                character.refreshequipped();
                                character.DisplayStats();
                            }
                            catch
                            {
                                Console.WriteLine("\nNot a valid character file!\n");
                            }
                        }
                        else
                        {
                            Console.WriteLine("\nCharacter does not exit.\n");
                        }
                    }
                    picked = true;
                }
                if (Utility.WordMatch(choice, "room", picked))
                {
                    Console.WriteLine("OK lets edit rooms!");
                    RoomEditor roomy = new RoomEditor();
                    Console.WriteLine("Welcome to Edit Mode.\n");
                    roomy.LoadFile();
                    roomy.MainMenu();
                    picked = true;
                }
                if (Utility.WordMatch(choice, "item", picked))
                {
                    Console.WriteLine("OK lets edit items!");
                    ItemEditor itemy = new ItemEditor();
                    Console.WriteLine("Welcome to Edit Mode.\n");
                    itemy.LaunchEditor();
                    itemy.MainMenu();
                    picked = true;
                }
                if (Utility.WordMatch(choice, "creature", picked))
                {
                    Console.WriteLine("OK lets edit creatures!");
                    CreatureEditor creaturey = new CreatureEditor();
                    Console.WriteLine("Welcome to Edit Mode.\n");
                    creaturey.LaunchEditor();
                    creaturey.MainMenu();
                    picked = true;
                }
                if (Utility.WordMatch(choice, "begin", picked))
                {
                    Console.WriteLine("Time to begin the adventure!");
                    if (adventure.LoadRoomFile())
                    {
                        Console.WriteLine("GET READY!!");
                        adventure.BeginAdventure(character);
                        adventure.Explore();
                    }
                    picked = true;
                }

                picked = false;
            }
        }
Exemplo n.º 4
0
        public void NewCharacter()
        {
            inventory.Clear();
            weapon = null;
            armor  = null;
            shield = null;
            SaveMaker saver = new SaveMaker();
            string    choice;
            bool      picked  = false;
            string    mychar  = "";
            bool      confirm = false;

            while (string.IsNullOrWhiteSpace(mychar))
            {
                Console.Write("Welcome to Garlos, what is yon name? ");
                mychar = Console.ReadLine();
            }
            name = mychar;
            //Character character = new Character();
            reset();
            Console.WriteLine("Welcome " + name + "\nYour starting stats are as follows:\n");
            while (!confirm)
            {
                while (statpoints > 0)
                {
                    Console.WriteLine("HP: " + hp + "/" + maxhp);
                    Console.WriteLine("MP: " + mp + "/" + maxmp);
                    Console.WriteLine("Strength:     " + str);
                    Console.WriteLine("Dexterity:    " + dex);
                    Console.WriteLine("Wisdom:       " + wis);
                    Console.WriteLine("Constitution: " + con);
                    Console.WriteLine("\nYou currently have " + statpoints + " stat points to distribute\n");
                    Console.Write("What stat will you improve (hp gains by 5 and mp gains by 2)? ");
                    choice = Console.ReadLine();

                    picked = false;
                    if (Utility.NotBlank(choice))
                    {
                        if (Utility.WordMatch(choice, "dexterity", picked))
                        {
                            Console.WriteLine("You chose dexterity!");
                            dex   += 1;
                            picked = true;
                        }
                        if (Utility.WordMatch(choice, "strength", picked))
                        {
                            Console.WriteLine("You chose strength!");
                            str   += 1;
                            picked = true;
                        }
                        if (Utility.WordMatch(choice, "wisdom", picked))
                        {
                            Console.WriteLine("You chose wisdom!");
                            wis   += 1;
                            picked = true;
                        }
                        if (Utility.WordMatch(choice, "constitution", picked))
                        {
                            Console.WriteLine("You chose constitution!");
                            con   += 1;
                            picked = true;
                        }
                        if (Utility.WordMatch(choice, "hp", picked))
                        {
                            Console.WriteLine("You chose hp!");
                            hp    += 5;
                            maxhp += 5;
                            picked = true;
                        }
                        if (Utility.WordMatch(choice, "mp", picked))
                        {
                            Console.WriteLine("You chose mp!");
                            mp    += 2;
                            maxmp += 2;
                            picked = true;
                        }
                        if (picked)
                        {
                            statpoints--;
                        }
                        else
                        {
                            Console.WriteLine("That did not register, please try again.\n");
                        }
                    }
                }
                calcstats();
                Console.WriteLine("You have finished character creation.  Your final stats are as follows:\n");
                Console.WriteLine("HP: " + hp + "/" + maxhp);
                Console.WriteLine("MP: " + mp + "/" + maxmp);
                Console.Write("\nStr:\t" + str + "\tDex:\t" + dex);
                Console.Write("\nWis:\t" + wis + "\tCon:\t" + con);
                Console.Write("\nAtt:\t" + attack + "\tDef:\t" + defense);


                picked = false;
                while (!picked)
                {
                    Console.Write("\nIs this acceptable (y/n)?");
                    choice = Console.ReadLine();

                    if (Utility.WordMatch(choice, "yes", picked))
                    {
                        startingequip();
                        confirm = true;
                        picked  = false;
                        while (!picked)
                        {
                            Console.Write("\nWill you save (y/n)?");
                            choice = Console.ReadLine();
                            if (Utility.WordMatch(choice, "yes", picked))
                            {
                                picked = true;
                                saver.SaveData(this, name + ".character");
                                Console.Write("\nData Saved.\n");
                                DisplayStats();
                            }
                            if (Utility.WordMatch(choice, "no", picked))
                            {
                                picked = true;
                                DisplayStats();
                            }
                        }
                    }
                    if (Utility.WordMatch(choice, "no", picked))
                    {
                        picked = true;
                        reset();
                    }
                }
            }
            calcstats();
        }