예제 #1
0
 private void AddRewardsToMessage(Message message, CampaignWorld world)
 {
     foreach (var reward in world.Rewards)
     {
         message.Add(reward.Key);
         message.Add(reward.Value);
     }
 }
예제 #2
0
        private void AwardWorldRewards(CommonPlayer player, CampaignWorld world, Shop shop)
        {
            foreach (var reward in world.Rewards)
            {
                switch (reward.Key)
                {
                case "maxEnergy":
                    player.MaxEnergy += (int)reward.Value;
                    Console.WriteLine("Rewarded {0} with +{1} maximum energy.", player.Name, reward.Value);
                    break;

                case "energy":
                    player.AddEnergy((int)reward.Value);
                    Console.WriteLine("Rewarded {0} with +{1} energy.", player.Name, reward.Value);
                    break;

                case "energyRefill":
                    player.RefillEnergy();
                    Console.WriteLine("Rewarded {0} with energy refill.", player.Name);
                    break;

                case "gems":
                    var amount = reward.Value;
                    player.PayVault.Credit(amount, "Completing " + this.Data.Title + " campaign",
                                           delegate { Console.WriteLine("Rewarded {0} with {1} gems.", player.Name, amount); });
                    break;

                default:
                    var item = shop.GetShopItem(reward.Key);

                    if (item != null && item.Key == reward.Key && (!player.PayVault.Has(item.Key) || item.Reusable))
                    {
                        var count = item.Reusable ? reward.Value : 1;
                        var items = new BuyItemInfo[count];
                        for (var i = 0; i < items.Length; i++)
                        {
                            items[i] = new BuyItemInfo(item.Key);
                        }

                        player.PayVault.Give(items,
                                             delegate
                        {
                            Console.WriteLine("Rewarded {0} with {1} x{2}.", player.Name, item.Key, count);
                        });
                    }
                    break;
                }
            }
        }