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;
            }
        }
    }
Ejemplo n.º 2
0
    void NotifyPacketDrag(string sName, string tName)
    {
        int        srcIndex   = Convert.ToInt32(sName.Substring(1, sName.Length - 1)) - 1;
        int        tarIndex   = Convert.ToInt32(tName.Substring(1, tName.Length - 1)) - 1;
        ITEM_OWNER nTypeOwner = ItemImpl.TypeOwner;

        switch (nTypeOwner)
        {
        //Package -> Package
        case ITEM_OWNER.IO_MYSELF_PACKET:
        {
            //同一格

            if (srcIndex == tarIndex)
            {
                break;
            }

            //不同格
            CGPackage_SwapItem msg = new CGPackage_SwapItem();
            msg.PIndex1 = (byte)srcIndex;
            msg.PIndex2 = (byte)tarIndex;
            NetManager.GetNetManager().SendPacket(msg);
        }
        break;

        case ITEM_OWNER.IO_PET_EQUIPT:
        {
            // 发送卸下宠物装备消息.
            CObject_Item_Equip curEquipt = ItemImpl as CObject_Item_Equip;
            if (GameProcedure.s_pUISystem != null &&
                UISystem.Instance.IsWindowShow("RoleTipWindow") &&
                curEquipt != null)
            {
                GameObject  roleTip   = UIWindowMng.Instance.GetWindowGo("RoleTipWindow");
                UISelfEquip selfEquip = roleTip.GetComponent <UISelfEquip>();
                SDATA_PET   curPet    = CDataPool.Instance.Pet_GetValidPet(selfEquip.ActivePet);   //CDataPool.Instance.Pet_GetPet(selfEquip.ActivePet);
                if (curPet != null)
                {
                    CGOperatePetEquip msg = new CGOperatePetEquip();
                    msg.OperatorType   = 1;
                    msg.GUID           = curPet.GUID;
                    msg.DestBagIndex   = (byte)curEquipt.GetItemType();
                    msg.SourecBagIndex = (byte)tarIndex;
                    NetManager.GetNetManager().SendPacket(msg);
                }
            }
        }
        break;

        default:
            break;
        }

//          switch(nTypeOwner)
//          {
//              //jiaoyikuang->Package
//          case tObject_Item::IO_MYEXBOX:
//              {
//                  //发送拖动物品的消息
//                  CGExchangeSynchItemII msg;
//                  msg.SetOpt(EXCHANGE_MSG::OPT_REMOVEITEM);
//                  msg.SetFromIndex(this->GetPosIndex());
//                  msg.SetToType(EXCHANGE_MSG::POS_BAG);
//                  msg.SetToIndex(nTargetIndex);
//                  CNetManager::GetMe()->SendPacket(&msg);
//              }
//              break;
//          //Bank -> Package
//          case tObject_Item::IO_MYSELF_BANK:
//              {
//                  CGBankRemoveItem msg;
//                  msg.SetToType(CGBankRemoveItem::BAG_POS);
//                  msg.SetIndexFrom(this->GetPosIndex());
//                  msg.SetIndexTo(nTargetIndex);
//
//                  CNetManager::GetMe()->SendPacket(&msg);
//              }
//              break;
//          //Package -> Package
//          case tObject_Item::IO_MYSELF_PACKET:
//              {
//                  //同一格
//                  if(this->GetPosIndex() == nTargetIndex) break;
//
//                  //不同格
//                  CGPackage_SwapItem msg;
//                  msg.SetPackageIndex1(GetPosIndex());
//                  msg.SetPackageIndex2(nTargetIndex);
//
//                  CNetManager::GetMe()->SendPacket(&msg);
//              }
//              break;
//          //SelfEquip -> package
//          case tObject_Item::IO_MYSELF_EQUIP:
//              {
//                  //发送卸下装备的消息
//                  CGUnEquip msg;
//                  msg.setEquipPoint(this->GetPosIndex());
//                  msg.setBagIndex((BYTE)nTargetIndex);
//
//                  CNetManager::GetMe()->SendPacket(&msg);
//                  break;
//              }
//          //playerShop -> package
//          case tObject_Item::IO_PS_SELFBOX:
//              {
//                  _ITEM_GUID Guid;
//                  tObject_Item::ITEM_GUID temp;
//                  temp.m_idUnion = 0;
//
//                  tObject_Item* pSelectItem = this->GetItemImpl();
//                  if(NULL == pSelectItem)
//                  {
//                      return;
//                  }
//
//                  //需要先判定这个物品是否满足移动的条件
//                  //查询这个物品是不是处于上架的状态
//                  INT nIndex = pSelectItem->GetPosIndex();
//                  INT nConIndex = nIndex/20;
//                  INT nPosition = nIndex%20;
//                  if(CDataPool::GetMe()->PlayerShop_GetItemOnSale(TRUE, nConIndex, nPosition))
//                  {
//                      //已经上架,不能取回
//                      return;
//                  }
//
//                  pSelectItem->GetGUID(temp.m_idOrg.m_idWorld, temp.m_idOrg.m_idServer, temp.m_idOrg.m_uSerial);
//                  Guid.m_World	= (BYTE)temp.m_idOrg.m_idWorld;
//                  Guid.m_Server	= (BYTE)temp.m_idOrg.m_idServer;
//                  Guid.m_Serial	= (INT)temp.m_idOrg.m_uSerial;
//
//                  CGItemSynch msg;
//                  msg.SetOpt(CGItemSynch::OPT_MOVE_ITEM_MANU);
//                  msg.SetFromType(CGItemSynch::POS_PLAYERSHOP);
//                  msg.SetToIndex(nTargetIndex);
//                  msg.SetToType(CGItemSynch::POS_BAG);
//                  msg.SetItemGUID(Guid);
//
//                  INT nPage = CDataPool::GetMe()->PlayerShop_GetMySelectConTa();
//                  CGManuMoveItemFromPlayerShopToBag_t ExtraDataInfo;
//                  ExtraDataInfo.m_ShopGuid	= CDataPool::GetMe()->PlayerShop_GetShopID(TRUE);
//                  ExtraDataInfo.m_nStallIndex = (BYTE)nPage;
//                  ExtraDataInfo.m_uSerial		= CDataPool::GetMe()->PlayerShop_GetItemSerial(TRUE,nPage,this->GetPosIndex()%20);
//                  msg.SetExtraInfoLength(ExtraDataInfo.GetSize());
//                  msg.SetExtraInfoData((BYTE*)&ExtraDataInfo);
//
//                  CNetManager::GetMe()->SendPacket(&msg);
//              }
//              break;
//          default:
//              break;
//          }
    }