Ejemplo n.º 1
0
        public void Update(GameTime gameTime, Map map)
        {
            var tiles = map.CloseTiles(Image.Position);

            if (InputManager.Instance.KeyDown(Keys.W, Keys.Up) &&
                !tiles.Any(x => x.CollisionBox.Any(y => y.Contains(new Point((int)Math.Round(Image.Position.X), (int)Math.Round(Image.Position.Y) - (int)Math.Round((Speed + CharacterWidth)))))))
                Image.Position.Y -= Speed;
            if (InputManager.Instance.KeyDown(Keys.S, Keys.Down) &&
                !tiles.Any(x => x.CollisionBox.Any(y => y.Contains(new Point((int)Math.Round(Image.Position.X), (int)Math.Round(Image.Position.Y) + (int)Math.Round((Speed + CharacterWidth)))))))
                Image.Position.Y += Speed;
            if (InputManager.Instance.KeyDown(Keys.A, Keys.Left) &&
                !tiles.Any(x => x.CollisionBox.Any(y => y.Contains(new Point((int)Math.Round(Image.Position.X) - (int)Math.Round((Speed + CharacterWidth)), (int)Math.Round(Image.Position.Y))))))
                Image.Position.X -= Speed;
            if (InputManager.Instance.KeyDown(Keys.D, Keys.Right) &&
                !tiles.Any(x => x.CollisionBox.Any(y => y.Contains(new Point((int)Math.Round(Image.Position.X) + (int)Math.Round((Speed + CharacterWidth)), (int)Math.Round(Image.Position.Y))))))
                Image.Position.X += Speed;

            CheckDoors(map);

            var v = ScreenManager.Instance.GraphicsDevice.Viewport;
            var direction = new Vector2(v.Width/2f, v.Height/2f) - InputManager.Instance.GetMousePostion();
            Image.Rotation = (float)(Math.Atan2(direction.Y, direction.X));

            ScreenManager.Instance.Camera.CenterOn(Image);
        }
Ejemplo n.º 2
0
 private void CheckDoors(Map map)
 {
     foreach (var door in map.Doors)
     {
         var res = door.DoorImage.CollidesWith(Image);
         if (res.IsSuccessful)
         {
             door.Push(Image, .05f, res.SpotB);
             return;
         }
     }
 }
Ejemplo n.º 3
0
        public override void LoadContent()
        {
            base.LoadContent();
            Image.LoadContent();

            Map = new Map();
            Map.LoadContent("TestLevel");

            Player = new Player();
            Player.LoadContent();
            Player.Image.Position = new Vector2(200, 200);
        }