Beispiel #1
0
    private void DoAction_Packet()
    {
        // 判断商店是否开启 [2/20/2012 Ivan]
        if (UISystem.Instance.IsWindowShow("ShopWindow"))
        {
            //    //是否在修理状态
            //if(CActionSystem::GetMe()->GetDefaultAction() == CActionItem_MouseCmd_Repair::GetMe())
            //{
            //    //取消修理
            //    CGameProcedure::s_pGameInterface->Skill_CancelAction();
            //}
            ////执行销售
            //else
            {
                //任务物品不可以卖
                if (ItemImpl.GetItemClass() == ITEM_CLASS.ICLASS_TASKITEM)
                {
                    //任务物品不能卖的信息提示
                    //if(bLog)
                    //{
                    //    STRING strTemp = "这件物品不能出售";//NOCOLORMSGFUNC("stall_sold_failure");
                    //    ADDNEWDEBUGMSG(strTemp);
                    //}
                }
                else
                {
                    GameProcedure.s_pGameInterface.Booth_SellItem(ItemImpl);
                }
            }

            return;
        }
        //银行开启
        else if (GameProcedure.s_pUISystem != null && UISystem.Instance.IsWindowShow("StoreWindow"))
        {
            //需要先判定是不是能够存入银行的物品
            if (ItemImpl != null && ItemImpl.GetItemClass() == ITEM_CLASS.ICLASS_TASKITEM)
            //if(pItem->GetPosIndex() >= TASK_CONTAINER_OFFSET )
            {
                //任务物品不能放入银行
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "任务物品不能存入银行");
                return;
            }


            CGBankAddItem msg = new CGBankAddItem();
            msg.FromType  = (byte)(CGBankAddItem.AddType.BAG_POS);
            msg.IndexFrom = (byte)(GetPosIndex());
            msg.IndexTo   = (byte)CGBankAddItem.AutoPosBox.AUTO_POS_BOX1;

            //检测这个租赁箱是不是有空位
            if (!CDataPool.Instance.UserBank_IsEmpty(1))
            {
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "仓库已经满了");
                return;
            }

            NetManager.GetNetManager().SendPacket(msg);

            return;
        }
        else// 没有打开任何其他窗口的时候 [2/20/2012 Ivan]
        {
            switch (ItemImpl.GetItemClass())
            {
            case ITEM_CLASS.ICLASS_EQUIP:
                //装备
            {
                //使用
                CObject_Item_Equip curEquipt = ItemImpl as CObject_Item_Equip;
                //装备宠物
                if (GameProcedure.s_pUISystem != null &&
                    UISystem.Instance.IsWindowShow("RoleTipWindow") &&
                    curEquipt != null)
                {
                    if (!curEquipt.IsPetEquipt())
                    {
                        GameInterface.Instance.PacketItem_UserEquip(ItemImpl);        // CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "该装备不是宠物装备");
                    }
                    else
                    {
                        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   = 0;
                            msg.GUID           = curPet.GUID;
                            msg.SourecBagIndex = (byte)GetPosIndex();
                            msg.DestBagIndex   = (byte)curEquipt.GetItemType();
                            NetManager.GetNetManager().SendPacket(msg);
                        }
                    }
                }
                else
                {
                    if (curEquipt != null)
                    {
                        if (!curEquipt.IsPetEquipt())
                        {
                            GameInterface.Instance.PacketItem_UserEquip(ItemImpl);
                        }
                        else
                        {
                            CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "该装备只能给宠物使用");
                        }
                    }
                    else
                    {
                        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "该物品不是装备");
                    }
                }
            }
            break;

            case ITEM_CLASS.ICLASS_MATERIAL:
                break;

            case ITEM_CLASS.ICLASS_COMITEM:
            case ITEM_CLASS.ICLASS_TASKITEM:
            case ITEM_CLASS.ICLASS_STOREMAP:
            {
                int iType = ItemImpl.GetItemTableType();

                //摆摊时不可以随便使用物品
//                      if(TRUE == CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_IsInStall())
//                      {
//                          CEventSystem::GetMe()->PushEvent(GE_INFO_SELF,"你正在摆摊……");
//                          break;
//                      }

                //验证是否可以使用
                if (!ItemImpl.Rule(ITEM_RULE.RULE_USE))
                {
                    CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, ItemImpl.RuleFailMessage(ITEM_RULE.RULE_USE));
                    return;
                }

                //检查冷却是否结束
                if (!CoolDownIsOver())
                {
                    CActionSystem.Instance.SetoutAction = this;
                    CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF,
                                                    GameDefineResult.Instance.GetOResultText(OPERATE_RESULT.OR_COOL_DOWNING));
                    break;
                }
                CObject pMainTarget = CObjectManager.Instance.GetMainTarget();
                //使用物品时自动下坐骑  [3/14/2012 ZZY]
                bool result = CObjectManager.Instance.getPlayerMySelf().UnRideUseItem(this,
                                                                                      (pMainTarget != null ? pMainTarget.ServerID : -1),
                                                                                      new Vector2(-1, -1));

                if (!result)
                {
                    GameInterface.Instance.PacketItem_UserItem(this, (pMainTarget != null? pMainTarget.ServerID:-1),
                                                               new Vector2(-1, -1));
                }
            }
            break;

            case ITEM_CLASS.ICLASS_GEM:
                break;

            case ITEM_CLASS.ICLASS_SYMBOLITEM:    //  [3/22/2012 ZZY]
                //请求使用符印
                GameInterface.Instance.PacketItem_UserSymbol(this);
                break;

            case ITEM_CLASS.ICLASS_TALISMAN:
                break;

            case ITEM_CLASS.ICLASS_GUILDITEM:
                break;

            case ITEM_CLASS.ICLASS_NUMBER:
                break;

            default:
                break;
            }
        }
    }
Beispiel #2
0
    //////////////////////////////////////////////////////////////////////////
    // 所有标记 [7/14/2011 ivan edit]
    // case 'S':		//摆摊界面
    // case 'Q':		//任务提交界面(MissionReply)
    // case 'B':		//银行
    // case 'P':		//背包
    // case 'E':		//交易界面,只能拖动到自己的(右边的)格子里头(1~6)
    // case 'R':		//银行的界面上的租赁箱格子
    // case 'G':		//宝石合成/镶嵌界面
    // case 'C':		//装备打孔 [7/14/2011 ivan edit]
    // case 'T':		//宠物技能学习/还童/延长寿命/宠物驯养/宠物征友
    // case 'Z':		//人物装备界面
    // case 'A':		//玩家商店
    // case 'M':		//主菜单
    // case 'Y':		//对象头像
    // case 'L':		//自己头像
    // case 'I':		// 装备强化 [7/18/2011 ivan edit]
    // case 'E':        // 宠物装备
    //////////////////////////////////////////////////////////////////////////
    public override void NotifyDragDropDragged(bool bDestory, string szTargetName, string szSourceName)
    {
        //LogManager.LogWarning("Drag From:" + szSourceName + " to:" + szTargetName);
        //拖动到表示销毁的地方
        if (bDestory)
        {
            DestoryItem(szSourceName);
            return;
        }
        //拖动到空白地方
        if (szTargetName == "")
        {
            return;
        }

        char cSourceName = szSourceName[0];
        char cTargetType = szTargetName[0];

        //如果是快捷栏,不能往其他地方拖,除了自己本身。
        if (cSourceName == 'M' &&
            cTargetType != 'M')
        {
            return;
        }

        switch (cTargetType)
        {
        case 'P':
            NotifyPacketDrag(szSourceName, szTargetName);
            break;

        case 'E':
        {
            ITEM_OWNER typeOwner = ItemImpl.TypeOwner;
            switch (typeOwner)
            {
            case ITEM_OWNER.IO_MYSELF_PACKET:
            {
                // 发送装备宠物装备消息.
                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);
                    int       tarIndex = Convert.ToInt32(szTargetName.Substring(1, szTargetName.Length - 1)) - 1;
                    if ((int)curEquipt.GetItemType() != tarIndex)
                    {
                        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "该装备不能装备到目标位置");
                    }
                    else if (!curEquipt.IsPetEquipt())
                    {
                        CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "该装备不能装备到宠物上");
                    }
                    else if (curPet != null &&
                             curEquipt != null)
                    {
                        CGOperatePetEquip msg = new CGOperatePetEquip();
                        msg.OperatorType   = 0;
                        msg.GUID           = curPet.GUID;
                        msg.DestBagIndex   = (byte)curEquipt.GetItemType();
                        msg.SourecBagIndex = (byte)GetPosIndex();
                        NetManager.GetNetManager().SendPacket(msg);
                    }
                }
            }
            break;
            }
        }
        break;

        case 'B':    //bank
        {
            int tarIndex = Convert.ToInt32(szTargetName.Substring(1, szTargetName.Length - 1)) - 1;

            if (!CDataPool.Instance.UserBank_IsValid(tarIndex))
            {
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "格子未解封");
                return;
            }
            //根据物品的来源决定发送什么消息
            ITEM_OWNER typeOwner = ItemImpl.TypeOwner;
            //任务物品不能放入银行
            if (ItemImpl.GetItemClass() == ITEM_CLASS.ICLASS_TASKITEM)
            {
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "任务物品不能放入");
                return;
            }
            switch (typeOwner)
            {
            case ITEM_OWNER.IO_MYSELF_PACKET:                                           //来自玩家的背包
            {
                CGBankAddItem msg = new CGBankAddItem();
                msg.FromType  = (byte)(CGBankAddItem.AddType.BAG_POS);
                msg.IndexFrom = (byte)GetPosIndex();
                msg.IndexTo   = (byte)tarIndex;
                NetManager.GetNetManager().SendPacket(msg);
            }
            break;

            case ITEM_OWNER.IO_MYSELF_BANK:                                             //来自银行内部
            {
                CGBankSwapItem msg = new CGBankSwapItem();
                msg.FromType  = (byte)CGBankSwapItem.AddType.BANK_POS;
                msg.IndexFrom = (byte)GetPosIndex();
                msg.IndexTo   = (byte)tarIndex;
                msg.ToType    = (byte)(CGBankSwapItem.AddType.BANK_POS);
                if (msg.IndexFrom == msg.IndexTo)
                {
                    break;
                }
                NetManager.GetNetManager().SendPacket(msg);
            }
            break;

            default:
                break;
            }
        }
        break;
        }
        //switch(cSourceName)
        //{
        //case 'M':
        //    {
        //        INT nIndex = szSourceName[1]-'0';
        //        nIndex = szSourceName[2]-'0' + nIndex*10 ;
        //        CActionSystem::GetMe()->MainMenuBar_Set(nIndex, nOldTargetId);
        //    }
        //    break;
        //default:
        //    break;
        //}

        //CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_SUPERTOOLTIP);
    }