示例#1
0
        /**计算出路径段
         * @param fromMapId 开始场景ID
         * @param toMapId   目标场景ID
         * @param NpcVo     是否寻路到NPC前(null:寻路到场景,!=null:寻路到NPC前)
         * @param MonsterVo 是否寻路到怪物前
         * **/
        //private bool findPath(string fromMapId,string toMapId,NpcVo npcVo=null,SysMonsterVo monsterVo=null) {
        //SysMapVo toMapVo = BaseDataMgr.instance.GetMapVo(toMapId);
        //SysMapVo fromMapVo = BaseDataMgr.instance.GetMapVo(fromMapId);
        //if (toMapVo == null || fromMapVo == null) return false;

        //string startMapId = null; // fromMapVo.type == MapTypeConst.FIELD_BOSS_MAP ? fromMapVo.preId : fromMapId;
        //string endMapId = null; //toMapVo.type == MapTypeConst.FIELD_BOSS_MAP ? toMapVo.preId : toMapId;
        //string fromMainMapId = findMainMapId(startMapId);                 //开始场景的主城场景ID
        //string toMainMapId = findMainMapId(endMapId);                     //目标场景的主城场景ID
        //if (fromMainMapId == null || toMainMapId == null) return false;
        //Log.info(this, "-findPath() 开始场景:" + fromMapId + ",所在主城:" + fromMainMapId);
        //Log.info(this, "-findPath() 目标场景:" + toMapId + ",所在主城:" + toMainMapId);

        //if (fromMainMapId.Equals(toMainMapId))
        //{//当前环寻路
        //    Log.info(this, "-findPath() 当前环寻路!");
        //    if (startMapId.Equals(fromMainMapId))
        //    {//当前所在:主城场景,只需下寻
        //        findMapLinks(startMapId, endMapId, false);
        //    }
        //    else
        //    {//当前所在:非主城场景,先上寻再下寻
        //        findMapLinks(startMapId, endMapId, true);
        //        if (tempMapList.Count < 1) findMapLinks(startMapId, endMapId, false);
        //    }

        //    //构造路径列表
        //    int len = 0;


        //    for (int i = 0; i < tempMapList.Count; i++)
        //    {
        //        add2PathList(++len, TO_STEP_SCENE, tempMapList[i]);
        //    }

        //    if (npcVo != null)     add2PathList(++len, TO_STEP_NPC, npcVo.id);
        //    if (monsterVo != null) add2PathList(++len, TO_STEP_MONSTER, monsterVo.id.ToString());
        //    if (pathLen < 1) return false;
        //}
        //else
        //{//不同环寻路
        //    Log.info(this, "-findPath() 不同环寻路!");
        //    //当前环
        //    if (startMapId.Equals(fromMainMapId))
        //    {//当前所在:主城场景
        //        tempMapList.Clear();
        //        tempMapList.Add(fromMainMapId);
        //    }
        //    else
        //    {//当前所在:非主城场景
        //        findMapLinks(startMapId, fromMainMapId, true);
        //    }
        //    if (tempMapList.Count < 1) return false;

        //    int len = 0;


        //    for (int i = 0; i < tempMapList.Count; i++)
        //    {
        //        add2PathList(++len, TO_STEP_SCENE, tempMapList[i]);
        //    }
        //    add2PathList(++len, TO_STEP_SCENE, fromMainMapId);
        //    add2PathList(++len, TO_STEP_WORLDMAP, toMainMapId);

        //    //新环
        //    if (!toMainMapId.Equals(toMapId))
        //    {
        //        findMapLinks(toMainMapId, endMapId, false);
        //        if (tempMapList.Count < 1) return false;
        //        for (int j = 0; j < tempMapList.Count; j++)
        //        {
        //            add2PathList(++len, TO_STEP_SCENE, tempMapList[j]);
        //        }
        //    }

        //    if (npcVo != null)     add2PathList(++len, TO_STEP_NPC, npcVo.id);
        //    if (monsterVo != null) add2PathList(++len, TO_STEP_MONSTER, monsterVo.id.ToString());
        //}
        //println();
        //return true;
        //}

        /**打印路径**/
        private void println()
        {
            Log.info(this, "=========================================\n");
            PathStepVo stepVo = null;

            for (int i = 0; i < pathLen; i++)
            {
                stepVo = pathList[i];
                Log.info(this, "[" + stepVo.stepDesc() + "] targetId:" + stepVo.targetId);
            }
            Log.info(this, "=========================================\n");
        }
示例#2
0
        /**添加阶段轨迹到列表
         * @param index    在轨迹列表中位置下标从1开始
         * @param stepType 到达阶段目标点类型[TO_STEP_NPC,TO_STEP_COPY,TO_STEP_SCENE,TO_STEP_WORLDMAP]
         * @param targetId 到达阶段目标点ID  [npcId,copyId,MapId]
         * @param isUpWalk 是否向上寻走[true:向上寻,false:向下寻],该标记决定本玩家在场景出生点坐标
         * **/
        private void add2PathList(int index, int stepType, string targetId)
        {
            if (pathList.Count < index)
            {
                pathList.Add(new PathStepVo());
            }
            PathStepVo pathStepVo = pathList[index - 1];

            pathStepVo.stepType = stepType;
            pathStepVo.targetId = targetId;
            pathLen++;
        }
示例#3
0
        /**自动行走**/
        public void autoWalk()
        {
            curStep++;
            //Log.info(this, "-autoWalk() isRoading:" + isRoading + ",curStep:" + curStep + ",pathLen:" + pathLen);
            if (isRoading == false || curStep >= pathLen)
            {
                curStep   = -1;
                isRoading = false;
                //if (battleControl != null) battleControl.isAutoRoad = false;
                //Log.info(this, "-autoWalk() 自动寻路已结束,battleControl.isAutoRoad:" + (battleControl != null ? battleControl.isAutoRoad : false) + ",battleControl:" + battleControl);
                return;
            }

            PathStepVo stepVo = pathList[curStep];
            //if (battleControl != null) battleControl.isAutoRoad = true;
            MonsterVo enemyVo;

            switch (stepVo.stepType)
            {
            case TO_STEP_NPC:
                moveTo(AppMap.Instance.GetNpc(stepVo.targetId), moveEndBack);
                break;

            case TO_STEP_SCENE:
                moveTo(AppMap.Instance.GetMapPoint(stepVo.targetId));
                break;

            case TO_STEP_WORLDMAP:
                //worldmapControl.moveTo(stepVo.targetId);
                break;

            case TO_STEP_MONSTER:
                MonsterDisplay monster = getMonsterWithUid(stepVo.targetId);
                if (monster != null)
                {
                    moveTo(monster, moveEndBack);
                }
                else
                {     //从等待队列中找
                    enemyVo = MonsterMgr.Instance.GetMonster(stepVo.targetId);
                    if (enemyVo != null)
                    {
                        (AppMap.Instance.me.Controller as MeControler).MoveToAndTellServer(enemyVo.X, enemyVo.Y, moveEndBack);
                    }
                }
                break;
            }
        }
示例#4
0
        /**自动行走**/
        public void autoWalk()
        {
            curStep++;
            if (isRoading == false || curStep >= pathLen)
            {
                curStep   = -1;
                isRoading = false;
                Log.info(this, "-autoWalk() 自动寻路已结束!");
                //if (battleControler != null) battleControler.isAutoRoad = false;
                return;
            }

            Log.info(this, "-autoWalk() 开始自动寻路!");
            PathStepVo stepVo = pathList[curStep];

            //if (battleControler != null) battleControler.isAutoRoad = true;

            switch (stepVo.stepType)
            {
            case TO_STEP_NPC:
                moveTo(AppMap.Instance.GetNpc(stepVo.targetId));
                break;

            case TO_STEP_COPY:
                //根据副本组ID取得副本传送点
                moveTo(AppMap.Instance.GetCopyPoint(stepVo.targetId));
                break;

            case TO_STEP_SCENE:
                moveTo(AppMap.Instance.MapPointDisplay);
                break;

            case TO_STEP_WORLDMAP:
                //worldmapControl.moveTo(stepVo.targetId);
                break;
            }
        }