예제 #1
0
        public override void Update(Piece player, Direction playersDirection)
        {
            int       deltaY    = player.Position.Height - Position.Height;
            int       deltaX    = player.Position.Width - Position.Width;
            Direction direction = Direction.Stay;

            if (Math.Abs(deltaY) > Math.Abs(deltaX))
            {
                if (deltaY > 0)
                {
                    direction = Direction.Down;
                }
                else
                {
                    direction = Direction.Up;
                }
            }
            else
            {
                if (deltaX > 0)
                {
                    direction = Direction.Right;
                }
                else
                {
                    direction = Direction.Left;
                }
            }

            Position = PositionTarsformer.Move(Position, direction);
        }
예제 #2
0
파일: Player.cs 프로젝트: galtamir/LearnUWP
 public override void Update(Piece player, Direction direction)
 {
     Position = PositionTarsformer.Move(Position, direction);
 }