Ejemplo n.º 1
0
 //获取到服务器转盘奖品数据
 public void BackData(int pos)
 {
     //从服务器获取旋转得到的商品在奖品链表里面索引
     wrap               = allitems[pos - 1];
     ID                 = wrap.Position;
     goimg.color        = Color.gray;
     goBtn.interactable = false;
     if (PlayerCache.loginInfo.signInDialNum > 0)
     {
         PlayerCache.loginInfo.signInDialNum--;
     }
     if (PlayerCache.loginInfo.signInDialNum == 0)
     {
         goBtn.interactable = false;
     }
     else
     {
         goBtn.interactable = true;
     }
     dialTimes.text = "剩余次数(" + PlayerCache.loginInfo.signInDialNum + ")";
     //设置旋转速度
     RotationSpeed = 1000;
     //设置时间
     time = Time.time + rotateTime;
     //停止状态变成旋转
     isStop = false;
 }
Ejemplo n.º 2
0
        void HandleWrapItem(WrapItem packet)
        {
            if (packet.Inv.Items.Count != 2)
            {
                Log.outError(LogFilter.Network, "HandleWrapItem - Invalid itemCount ({0})", packet.Inv.Items.Count);
                return;
            }

            // Gift
            byte giftContainerSlot = packet.Inv.Items[0].ContainerSlot;
            byte giftSlot          = packet.Inv.Items[0].Slot;
            // Item
            byte itemContainerSlot = packet.Inv.Items[1].ContainerSlot;
            byte itemSlot          = packet.Inv.Items[1].Slot;

            Item gift = GetPlayer().GetItemByPos(giftContainerSlot, giftSlot);

            if (!gift)
            {
                GetPlayer().SendEquipError(InventoryResult.ItemNotFound, gift);
                return;
            }

            if (!gift.GetTemplate().HasFlag(ItemFlags.IsWrapper)) // cheating: non-wrapper wrapper
            {
                GetPlayer().SendEquipError(InventoryResult.ItemNotFound, gift);
                return;
            }

            Item item = GetPlayer().GetItemByPos(itemContainerSlot, itemSlot);

            if (!item)
            {
                GetPlayer().SendEquipError(InventoryResult.ItemNotFound, item);
                return;
            }

            if (item == gift) // not possable with pacjket from real client
            {
                GetPlayer().SendEquipError(InventoryResult.CantWrapWrapped, item);
                return;
            }

            if (item.IsEquipped())
            {
                GetPlayer().SendEquipError(InventoryResult.CantWrapEquipped, item);
                return;
            }

            if (!item.GetGiftCreator().IsEmpty()) // HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED);
            {
                GetPlayer().SendEquipError(InventoryResult.CantWrapWrapped, item);
                return;
            }

            if (item.IsBag())
            {
                GetPlayer().SendEquipError(InventoryResult.CantWrapBags, item);
                return;
            }

            if (item.IsSoulBound())
            {
                GetPlayer().SendEquipError(InventoryResult.CantWrapBound, item);
                return;
            }

            if (item.GetMaxStackCount() != 1)
            {
                GetPlayer().SendEquipError(InventoryResult.CantWrapStackable, item);
                return;
            }

            // maybe not correct check  (it is better than nothing)
            if (item.GetTemplate().GetMaxCount() > 0)
            {
                GetPlayer().SendEquipError(InventoryResult.CantWrapUnique, item);
                return;
            }

            SQLTransaction trans = new();

            PreparedStatement stmt = DB.Characters.GetPreparedStatement(CharStatements.INS_CHAR_GIFT);

            stmt.AddValue(0, item.GetOwnerGUID().GetCounter());
            stmt.AddValue(1, item.GetGUID().GetCounter());
            stmt.AddValue(2, item.GetEntry());
            stmt.AddValue(3, (uint)item.m_itemData.DynamicFlags);
            trans.Append(stmt);

            item.SetEntry(gift.GetEntry());

            switch (item.GetEntry())
            {
            case 5042:
                item.SetEntry(5043);
                break;

            case 5048:
                item.SetEntry(5044);
                break;

            case 17303:
                item.SetEntry(17302);
                break;

            case 17304:
                item.SetEntry(17305);
                break;

            case 17307:
                item.SetEntry(17308);
                break;

            case 21830:
                item.SetEntry(21831);
                break;
            }

            item.SetGiftCreator(GetPlayer().GetGUID());
            item.SetItemFlags(ItemFieldFlags.Wrapped);
            item.SetState(ItemUpdateState.Changed, GetPlayer());

            if (item.GetState() == ItemUpdateState.New) // save new item, to have alway for `character_gifts` record in `item_instance`
            {
                // after save it will be impossible to remove the item from the queue
                Item.RemoveItemFromUpdateQueueOf(item, GetPlayer());
                item.SaveToDB(trans); // item gave inventory record unchanged and can be save standalone
            }
            DB.Characters.CommitTransaction(trans);

            uint count = 1;

            GetPlayer().DestroyItemCount(gift, ref count, true);
        }