コード例 #1
0
ファイル: Player.cs プロジェクト: royer00/Dungeon2_28_20
 public Player(string name, int hitChance, int block, int maxLife, int life, int xp, Race characterRace, Weapon equippedWeapon, Potion equippedPotion, int level, Armor equippedArmor, Inventory inventory, List <QuestItems> questItemslist)
     : base(name, hitChance, block, maxLife, life, xp)
 {
     CharacterRace  = characterRace;
     EquippedWeapon = equippedWeapon;
     EquippedPotion = equippedPotion;
     Level          = Level;
     EquippedArmor  = equippedArmor;
     Inventory      = inventory;
     QuestItemsList = questItemslist;
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: royer00/Dungeon2_28_20
        }//end player level

        //Player Creation
        public void PlayerCreation(Player player)
        {
            Console.WriteLine("Enter your name, brave soul: ");
            player.Name = Console.ReadLine();
            Inventory playerInventory = new Inventory();//instantiating an inventory

            player.Inventory = playerInventory;
            Console.WriteLine("Choose a race:\n" +
                              "H)uman - a race with the potential to be good at everything they try\n" +
                              "E)lf - an ancient race, lighting quick but frail\n" +
                              "O)rc - a smaller race, slightly weaker, but excellent at stealth\n" +
                              "D)warf - a smaller race, but hearty and industrious\n" +
                              "G)iant - an incredibly powerful and hearty race, but oh so slow..");
            ConsoleKey raceChoice = Console.ReadKey(true).Key;

            switch (raceChoice)
            {//player is given different starting weapon depending on race
            //player is given different advantages and disadvantages
            case ConsoleKey.H:
                player.CharacterRace = Race.Human;                                          //vvvvvvvvvv vvvvvvvturned up for testing
                Weapon longSword = new Weapon("Long Sword Weapon", "A long gleaming blade", 100, 5, true, 50);
                player.Inventory.AddItem(longSword);
                player.EquippedWeapon = longSword;
                break;

            case ConsoleKey.E:
                player.CharacterRace = Race.Elf;
                player.HitChance    += 5;
                player.MaxLife      -= 10;
                Weapon shortSword = new Weapon("Short Sword Weapon", "A short, precise blade", 8, 3, false, 4);
                player.Inventory.AddItem(shortSword);
                player.EquippedWeapon = shortSword;
                break;

            case ConsoleKey.O:
                player.CharacterRace = Race.Orc;
                player.MaxLife      += 10;
                player.HitChance    -= 2;
                Weapon mace = new Weapon("Mace Weapon", "A wicked-looking spiked club", 12, 0, true, 1);
                player.Inventory.AddItem(mace);
                player.EquippedWeapon = mace;
                break;

            case ConsoleKey.D:
                player.CharacterRace = Race.Dwarf;
                player.HitChance    -= 5;
                Weapon broadAxe = new Weapon("Broad Axe Weapon", "A finely-honed, silver axe", 10, 0, true, 3);
                player.Inventory.AddItem(broadAxe);
                player.EquippedWeapon            = broadAxe;
                player.EquippedWeapon.MaxDamage += 3;
                break;

            case ConsoleKey.G:
                player.CharacterRace = Race.Giant;
                Weapon warHammer = new Weapon("War Hammer Weapon", "A massive iron hammer", 15, -2, true, 4);
                player.Inventory.AddItem(warHammer);
                player.EquippedWeapon            = warHammer;
                player.EquippedWeapon.MaxDamage += 15;
                player.HitChance -= 10;
                player.MaxLife   += 20;
                player.Block     -= 10;
                break;

            default:
                Console.WriteLine("If you can't choose well, you will be a human.");
                break;
            }//end race switch

            Armor         clothArmor = new Armor("Cloth Armor", "Lightweigth, but little protection", 1);
            HealingPotion h1         = new HealingPotion("Healing Potion", "heals what ails you", 5);

            //starting player off with cloth armor and some healing potions
            player.EquippedArmor  = clothArmor;
            player.EquippedPotion = h1;

            //separate inventory for quest items
            List <QuestItems> questItems = new List <QuestItems>();

            player.QuestItemsList = questItems;
            player.Inventory.AddItem(clothArmor);
            player.Inventory.AddItem(h1);

            Console.Clear();
            Console.WriteLine("----------------YOUR CHARACTER-----------\n");
            Console.WriteLine($"{player}\n");
            Console.WriteLine("________________________________________________________________");
        }//end PlayerCreation()