Esempio n. 1
0
 private void GetItems(DropItem item)
 {
     if (PlayerPackageLogic.IsItem(item.ItemId))
     {
         var itemData = CacheSet.ItemTable.GetData(item.ItemId);
         if (itemData == null)
         {
             TraceLog.WriteError("Wrong Item ID in drop table : " + item.ItemId.ToString());
         }
         if (itemData.FunctionId == (int)ItemFunctions.AddHero)
         {
             PlayerHeroLogic ph = new PlayerHeroLogic();
             ph.SetUser(m_UserId);
             int          heroId = int.Parse(itemData.FunctionParams);
             ItemListItem piece  = ph.AddNewHero(heroId);
             if (piece == null)
             {
                 Hero newHero = ph.MyHeros.Heros[heroId];
                 m_ResponsePacket.LobbyHeroInfo.Add(new PBLobbyHeroInfo()
                 {
                     Type               = newHero.HeroType,
                     Level              = newHero.HeroLv,
                     Exp                = newHero.HeroExp,
                     ElevationLevel     = newHero.ElevationLevel,
                     ConsciousnessLevel = newHero.ConsciousnessLevel,
                     StarLevel          = newHero.HeroStarLevel
                 });
                 return;
             }
             else
             {
                 AddItem(piece.Id, piece.Count);
                 return;
             }
         }
         AddItem(item.ItemId, item.ItemCount);
         return;
     }
     AddItem(item.ItemId, item.ItemCount);
     return;
 }
Esempio n. 2
0
        private void GetReward(DropItem item)
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            var type = m_RequestPacket.ChanceType == (int)ChanceType.Money ? ReceiveItemMethodType.MoneyChance : ReceiveItemMethodType.CoinChance;

            if (PlayerPackageLogic.IsItem(item.ItemId))
            {
                m_ResponsePacket.ReceivedItems = new PBReceivedItems();
                var itemData = CacheSet.ItemTable.GetData(item.ItemId);
                if (itemData.FunctionId == (int)ItemFunctions.AddHero)
                {
                    PlayerHeroLogic ph = new PlayerHeroLogic();
                    ph.SetUser(m_UserId);
                    int          heroId = int.Parse(itemData.FunctionParams);
                    ItemListItem piece  = ph.AddNewHero(heroId, type);
                    if (piece == null)
                    {
                        Hero newHero = ph.MyHeros.Heros[heroId];
                        m_ResponsePacket.LobbyHeroInfo = new PBLobbyHeroInfo()
                        {
                            Type               = newHero.HeroType,
                            Level              = newHero.HeroLv,
                            Exp                = newHero.HeroExp,
                            ElevationLevel     = newHero.ElevationLevel,
                            ConsciousnessLevel = newHero.ConsciousnessLevel,
                            StarLevel          = newHero.HeroStarLevel
                        };
                    }
                    else
                    {
                        pp.AddInventory(piece);
                        m_ResponsePacket.ReceivedItems.ItemInfo.Add(new PBItemInfo()
                        {
                            Type  = piece.Id,
                            Count = pp.MyPackage.Inventories[piece.Id]
                        });
                    }
                }
                else
                {
                    pp.AddInventory(new ItemListItem()
                    {
                        Id = item.ItemId, Count = item.ItemCount
                    });
                    m_ResponsePacket.ReceivedItems.ItemInfo.Add(new PBItemInfo()
                    {
                        Type  = item.ItemId,
                        Count = pp.MyPackage.Inventories[item.ItemId]
                    });
                }
            }
            else
            {
                Dictionary <int, int> itemDict = new Dictionary <int, int>();
                itemDict.Add(item.ItemId, item.ItemCount);
                PBReceivedItems receivedItems;
                pp.GetItems(itemDict, type, out receivedItems);
                m_ResponsePacket.ReceivedItems = receivedItems;
            }
        }