示例#1
0
    //--------------------------------------------------
    //在鼠标上存储命令
    public void MouseCommand_Set(bool bHoverInUI, CObject pSelectObj, Vector3 fvPos, tActionItem pActiveSkill)
    {
        m_cmdCurrent_Left.m_typeMouse  = MOUSE_CMD_TYPE.MCT_NULL;
        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_NULL;
        //bool bCtrlDown = CInputSystem.GetMe().IsKeyDown(KeyCode.KC_LCONTROL) || CInputSystem.GetMe().IsKeyDown(KeyCode.KC_RCONTROL);

        //在UI上空
        if (bHoverInUI)
        {
            if (UISystem.Instance.CurrHyperlink != null)
            {
                m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_HyperLink;
                m_cmdCurrent_Left.SetValue(0, UISystem.Instance.CurrHyperlink);
            }
            else if (pActiveSkill != null)
            {
                switch (pActiveSkill.GetType())
                {
                //修理装备
                case ACTION_OPTYPE.AOT_MOUSECMD_REPARE:
                {
                    //左键挂锤子
                    m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_REPAIR;
                    //右键取消
                    m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCLE_REPAIR;
                }
                break;

                //鉴定装备
                case ACTION_OPTYPE.AOT_MOUSECMD_IDENTIFY:
                {
                    //左键鉴定
                    m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_IDENTIFY;
                    //右键取消
                    m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_CANCEL_IDENTIFY;
                }
                break;

                case ACTION_OPTYPE.AOT_MOUSECMD_ADDFRIEND:
                {
                    //左键鉴定
                    m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_ADDFRIEND;
                    //右键取消
                    m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_CANCEL_ADDFRIEND;
                }
                break;

                case ACTION_OPTYPE.AOT_MOUSECMD_EXCHANGE:
                {
                    //左键鉴定
                    m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_EXCHANGE;
                    //右键取消
                    m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_CANCEL_EXCHANGE;
                }
                break;

                case ACTION_OPTYPE.AOT_MOUSECMD_SALE:
                {
                    //左键鉴定
                    m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_SALE;
                    //右键取消
                    m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCEL_SALE;
                }
                break;

                case ACTION_OPTYPE.AOT_MOUSECMD_BUYMULT:
                {
                    //左键鉴定
                    m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_BUYMULT;
                    //右键取消
                    m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCEL_BUYMULT;
                }
                break;

                default:
                    break;
                }
            }
            else
            {
                return;
            }
        }
        else
        {
            //计算相应obj鼠标指令
            if (pSelectObj != null)
            {
                pSelectObj.FillMouseCommand_Left(ref m_cmdCurrent_Left, pActiveSkill);
                pSelectObj.FillMouseCommand_Right(ref m_cmdCurrent_Right, pActiveSkill);
            }

            if (m_cmdCurrent_Left.m_typeMouse == MOUSE_CMD_TYPE.MCT_NULL)
            {
                if (pActiveSkill != null)
                {
                    switch (pActiveSkill.GetType())
                    {
                    case ACTION_OPTYPE.AOT_SKILL:
                    case ACTION_OPTYPE.AOT_PET_SKILL:
                    {
                        SCLIENT_SKILL skillImpl = (SCLIENT_SKILL)pActiveSkill.GetImpl();

                        if (skillImpl == null)
                        {
                            {
                                m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_PLAYER_MOVETO;
                                m_cmdCurrent_Left.SetValue(0, fvPos.x);
                                m_cmdCurrent_Left.SetValue(1, fvPos.z);
                            }
                            return;
                        }

                        //选择类型
                        //                              ENUM_SELECT_TYPE typeSel = (ENUM_SELECT_TYPE)( pActiveSkill.type()== ACTION_OPTYPE.AOT_SKILL ?
                        //                                  ((SCLIENT_SKILL)pSkillImpl)->m_pDefine->m_nSelectType :
                        //                                  ((PET_SKILL)pSkillImpl)->m_pDefine->m_nSelectType);

                        ENUM_SELECT_TYPE typeSel = (ENUM_SELECT_TYPE)skillImpl.m_pDefine.m_nSelectType;
                        switch (typeSel)
                        {
                        //点选角色
                        case ENUM_SELECT_TYPE.SELECT_TYPE_CHARACTER:
                        {
                            //进入这里说明逻辑出错了,不然会在character里面填充
                            //如果FillMouseCommand_Left填充失败,说明目标是不可攻击对象,执行移动操作
                            if (pSelectObj == null)
                            {
                                m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_PLAYER_MOVETO;
                                m_cmdCurrent_Left.SetValue(0, fvPos.x);
                                m_cmdCurrent_Left.SetValue(1, fvPos.z);
                            }
                        }
                        break;

                        //点选范围
                        case ENUM_SELECT_TYPE.SELECT_TYPE_POS:
                        {
                            //储存技能
                            m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_SKILL_AREA;
                            m_cmdCurrent_Left.SetValue(0, pActiveSkill);
                            m_cmdCurrent_Left.SetValue(1, fvPos.x);
                            m_cmdCurrent_Left.SetValue(2, fvPos.z);
                            //                                      FLOAT fRingRange = (FLOAT)( pActiveSkill.type()==AOT_SKILL ?
                            //                                          ((SCLIENT_SKILL*)pSkillImpl)->m_pDefine->m_fDamageRange :
                            //                                      ((PET_SKILL*)pSkillImpl)->m_pDefine->m_fDamageRange);
                            m_cmdCurrent_Left.SetValue(5, skillImpl.m_pDefine.m_fDamageRange);

                            //取消技能
                            m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCEL_SKILL;
                        }
                        break;

                        //方向
                        case ENUM_SELECT_TYPE.SELECT_TYPE_DIR:
                        {
                            //储存技能
                            m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_SKILL_DIR;
                            m_cmdCurrent_Left.SetValue(0, pActiveSkill);

                            //计算方向

                            //鼠标位置
                            Vector3 avatarPos = CObjectManager.Instance.getPlayerMySelf().GetPosition();

                            Vector3 avatarPosOnPlane = new Vector3(avatarPos.x, 0, avatarPos.z);
                            Vector3 PosOnPlane       = new Vector3(fvPos.x, 0, fvPos.z);
                            float   angle            = Vector3.Angle(avatarPosOnPlane, PosOnPlane);
                            m_cmdCurrent_Left.SetValue(1, angle);
                            //取消技能
                            m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCEL_SKILL;
                        }
                        break;

                        //add by ss 增加对无目标技能和只对自己的处理流程
                        case ENUM_SELECT_TYPE.SELECT_TYPE_SELF:
                        {
                            m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_SKILL_SELF;
                            m_cmdCurrent_Left.SetValue(0, pActiveSkill);
                            m_cmdCurrent_Left.SetValue(1, CObjectManager.Instance.getPlayerMySelf().ServerID);
                        }
                        break;

                        case ENUM_SELECT_TYPE.SELECT_TYPE_NONE:
                        {
                            m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_SKILL_NONE;
                            m_cmdCurrent_Left.SetValue(0, pActiveSkill);
                        }
                        break;
                        }
                    }
                    break;

                    case ACTION_OPTYPE.AOT_ITEM:
                    {
                        if (pActiveSkill == null || pActiveSkill.GetType() != ACTION_OPTYPE.AOT_ITEM)
                        {
                            break;
                        }

                        CObject_Item pItem = (CObject_Item)(((CActionItem_Item)pActiveSkill).GetImpl());
                        if (pItem == null)
                        {
                            break;
                        }

                        //必须是能够使用的物品,必须支持任务物品 [1/24/2011 ivan edit]
                        if (pItem.GetItemClass() != ITEM_CLASS.ICLASS_COMITEM && pItem.GetItemClass() != ITEM_CLASS.ICLASS_TASKITEM)
                        {
                            break;
                        }

                        bool bAreaItem = ((CObject_Item_Medicine)pItem).IsAreaTargetType();

                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_USE_ITEM;
                        m_cmdCurrent_Left.SetValue(0, pActiveSkill);
                        m_cmdCurrent_Left.SetValue(1, 0);
                        m_cmdCurrent_Left.SetValue(2, fvPos.x);
                        m_cmdCurrent_Left.SetValue(3, fvPos.z);
                        m_cmdCurrent_Left.SetValue(4, (int)(bAreaItem ? 1 : 0));

                        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCEL_USE_ITEM;
                    }
                    break;

                    //修理单独处理
                    case ACTION_OPTYPE.AOT_MOUSECMD_REPARE:
                    {
                        //左键挂锤子
                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_REPAIR;
                        //右键取消
                        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCLE_REPAIR;
                    }
                    break;

                    //鉴定装备
                    case ACTION_OPTYPE.AOT_MOUSECMD_IDENTIFY:
                    {
                        //左键鉴定
                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_IDENTIFY;
                        //右键取消
                        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_CANCEL_IDENTIFY;
                    }
                    break;

                    case ACTION_OPTYPE.AOT_MOUSECMD_ADDFRIEND:
                    {
                        //左键鉴定
                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_ADDFRIEND;
                        //右键取消
                        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_CANCEL_ADDFRIEND;
                    }
                    break;

                    case ACTION_OPTYPE.AOT_MOUSECMD_EXCHANGE:
                    {
                        //左键鉴定
                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_EXCHANGE;
                        //右键取消
                        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_UI_USE_CANCEL_EXCHANGE;
                    }
                    break;

                    case ACTION_OPTYPE.AOT_MOUSECMD_CATCHPET:
                    {
                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_CATCH_PET;
                        m_cmdCurrent_Left.SetValue(0, fvPos.x);
                        m_cmdCurrent_Left.SetValue(1, fvPos.z);
                    }
                    break;

                    case ACTION_OPTYPE.AOT_MOUSECMD_SALE:
                    {
                        //左键鉴定
                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_SALE;
                        //右键取消
                        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCEL_SALE;
                    }
                    break;

                    case ACTION_OPTYPE.AOT_MOUSECMD_BUYMULT:
                    {
                        //左键
                        m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_BUYMULT;
                        //右键
                        m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_CANCEL_BUYMULT;
                    }
                    break;

                    default:
                        //移动
                    {
                        //if (pSelectObj != CObjectManager.Instance.getPlayerMySelf())
                        {
                            m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_PLAYER_MOVETO;
                            m_cmdCurrent_Left.SetValue(0, fvPos.x);
                            m_cmdCurrent_Left.SetValue(1, fvPos.z);
                        }
                    }
                    break;
                    }
                }
                else //temp fix 添加默认左键事件, TODO,find其他地方是否有默认左键事件
                {
                    //移动
                    {
                        if (pSelectObj == null)
                        {
                            m_cmdCurrent_Left.m_typeMouse = MOUSE_CMD_TYPE.MCT_PLAYER_MOVETO;
                            m_cmdCurrent_Left.SetValue(0, fvPos.x);
                            m_cmdCurrent_Left.SetValue(1, fvPos.z);
                        }
                    }
                }
            }
            //选择玩家
            if (m_cmdCurrent_Right.m_typeMouse == MOUSE_CMD_TYPE.MCT_NULL)
            {
                m_cmdCurrent_Right.m_typeMouse = MOUSE_CMD_TYPE.MCT_PLAYER_SELECT;
                m_cmdCurrent_Right.SetValue(0, -1);
            }
        }
    }