示例#1
0
 public void GetItems(IDictionary<int, int> gotItems, ReceiveItemMethodType method, out PBReceivedItems receivedItems)
 {
     GearLogic gear = new GearLogic();
     SoulLogic soul = new SoulLogic();
     Dictionary<int, int> itemDict = new Dictionary<int, int>();
     receivedItems = new PBReceivedItems();
     foreach (var reward in gotItems)
     {
         if (IsGear(reward.Key))
         {
             for (int i = 0; i < reward.Value; i++)
             {
                 int gearId = gear.AddNewGear(reward.Key, m_UserId, method);
                 AddGear(gearId, reward.Key);
                 receivedItems.GearInfo.Add(new PBGearInfo() { Id = gearId, Type = reward.Key, Level = 1 });
             }
         }
         else if (IsItem(reward.Key))
         {
             AddInventory(new ItemListItem() { Id = reward.Key, Count = reward.Value });
             GameUtils.MergeItem(itemDict, reward.Key, reward.Value);
         }
         else if (IsSoul(reward.Key))
         {
             for (int i = 0; i < reward.Value; i++)
             {
                 int soulId = soul.AddNewSoul(reward.Key);
                 AddSoul(soulId, reward.Key);
                 receivedItems.SoulInfo.Add(new PBSoulInfo() { Id = soulId, Type = reward.Key });
             }
         }
         else if (IsEpigraph(reward.Key))
         {
             for (int i = 0; i < reward.Value; i++)
             {
                 ItemListItem item;
                 if (GetNewEpigraph(reward.Key, out item))
                 {
                     receivedItems.EpigraphInfo.Add(new PBEpigraphInfo() { Type = reward.Key, Level = m_Package.Epigraphs[reward.Key] });
                 }
                 else
                 {
                     GameUtils.MergeItem(itemDict, item.Id, item.Count);
                 }
             }
         }
         else
         {
             PlayerLogic p = new PlayerLogic();
             p.SetUser(m_UserId);
             switch ((GiftItemType)reward.Key)
             {
                 case GiftItemType.Coin:
                     p.AddCoin(reward.Value);
                     break;
                 case GiftItemType.Money:
                     p.AddMoney(reward.Value);
                     break;
                 case GiftItemType.Energy:
                     long nextRecoverTime;
                     p.AddEnergy(reward.Value, out nextRecoverTime);
                     break;
                 case GiftItemType.MeridianEnergy:
                     p.AddStarEnergy(reward.Value);
                     break;
                 case GiftItemType.Spirit:
                     p.AddSpirit(reward.Value);
                     break;
                 case GiftItemType.DragonStripeToken:
                     p.AddDragonStripeToken(reward.Value);
                     break;
             }
         }
     }
     foreach (var item in itemDict)
     {
         receivedItems.ItemInfo.Add(new PBItemInfo() { Type = item.Key, Count = m_Package.Inventories[item.Key] });
     }
 }