MapServer.PlayerObject.Move C# (CSharp) Method

Move() public method

public Move ( NetMsg move ) : bool
move NetMsg
return bool
        public bool Move(NetMsg.MsgMoveInfo move)
        {
            if (!this.GetMagicSystem().CheckMoveSpeed())
            {
                this.ScroolRandom(this.GetCurrentX(), this.GetCurrentY());

                return false;
            }
            // testeudemon();
            byte dir = (byte)((int)move.dir % 8);
            this.SetDir(dir);

            short nNewX = GetCurrentX();
            short nNewY = GetCurrentY();
            nNewX += DIR._DELTA_X[dir];
            nNewY += DIR._DELTA_Y[dir];
            if (!mGameMap.CanMove(nNewX, nNewY))
            {
                nNewX = this.GetCurrentX();
                nNewY = this.GetCurrentY();
                if (!mGameMap.CanMove(nNewX, nNewY))
                {
                    nNewX = (short)mGameMap.GetMapInfo().recallx;
                    nNewY = (short)mGameMap.GetMapInfo().recally;
                }
                //暂时使用随机卷的方式重置玩家坐标
                this.ScroolRandom(nNewX, nNewY);
               // Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString());
                return false;
            }
            // 跑步模式的阻挡判断
            bool IsRun = false;
            if (move.ucMode >= DIR.MOVEMODE_RUN_DIR0 && move.ucMode <= DIR.MOVEMODE_RUN_DIR7 && GetBaseAttr().sp > 0 /*没有体力不让跑*/)
            {

                nNewX += DIR._DELTA_X[move.ucMode - DIR.MOVEMODE_RUN_DIR0];
                nNewY += DIR._DELTA_Y[move.ucMode - DIR.MOVEMODE_RUN_DIR0];
                IsRun = true;
                if (!mGameMap.CanMove(nNewX, nNewY))
                {
                    nNewX = this.GetCurrentX();
                    nNewY = this.GetCurrentY();
                    if (!mGameMap.CanMove(nNewX, nNewY))
                    {
                        nNewX = (short)mGameMap.GetMapInfo().recallx;
                        nNewY = (short)mGameMap.GetMapInfo().recally;
                    }
                    //暂时使用随机卷的方式重置玩家坐标
                    this.ScroolRandom(nNewX, nNewY);
                    //Log.Instance().WriteLog("非法封包..禁止走路!!x:" + nNewX.ToString() + "y:" + nNewY.ToString());
                    //Log.Instance().WriteLog("这个家伙肯定用了外挂,不如我们把他封号吧,角色名称:" + this.GetName() +
                    //    "如果下次他还开外挂,就把他硬盘里的种子全删掉...");
                    return false;
                }
            }
            //传送点判断
            uint mapid = 0; short x = 0; short y = 0;
            if (ConfigManager.Instance().CheckMapGate(this.GetGameMap().GetMapInfo().id, nNewX, nNewY, ref mapid, ref x, ref y))
            {
                this.ChangeMap(mapid, x, y);
                return false;
            }
            if (GetBaseAttr().sp <= 0) move.ucMode = 0;
            SetPoint(nNewX, nNewY);

            GameStruct.Action action = new GameStruct.Action(GameStruct.Action.MOVE);
            if (IsRun) action.AddObject(move.ucMode);

            //解除锁定目标
            this.GetFightSystem().SetAutoAttackTarget(null);
            PushAction(action);
            return true;
        }