Beispiel #1
0
        private void TryMove(EDirection MoveDir, TileMap TileMap)
        {
            Point2D newCell = DrawHelper.Vector2ToEngineCell(mPosition) + MoveDir.ToPoint2D();

            mCurrentDirection = MoveDir;
            if (EngineCore.InputHelper.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.LeftShift) == true)
            {
                return;                 // no move, only Dir Change
            }
            if (CanMove(newCell, TileMap) == false)
            {
                return;
            }

            if (Character != null)
            {
                Character.Move(newCell);
            }
            mFinalPosition = DrawHelper.EngineCellToVector(newCell);
        }
Beispiel #2
0
 public static Point3D ToPoint3D(this EDirection direction)
 {
     return(new Point3D(direction.ToPoint2D()));
 }
Beispiel #3
0
 public virtual void Move(EDirection D)
 {
     Move(D.ToPoint2D());
 }
Beispiel #4
0
		private void TryMove( EDirection MoveDir, TileMap TileMap ) {
			Point2D newCell = DrawHelper.Vector2ToEngineCell( mPosition ) + MoveDir.ToPoint2D();

			mCurrentDirection = MoveDir;
			if( EngineCore.InputHelper.IsKeyDown( Microsoft.Xna.Framework.Input.Keys.LeftShift ) == true )
				return; // no move, only Dir Change 

			if( CanMove( newCell, TileMap ) == false )
				return;

			if( Character != null )
				Character.Move( newCell );
			mFinalPosition = DrawHelper.EngineCellToVector( newCell );
		}
Beispiel #5
0
        public static void WalkToXY_Tick(WorldObjectUnit obj)
        {
            if (obj.Walkpath == null)
            {
                return;
            }
            else if (obj.Walkpath.path_pos >= obj.Walkpath.path_len)
            {
                return;
            }
            else if (obj.Walkpath.path[obj.Walkpath.path_pos] == EDirection.None)
            {
                return;
            }
            else if ((int)obj.Walkpath.path[obj.Walkpath.path_pos] > 8)
            {
                return;
            }
            else
            {
            }

            // TODO: this is the point there the client seems to look laggy
            //		 eAthena sends before any movement the WalkOk() packet
            //		 and the client animates the move to the target location.
            //		 But if we attacked by a skill or w00tever,
            //		 eAthena updates the position (i think)
            //		 AND THIS is the all-known movement/position-reset.
            //
            //		 In future, we may test to send a WalkOk() Packet in every single step
            //		 So the client maybe display it more accurate..

            EDirection dir       = obj.Walkpath.path[obj.Walkpath.path_pos];
            Point2D    targetLoc = obj.Location.Point + dir.ToPoint2D();

            ServerConsole.DebugLine("{0}: walk from {1} to {2} ({3})", obj, obj.Location.Point, targetLoc, dir);
            //obj.Map.DrawGat();
            //Mapcache.Maps[obj.Map.Name].DrawGat();
            if (obj.Map.CheckCell(targetLoc, ECollisionType.Walkable) == false)
            {
                // Target location is not walkable - recalc path!
                ServerConsole.DebugLine("WalkToXY_Tick: location {0} not walkable, recalc path..", targetLoc);
                WalkToXY(obj, obj.TargetLocation);
                return;
            }

            obj.Move(dir);

            obj.Walkpath.path_pos++;
            int speed = CalcWalkspeed(obj);

            // Next step?
            if (speed > 0)
            {
                obj.WalkTimer = Timer.DelayCall(TimeSpan.FromMilliseconds(speed), TimeSpan.Zero, 1, new TimerStateCallback <WorldObjectUnit>(WalkToXY_Tick), obj);
            }
            else
            {
                // No next step, target location reached, update target location
                // just to be sure..
                obj.TargetLocation = obj.Location.Point;
                obj.Walkpath       = null;
                ServerConsole.DebugLine("WalkToXY_Tick: finished moving to location {0}", obj.Location.Point);
            }
        }
Beispiel #6
0
		public virtual void Move(EDirection D) {
			Move(D.ToPoint2D());
		}