Example #1
0
        private void AddItem(int itemId, int count)
        {
            PlayerPackageLogic pp = new PlayerPackageLogic();

            pp.SetUser(m_UserId);
            ItemListItem item = new ItemListItem();

            item.Id    = itemId;
            item.Count = count;
            pp.AddInventory(item);
            m_ResponsePacket.ItemInfo = new PBItemInfo()
            {
                Type  = itemId,
                Count = pp.MyPackage.Inventories[itemId]
            };
        }
Example #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;
            }
        }