Пример #1
0
        public void ViewInventory()
        {
            // This is almost an exact copy of the Shop.cs do while possibly rework later
            do
            {
                // See shop.cs for explination of this
                Interface.BasicInterfaceDelegateParams(this, LineHelpers.PrintLine, "Your Inventory:", "1. Weapons", "2. Armor", "3. Consumables.", "4. Exit");

                int type = LineHelpers.ReadInputNumber(new int[] { 1, 2, 3, 4 });

                Interface.BasicInterface(this);

                Thing choice;
                switch (type)
                {
                case 1:
                    Interface.BasicInterfaceDelegate(this, LineHelpers.PrintLine, "Weapons: ");
                    choice = ListHelpers.PrintListGetItem(this.Weapons, PrintTypes.Weapon) as Weapon;
                    break;

                case 2:
                    Interface.BasicInterfaceDelegate(this, LineHelpers.PrintLine, "Armor: ");
                    choice = ListHelpers.PrintListGetItem(this.Armor, PrintTypes.Armor) as Armor;
                    break;

                case 3:
                    Interface.BasicInterfaceDelegate(this, LineHelpers.PrintLine, "Consumables: ");
                    choice = ListHelpers.PrintListGetItem(this.Consumables, PrintTypes.Consumable) as Consumable;
                    break;

                default:
                    return;
                }
                if (choice != null)
                {
                    try
                    {
                        if (type == 1)
                        {
                            EquipWeapon(choice as Weapon);
                        }
                        else
                        {
                            EquipArmor(choice as Armor);
                        }
                    }
                    // this should never be nessicary
                    catch (Exception ex)
                    {
                        LineHelpers.PrintLine("Unable to equip Item.");
                    }
                }
            } while (true);
        }
Пример #2
0
        public void Attack(Enemy enemy)
        {
            // Player decides what he wants to do.
            // Possibly add a space for class spells later
            Interface.BasicInterfaceDelegateParams(this, LineHelpers.PrintLine, "Choose your attack:", "1. Attack with your weapon.", "2. Choose a spell", "3. Drink a potion");

            int type = LineHelpers.ReadInputNumber(new int[] { 1, 2, 3 });

            Interface.BasicInterface(this);

            int damage = -1;

            while (damage == -1)
            {
                switch (type)
                {
                case 1:
                    damage = this.BaseAttack(enemy);
                    break;

                case 2:
                    Interface.BasicInterfaceDelegate(this, LineHelpers.PrintLine, "Spells: ");
                    Spell spell = ListHelpers.PrintListGetItem(ClassSpells, PrintTypes.Spell) as Spell;
                    if (spell != null)
                    {
                        damage = enemy.TakeDamage(spell.Use(this, enemy.Name));
                        LineHelpers.PrintLineWithContinue(GetAttackString(damage) + enemy.Name);
                        return;
                    }
                    break;

                case 3:
                    Interface.BasicInterfaceDelegate(this, LineHelpers.PrintLine, "Consumables: ");
                    Consumable consumable = ListHelpers.PrintListGetItem(Consumables, PrintTypes.Consumable) as Consumable;
                    if (consumable != null)
                    {
                        this.UseConsumable(consumable);
                        return;
                    }
                    break;
                }
            }

            // I may want to decouple this later
            AttackStringBuilder(enemy.TakeDamage(damage), enemy.Name);

            //return damage;
        }
Пример #3
0
        public override void LevelUp()
        {
            var choices = Constants.WizardSpells.Where(spell => spell.Level == Level).ToList();

            Interface.BasicInterfaceDelegate(this, LineHelpers.PrintLine, "Choose a new spell for this level: ");

            Spell choice;

            do
            {
                choice = ListHelpers.PrintListGetItem(choices, PrintTypes.SpellsInformation) as Spell;
            }while (choice == null);

            ClassSpells.Add(choice);

            // Wizard Level UP stats
            Intelligence += 2;
            Constitution += 5;
        }
Пример #4
0
        private static void BuyItem(Player player)
        {
            // Inits a vender and allows player to buy an item.
            Vendor vendor = new Vendor();

            do
            {
                Interface.BasicInterfaceDelegateParams(player, LineHelpers.PrintLine, "Look at wares:", "1. Weapons", "2. Armor", "3. Consumables.", "4. Exit");

                int type = LineHelpers.ReadInputNumber(new int[] { 1, 2, 3, 4 });

                Interface.BasicInterface(player);

                Thing choice = null;
                switch (type)
                {
                case 1:
                    Interface.BasicInterfaceDelegate(player, LineHelpers.PrintLine, "Weapons: ");
                    choice = ListHelpers.PrintListGetItem(vendor.Weapon, PrintTypes.Weapon) as Weapon;
                    break;

                case 2:
                    Interface.BasicInterfaceDelegate(player, LineHelpers.PrintLine, "Armor: ");
                    choice = ListHelpers.PrintListGetItem(vendor.Armor, PrintTypes.Armor) as Armor;
                    break;

                case 3:
                    Interface.BasicInterfaceDelegate(player, LineHelpers.PrintLine, "Consumables: ");
                    choice = ListHelpers.PrintListGetItem(vendor.Consumable, PrintTypes.Consumable) as Consumable;
                    break;

                case 4:
                    Interface.BasicInterfaceDelegate(player, LineHelpers.PrintLineWithContinue, "You leave the shop.");
                    return;
                }
                if (choice != null)
                {
                    player.BuyItem(choice);
                }
            } while (true);
        }