예제 #1
0
        public static int LootGenerator(Hero hero, Difficulty difficulty)
        {
            // Gold reward is calculated based on difficulty
            //  BaseGold: 31
            //          Min:    Max:
            //  Easy:   1 %     30 %
            //  Medium: 30 %    70 %
            //  Hard:   70 %    100 %
            int rewardGold = 0;
            var randomNum  = new Random();

            switch (difficulty)
            {
            case Difficulty.Easy:
                rewardGold = randomNum.Next((int)(Settings.BaseRewardGold * Settings.GoldEarnedEasyMin), (int)(Settings.BaseRewardGold * Settings.GoldEarnedEasyMax));
                break;

            case Difficulty.Medium:
                rewardGold = randomNum.Next((int)(Settings.BaseRewardGold * Settings.GoldEarnedMediumMin), (int)(Settings.BaseRewardGold * Settings.GoldEarnedMediumMax));
                break;

            case Difficulty.Hard:
                rewardGold = randomNum.Next((int)(Settings.BaseRewardGold * Settings.GoldEarnedHardMin), (int)(Settings.BaseRewardGold * Settings.GoldEarnedHardMax));
                break;

            default:
                break;
            }
            hero.AddGold(rewardGold);
            return(rewardGold);
        }
예제 #2
0
        public static int PlayerSellItem(int itemID, Hero hero)
        {
            var itemIndex = itemID - 1;
            var getItem   = (from item in hero.Bag
                             where itemIndex == hero.Bag.IndexOf(item)
                             select item).FirstOrDefault();

            // Add to Shop's inventory, remove from Hero's inventory.
            // If the item is not a potion, add it to the shops inventory
            if (!IsPotion(getItem.GetType()))
            {
                ShopItems.Add(getItem);
            }

            hero.RemoveItemFromHero(getItem);
            hero.AddGold(getItem.ResaleValue);
            return(getItem.ResaleValue);
        }