Пример #1
0
    void CompoundSingle()
    {
        bool           compound    = false;
        int            unlockCount = CDataPool.Instance.TalismanInventory_UnLockCount();
        CTalisman_Item item1       = null;
        CTalisman_Item item2       = null;

        for (int i = 0; i < unlockCount; i++)
        {
            item1 = CDataPool.Instance.TalismanInventory_GetItem(i);
            int lv      = item1.GetLV();
            int quality = item1.GetItemTableQuality();
            item2 = CDataPool.Instance.TalismanInventory_GetSuitableCompoundItem(lv, quality);
            if (item2 != null)
            {
                CGOperateTalisman operateTalisman = new CGOperateTalisman();
                operateTalisman.Type     = 2;
                operateTalisman.SrcIndex = (byte)(item1.GetPosIndex() + GAMEDEFINE.MAX_BAG_SIZE);
                operateTalisman.DstIndex = (byte)(item2.GetPosIndex() + GAMEDEFINE.MAX_BAG_SIZE);
                NetManager.GetNetManager().SendPacket(operateTalisman);
                compound = true;
                return;
            }
        }

        if (autoCompound)
        {
            autoCompound = compound;
        }

        if (!autoCompound)
        {
            EnableButton(true);
        }
    }
    void NotifyDragPackageToPackage(string szSourceName, string szTargetName)
    {
        int srcPackageIndex = Convert.ToInt32(szSourceName.Substring(1, szSourceName.Length - 1)) - 1;
        int desPackageIndex = Convert.ToInt32(szTargetName.Substring(1, szTargetName.Length - 1)) - 1;

        Debug.Log("src " + szSourceName + " dst " + szTargetName);
        CTalisman_Item item = ItemImpl;

        if (item != null)
        {
            switch (item.TypeOwner)
            {
            //Package -> Package
            case ITEM_OWNER.IO_TALISMAN_PACKET:
            {
                //先不做能不能放入的检测
                int srcindex = (int)srcPackageIndex + GAMEDEFINE.MAX_BAG_SIZE;
                int dstindex = (int)desPackageIndex + GAMEDEFINE.MAX_BAG_SIZE;


                if (srcindex == dstindex)
                {
                    return;
                }

                CTalisman_Item desItem = CDataPool.Instance.TalismanInventory_GetItem(srcPackageIndex);
                CTalisman_Item srcItem = CDataPool.Instance.TalismanInventory_GetItem(desPackageIndex);
                if (desItem != null && srcItem != null)
                {
                    CGOperateTalisman operateTalisman = new CGOperateTalisman();
                    operateTalisman.Type     = 2;
                    operateTalisman.SrcIndex = (byte)srcindex;
                    operateTalisman.DstIndex = (byte)dstindex;
                    NetManager.GetNetManager().SendPacket(operateTalisman);
                }
                else
                {
                    //不同格
                    CGPackage_SwapItem msg = new CGPackage_SwapItem();
                    msg.PIndex1 = (byte)srcindex;
                    msg.PIndex2 = (byte)dstindex;
                    NetManager.GetNetManager().SendPacket(msg);
                }
            }
            break;
            }
        }
    }
    //激活动作
    public override void DoAction()
    {
        base.DoAction();

        if (ItemImpl == null)
        {
            return;
        }
        switch (ItemImpl.TypeOwner)
        {
        case ITEM_OWNER.IO_TALISMAN_PACKET:
        {
            CGOperateTalisman operateTalisman = new CGOperateTalisman();
            int posIndex    = ItemImpl.GetPosIndex();
            int equiptIndex = CDataPool.Instance.FindTalismanEquiptEmptyPlace();
            if (equiptIndex == -1)
            {
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "装备栏没有空位");
                return;
            }
            operateTalisman.Type     = 0;
            operateTalisman.SrcIndex = (byte)(posIndex + GAMEDEFINE.MAX_BAG_SIZE);
            operateTalisman.DstIndex = (byte)(equiptIndex);
            NetManager.GetNetManager().SendPacket(operateTalisman);
        }
        break;

        case ITEM_OWNER.IO_TALISMAN_EQUIPT:
        {
            CGOperateTalisman operateTalisman = new CGOperateTalisman();
            int equiptIndex = ItemImpl.GetPosIndex();
            int posIndex    = CDataPool.Instance.FindTalismanInventoryEmptyPlace();
            if (posIndex == -1)
            {
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "法宝栏没有空位");
                return;
            }
            operateTalisman.Type     = 1;
            operateTalisman.SrcIndex = (byte)(posIndex + GAMEDEFINE.MAX_BAG_SIZE);
            operateTalisman.DstIndex = (byte)(equiptIndex);
            NetManager.GetNetManager().SendPacket(operateTalisman);
        }
        break;
        }
    }