public ActorManager(GraphicsDeviceManager _graphics, GraphicsDevice _device, InputManager _input)
        {
            this.Graphics = _graphics;
            this.Device = _device;
            this.Input = _input;

            AIList = new List<AI>();
            PieceList = new List<Piece>();

            FriendlyCollidables = new List<Collidable>();
            FriendlyProjectiles = new List<Collidable>();
            EnemyCollidables = new List<Collidable>();
            EnemyProjectiles = new List<Collidable>();

            PlayerControlsList = new List<PlayerControls>();
            Collisions = new CollisionManager(this);

            int gWidth = CollisionManager.GRID_WIDTH;
            int gHeight = CollisionManager.GRID_HEIGHT;

            BorderWidth = (gWidth + 2) / gWidth * Graphics.PreferredBackBufferWidth;
            BorderHeight = (gHeight + 2) / gHeight * Graphics.PreferredBackBufferHeight;

            Data = new ManagerData(Device);
        }
示例#2
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     input = new InputManager();
     Manager = new ActorManager(graphics, GraphicsDevice, input);
     Manager.NewPlayer(new Vector2(screenWidth/2, screenHeight/2));
     base.Initialize();
 }
 private void UpdateMovementInput(InputManager input)
 {
     float dY = 0;
     float dX = 0;
     if (input.isPressed(Up))
         dY -= 1;
     if (input.isPressed(Down))
         dY += 1;
     if (input.isPressed(Left))
         dX -= 1;
     if (input.isPressed(Right))
         dX += 1;
     if (dX == 0 && dY == 0)
         Player.Stop();
     else
         Player.Go();
     Player.SetHeading(Math.Atan2(dY, dX));
 }
 private void UpdateShootingInput(InputManager input)
 {
     if (input.isPressed(Shoot))
         Player.Shoot();
     else
         Player.HoldFire();
 }
 public void UpdatePlayer(InputManager input)
 {
     UpdateMovementInput(input);
     UpdateShootingInput(input);
 }