Ejemplo n.º 1
0
    public void ExecuteSkillFailed(GameCmd.stMultiAttackReturnMagicUserCmd_S cmd)
    {
        ISkillPart skillPart = SkillHelper.GetSkillPart(cmd.dwUserID, EntityType.EntityType_Player);

        if (skillPart == null)
        {
            Engine.Utility.Log.Error("获取主角技能部件失败!");
            return;
        }
        else
        {
            Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.SKILLGUIDE_PROGRESSBREAK,
                                                                new stGuildBreak()
            {
                action = GameCmd.UninterruptActionType.UninterruptActionType_SkillCJ, uid = cmd.dwUserID, skillid = cmd.wdSkillID
            });
            TimerAxis.Instance().KillTimer(m_uReadSliderTimerID, this);
            string str = "";// "skill error code = " + cmd.fail_code + " ";
            if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_success)
            {
                //使用成功
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_break)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_jinengbeidaduan);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_use)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_jinengzhengzaishiyong);
                Log.Error("使用过程 error code {0}", cmd.fail_code);
            }

            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_outRange)
            {
                Client.IControllerSystem cs = ClientGlobal.Instance().GetControllerSystem();
                if (cs != null)
                {
                    Client.ICombatRobot robot = cs.GetCombatRobot();
                    if (robot != null && robot.Status == CombatRobotStatus.RUNNING)
                    {
                        if (MainPlayerHelper.GetMainPlayer() == null)
                        {
                            return;
                        }
                        ISkillPart sp = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as ISkillPart;
                        if (sp == null)
                        {
                            return;
                        }

                        if (sp.GetSkillTarget() != null)
                        {
                            Move    move     = new Move();
                            Vector3 targePos = sp.GetSkillTarget().GetPos();
                            Vector3 dir      = targePos - MainPlayerHelper.GetMainPlayer().GetPos();
                            targePos           = targePos - dir.normalized * 1f;
                            move.m_target      = targePos;
                            move.m_ignoreStand = true;
                            Log.Error("自动挂机,打不到,朝向目标移动");

                            IController ctr = cs.GetActiveCtrl();
                            if (ctr != null)
                            {
                                ctr.MoveToTarget(targePos);
                            }
                            //MainPlayerHelper.GetMainPlayer().SendMessage(EntityMessage.EntityCommand_MoveTo, (object)move);
                            // Vector3 lookat = playerSkill.GetSkillTarget().GetNode().GetTransForm().forward;
                            return;
                        }
                    }
                }

                str = GetLocalText(LocalTextType.Skill_Commond_mubiaochaochugongjijuli);
                Log.Error("技能使用超超出范围 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_shapeErr)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_bianshenzhuangtaixiabunengshiyongjineng);
                Log.Error("变身不能使用技能 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_petFight)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_chongwuweichuzhanbunengshiyongjineng);
                Log.Error("宠物未出战不能使用技能 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_notExist)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_jinengbucunzai);
                Log.Error("技能不存在 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_none)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_jinengweizhicuowu);
                Log.Error("技能未知 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_needAim)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_shifanggaijinengxuyaoxuanzemubiao);
                Log.Error("技能需要目标error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_aimErr)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_mubiaoxuanzecuowu);
                Log.Error("技能目标错误 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_cantAtt)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_dangqianmubiaowufagongji);
                Log.Error("目标无法攻击 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_inCD)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_jinenglengquezhong);
                Log.Error("技能冷却中 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_lackSP)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_fashuzhibuzu);
                Log.Error("缺蓝 error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_flagsErr)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_dangqianjinengzhuangtaicuowu);
                Log.Error("flags error code {0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_NeedItemNumNotEnough)
            {
                str = GetLocalText(LocalTextType.Skill_Commond_shiyongchongwujinnegsuoxudaojubuzu);
                Log.Error("使用宠物技能所需道具不足{0}", cmd.fail_code);
            }
            else if (cmd.fail_code == (int)GameCmd.UseSkillFail.UseSkillFail_rideCantUse)
            {
                NetService.Instance.Send(new GameCmd.stDownRideUserCmd_C()
                {
                });
                return;
                //str = GetLocalText(LocalTextType.Skill_Commond_qichengzhuangtaiwufashiyongzhujuejineng);
                //Log.Error("骑乘无法使用技能{0}", cmd.fail_code);
            }
            else if (cmd.fail_code == 16)
            {                        //协议未更新 先写数字防止后期忘了
                str = "眩晕状态,技能不能使用"; // GetLocalText(LocalTextType.Skill_Commond_qichengzhuangtaiwufashiyongzhujuejineng);
                Log.Error("瞬移技能不能使用{0}", cmd.fail_code);
            }
            else
            {
                str = GetLocalText(LocalTextType.Skill_Commond_jinengweizhicuowu);
                Log.Error("技能未知错误 ");
            }
            if (cmd.dwUserID == MainPlayerHelper.GetPlayerID())
            {
                TipsManager.Instance.ShowTips(str);
            }
        }

        skillPart.OnUseSkillFailed(cmd.dwUserID, cmd.wdSkillID);
    }