コード例 #1
0
        public static Dictionary <string, Item> GlobalItems = new Dictionary <string, Item>(); //dictionary to hold Items based on their ID

        /*
         * This function will parse the CSV containing all the items
         */
        public static void Parser()
        {
            string     path       = "CSV-Items.csv";                     //store file path
            FileStream fileStream = new FileStream(path, FileMode.Open); //create File object

            using (StreamReader reader = new StreamReader(fileStream))   //read text
                using (CsvReader csv = new CsvReader(reader))            //parse text as a CSV
                {
                    var records = csv.GetRecords <ItemStats>();          //Get all records in the CSV as a Enumerable of ItemStats
                    foreach (ItemStats record in records)
                    {
                        if (record.GetItemType() == "Equibable")                                                 //if item can be equipped
                        {
                            Equipable item = new Equipable(record.GetID(), record.GetName(), record.GetDes());   //create Equipable object
                            item.SetItemStats(record.GetAgility(), record.GetAttack(), record.GetHP());          //set Equipable item's stats
                            item.SetLocation(record.GetLocDes());                                                //set location of item
                            GlobalItems.Add(record.GetID(), item);                                               //append item to dictionary based on ID
                        }
                        else if (record.GetItemType() == "Consumable")                                           //if item can be consumed
                        {
                            Consumable item = new Consumable(record.GetID(), record.GetName(), record.GetDes()); //create Consumable object
                            item.SetItemStats(record.GetAgility(), record.GetAttack(), record.GetHP());          //set Consumable item's stats
                            item.SetLocation(record.GetLocDes());                                                //set location of item
                            item.SetUsability(record.GetCombatUsability());                                      //determine if Consumable item can be used outside of battle
                            GlobalItems.Add(record.GetID(), item);                                               //append to dictionary based on ID
                        }
                    }
                }
        }
コード例 #2
0
        //displays the difference between the stats of one equipable and a new equipable
        private static void PrintDifferenceInStats(Equipable oldEquip, Equipable newEquip)
        {
            //TODO: Don't display change if it = 0

            Utility.Write("Change in stats: ", Game.inventoryColor);
            Utility.Write("Attack: " + (newEquip.plusAttack - oldEquip.plusAttack), Game.statsColor);
            Utility.Write("Agility: " + (newEquip.plusAgility - oldEquip.plusAgility), Game.statsColor);
            Utility.Write("HP: " + (newEquip.plusHP - oldEquip.plusHP), Game.statsColor);
            Console.WriteLine();
        }
コード例 #3
0
        /*
         * This function is meant to start the game. It outputs the title, the ASCII ART, the authors, creates the player,
         * sets player archetypes, deals with the branching narrative, *deals with combat*, and ends the game.
         */
        public static void Start()
        {
            GameTitle();
            Console.WriteLine();
            Console.WriteLine(Utility.Center("████████▄     ▄████████  ▄████████  ▄█     ▄████████  ▄█   ▄██████▄  ███▄▄▄▄      ▄████████       ▄██████▄     ▄████████"));
            Console.WriteLine(Utility.Center("███   ▀███   ███    ███ ███    ███ ███    ███    ███ ███  ███    ███ ███▀▀▀██▄   ███    ███      ███    ███   ███    ███"));
            Console.WriteLine(Utility.Center("███    ███   ███    █▀  ███    █▀  ███▌   ███    █▀  ███▌ ███    ███ ███   ███   ███    █▀       ███    ███   ███    █▀ "));
            Console.WriteLine(Utility.Center("███    ███  ▄███▄▄▄     ███        ███▌   ███        ███▌ ███    ███ ███   ███   ███             ███    ███  ▄███▄▄▄    "));
            Console.WriteLine(Utility.Center("███    ███ ▀▀███▀▀▀     ███        ███▌ ▀███████████ ███▌ ███    ███ ███   ███ ▀███████████      ███    ███ ▀▀███▀▀▀    "));
            Console.WriteLine(Utility.Center("███    ███   ███    █▄  ███    █▄  ███           ███ ███  ███    ███ ███   ███          ███      ███    ███   ███       "));
            Console.WriteLine(Utility.Center("███   ▄███   ███    ███ ███    ███ ███     ▄█    ███ ███  ███    ███ ███   ███    ▄█    ███      ███    ███   ███       "));
            Console.WriteLine(Utility.Center("████████▀    ██████████ ████████▀  █▀    ▄████████▀  █▀    ▀██████▀   ▀█   █▀   ▄████████▀        ▀██████▀    ███       "));
            Console.WriteLine(Utility.Center(""));
            Console.WriteLine(Utility.Center("    ███        ▄█    █▄       ▄████████      ████████▄     ▄████████   ▄▄▄▄███▄▄▄▄   ███▄▄▄▄      ▄████████ ████████▄   "));
            Console.WriteLine(Utility.Center("▀█████████▄   ███    ███     ███    ███      ███   ▀███   ███    ███ ▄██▀▀▀███▀▀▀██▄ ███▀▀▀██▄   ███    ███ ███   ▀███  "));
            Console.WriteLine(Utility.Center("   ▀███▀▀██   ███    ███     ███    █▀       ███    ███   ███    ███ ███   ███   ███ ███   ███   ███    █▀  ███    ███  "));
            Console.WriteLine(Utility.Center("    ███   ▀  ▄███▄▄▄▄███▄▄  ▄███▄▄▄          ███    ███   ███    ███ ███   ███   ███ ███   ███  ▄███▄▄▄     ███    ███  "));
            Console.WriteLine(Utility.Center("    ███     ▀▀███▀▀▀▀███▀  ▀▀███▀▀▀          ███    ███ ▀███████████ ███   ███   ███ ███   ███ ▀▀███▀▀▀     ███    ███  "));
            Console.WriteLine(Utility.Center("    ███       ███    ███     ███    █▄       ███    ███   ███    ███ ███   ███   ███ ███   ███   ███    █▄  ███    ███  "));
            Console.WriteLine(Utility.Center("    ███       ███    ███     ███    ███      ███   ▄███   ███    ███ ███   ███   ███ ███   ███   ███    ███ ███   ▄███  "));
            Console.WriteLine(Utility.Center("   ▄████▀     ███    █▀      ██████████      ████████▀    ███    █▀   ▀█   ███   █▀   ▀█   █▀    ██████████ ████████▀   "));
            Console.WriteLine(Utility.Center("               _      _____         _     ____                     _    ____                                "));
            Console.WriteLine(Utility.Center("              / \\    |_   _|____  _| |_  | __ )  __ _ ___  ___  __| |  / ___| __ _ _ __ ___   ___           "));
            Console.WriteLine(Utility.Center("       / _ \\     | |/ _ \\ \\/ / __| |  _ \\ / _` / __|/ _ \\/ _` | | |  _ / _` | '_ ` _ \\ / _ \\    "));
            Console.WriteLine(Utility.Center("  / ___ \\    | |  __/>  <| |_  | |_) | (_| \\__ \\  __/ (_| | | |_| | (_| | | | | | |  __/"));
            Console.WriteLine(Utility.Center(" /_/   \\_\\   |_|\\___/_/\\_\\___| |____/ \\__,_|___/\\___|\\__,_|  \\____|\\__,_|_| |_| |_|\\___|"));
            Console.WriteLine();
            Console.WriteLine(Utility.Center("<::::::::::::[]xxx[] xXx []xxx[]::::::::::::>"));
            Console.WriteLine();
            Console.WriteLine(Utility.Center("Created by:"));
            Console.WriteLine(Utility.Center("Mark Melkumyan, Kev Karnani, Humaid Mustajab,"));
            Console.WriteLine(Utility.Center("Cort Williams, and Joey Hermann."));
            Console.WriteLine();
            var pressAnyKey = Console.ReadLine();                                          //make the player press any key to continue

            Console.WriteLine(String.Concat(Enumerable.Repeat("=", Console.WindowWidth))); //create a line of "=" based on console width
            Console.WriteLine();

            Utility.Write("Controls:");
            Utility.Write(" - Choices are shown in cyan", choiceColor);
            Utility.Write("    - Type a # to choose an option (ex. '2')");
            Utility.Write(" - Type 'I' to open your inventory");
            Utility.Write(" - Type 'O' to open your player overview");
            Utility.Write(" - Type 'Q' to quit any menu");
            Console.WriteLine();


            CreatePlayer();

            //Equipable weapon1 = (Equipable)ItemParser.GlobalItems["1"];

            //test weapons
            Equipable weapon1 = new Equipable("1", "Dulled Shortsword", "An old blade wielded by a warrior long past.");

            weapon1.SetIsWeapon(true);
            weapon1.SetStats(10, 5, 0);
            Inventory.AddItem(weapon1);
            weapon1.Equip();

            Equipable armor1 = new Equipable("2", "Torn tunic", "The worn out garb of an experienced adventurer.");

            weapon1.SetIsWeapon(false);
            armor1.SetStats(0, 0, 15);
            Inventory.AddItem(armor1);
            armor1.Equip();

            Consumable potion1 = new Consumable("1", "Health potion", "a red liquid in a shiny bottle");

            potion1.SetStats(0, 0, 20);
            potion1.SetUsability(true);
            Consumable potion2 = new Consumable("2", "Attack potion", "a blue liquid in a dark bottle");

            potion2.SetStats(10, 0, 0);
            potion2.SetUsability(false);

            Inventory.AddItem(potion1);
            Inventory.AddItem(potion1);
            Inventory.AddItem(potion2);
            //potion1.UseEffect();
            //*/

            InitializeScenarios();
            InitializeEnemy();
            GameLoop();
            End();
        }