protected override void HandleMsg(Frame_ReqMovePoint_Data msg)
        {
            Unit unit = BattleScene.Instance.GetUnit(msg.unitId);

            if (null != unit)
            {
                TSVector targetPosition = GameInTool.ToTSVector(msg.targetPosition);
                unit.Move(targetPosition);
            }
        }
예제 #2
0
        public void MoveUnit(Unit unit, Vector2 newPos)
        {
            var w2 = WorldScale - 0.5f; w2 *= w2;

            if (newPos.SqrLength() > w2) //Don't go outside world
            {
                newPos = newPos.Normalize() * (WorldScale - 0.5f);
            }

            unit.Move(newPos, DeltaTime, _unitsTree, _obstaclesTree);
        }
        protected override void HandleMsg(Frame_ReqMovePath_Data msg)
        {
            Unit unit = BattleScene.Instance.GetUnit(msg.unitId);

            if (unit != null)
            {
                //这个移动是一帧处理的
                List <TSVector> lstPath = GameInTool.ToLstTSVector(msg.paths);
                unit.Move(lstPath);
            }
        }