コード例 #1
0
ファイル: AutoMission.cs プロジェクト: zuojiashun/src
    private void OnDoingTask(QuestTraceInfo taskInfo)
    {
        DataManager.Manager <TaskDataManager>().DoingTaskID = taskInfo.taskId;

        Client.IController controller = Client.ClientGlobal.Instance().GetControllerSystem().GetActiveCtrl();
        if (controller == null)
        {
            Engine.Utility.Log.Error("IController is null");

            return;
        }
        table.QuestDataBase questDB = taskInfo.QuestTable;
        if (questDB == null)
        {
            Engine.Utility.Log.Error("QuestTable is null");
            return;
        }
        UnityEngine.Vector2 pos;
        uint    npcid = 0;
        PanelID pid;
        int     copyID;
        int     tab = 0;
        uint    jumpId;

        //背包满了  无法执行任务
        if (false == taskInfo.TaskItemCanPutInKanpsack())
        {
            TipsManager.Instance.ShowTips(LocalTextType.Task_Commond_3);
            return;
        }

        if (MainPlayerIsChangeBody())
        {
            return;
        }
        else if (taskInfo.taskSubType == TaskSubType.SubmitLimit) //断档任务
        {
            if (taskInfo.IsOpenUI(out jumpId))
            {
                ItemManager.DoJump(jumpId);
            }
            else
            {
                string des = string.Format("将等级提升到{0}级继续主线任务", taskInfo.finishLevel);
                TipsManager.Instance.ShowTips(des);
            }
            return;
        }
        else if (taskInfo.IsDynamicCommitItem) //动态道具递交(蚩尤乱世除外)
        {
            taskInfo.DoJump();
            return;
        }
        else if (DataManager.Manager <ComBatCopyDataManager>().IsEnterCopy == false && taskInfo.IsOpenUI(out jumpId))
        {
            ItemManager.DoJump(jumpId);
            return;
        }
        else if (taskInfo.IsMoveToTargetPos(out pos))
        {
            //if (DataManager.Manager<TaskDataManager>().IsShowSlider)
            if (DataManager.Manager <SliderDataManager>().IsReadingSlider)
            {
                return;
            }
            Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem();
            if (cs == null)
            {
                return;
            }

            if (!m_bAddStopMoveListener)
            {
                m_bAddStopMoveListener = true;
                Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent);
            }

            if (EqualsMapID(questDB.destMapID))
            {
                cs.GetCombatRobot().Stop();
                DataManager.Manager <RideManager>().TryUsingRide(delegate(object o)
                {
                    //if (!m_bAddStopMoveListener)
                    //{
                    //    m_bAddStopMoveListener = true;
                    //    Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent);
                    //}
                    m_nDoingTaskID = taskInfo.taskId;
                    controller.GotoMap(questDB.destMapID, new Vector3(pos.x, 0, -pos.y));
                }, null);
                return;
            }
            else
            {
                DataManager.Manager <RideManager>().TryUsingRide(delegate(object o)
                {
                    if (questDB.dwHelpDoing)
                    {
                        m_nDoingTaskID = taskInfo.taskId;

                        //下载地图检查
                        if (!KHttpDown.Instance().SceneFileExists(questDB.destMapID))
                        {
                            //打开下载界面
                            DataManager.Manager <UIPanelManager>().ShowPanel(PanelID.DownloadPanel);
                            return;
                        }

                        controller.GotoMapDirectly(questDB.destMapID, new Vector3(pos.x, 0, -pos.y), questDB.dwID);
                    }
                }, null);
            }
        }
        else if (taskInfo.IsVisitCollectNpc(out npcid) || taskInfo.IsDeleverItem(out npcid))
        {
            AddCollectNpcEffect(taskInfo);

            DataManager.Manager <RideManager>().TryUsingRide(delegate(object o)
            {
                VisitNpc(questDB.dwHelpDoing, questDB.destMapID, npcid, questDB.dwID);
            }, null);
        }
        else if (taskInfo.IsDirectlyVisitCopy(taskInfo.copyId) && false == EqualsMapID(questDB.destMapID))
        {
            //直接跳副本
            VisitCopy(taskInfo.copyId);
        }
        else if (taskInfo.IsKillMonster(out npcid))
        {
            Client.ICombatRobot robot = Client.ClientGlobal.Instance().GetControllerSystem().GetCombatRobot();
            if (robot == null)
            {
                Engine.Utility.Log.Error("robotis null");

                return;
            }
            if (robot.Status == Client.CombatRobotStatus.RUNNING && robot.TargetId == npcid)
            {
                Engine.Utility.Log.Info("已经在挂机杀怪{0}", npcid);
                return;
            }
            //TODO 优化
            bool getPos = false;
            if (EqualsMapID(questDB.destMapID))
            {
                Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem();
                if (ms.GetClienNpcPos((int)npcid, out pos))
                {
                    getPos = true;
                    Vector3 mainPos = Client.ClientGlobal.Instance().MainPlayer.GetPos();
                    if ((mainPos - new Vector3(pos.x, mainPos.y, -pos.y)).sqrMagnitude < 5)
                    {
                        Client.IControllerSystem cs = Client.ClientGlobal.Instance().GetControllerSystem();
                        if (cs != null)
                        {
                            cs.GetCombatRobot().StartWithTarget((int)npcid);
                            Engine.Utility.Log.LogGroup("ZCX", "挂机杀怪物{0}", npcid);
                            return;
                        }
                    }
                }
            }

            DataManager.Manager <RideManager>().TryUsingRide(delegate(object o)
            {
                if (!m_bAddStopMoveListener)
                {
                    m_bAddStopMoveListener = true;
                    Engine.Utility.EventEngine.Instance().AddEventListener((int)Client.GameEventID.ENTITYSYSTEM_ENTITYSTOPMOVE, OnEvent);
                }
                m_nDoingTaskID = taskInfo.taskId;
                if (getPos)
                {
                    controller.MoveToTarget(new Vector3(pos.x, 0, -pos.y), null, true);
                }
                else if (EqualsMapID(questDB.destMapID))
                {
                    Client.IMapSystem ms = Client.ClientGlobal.Instance().GetMapSystem();
                    if (ms.GetClienNpcPos((int)npcid, out pos))
                    {
                        controller.MoveToTarget(new Vector3(pos.x, 0, -pos.y), null, true);
                    }
                }
                else
                {
                    VisitNpc(questDB.dwHelpDoing, questDB.destMapID, npcid, questDB.dwID);
                }
            }, null);
        }
    }