Ejemplo n.º 1
0
        private List<Player> _players; // List of players that are registered in the game. Used for Xbox controller input organisation.

        #endregion Fields

        #region Constructors

        public Input(Game1 game)
            : base(game)
        {
            _gamePadToCheck = new List<Buttons>();
            _keyboardToCheck = new List<Keys>();

            _gamePadCommandsC = new List<Dictionary<Buttons, InputTypeComplex>> ();
            _keyboardCommandsC = new Dictionary<Keys, InputTypeComplex>();
            _mouseCommandsC = new Dictionary<MouseInput.MouseButtonsXNA, InputTypeComplex>();

            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.LeftButton, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.RightButton, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.MiddleButton, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.XButton1, new InputTypeComplex());
            _mouseCommandsC.Add(MouseInput.MouseButtonsXNA.XButton2, new InputTypeComplex());

            _padEnable = _keyEnable = _mouseEnable = true;

            for (int i = 0; i < LocalPlayerRegistry.MAX_LOCAL_MACHINE_PLAYERS; i++)
            {
                _gamePadCommandsC.Add(new Dictionary<Buttons, InputTypeComplex>());
            }

            _mouse = new MouseInput(game);
            _mouse.CenterScreen = new Microsoft.Xna.Framework.Vector2(game.GraphicsDevice.DisplayMode.Width / 2, game.GraphicsDevice.DisplayMode.Height / 2);

            _container = new InputContainer(_gamePadCommandsC, _keyboardCommandsC, _mouseCommandsC, _mouse, this);

            ReloadPlayerList();
        }
Ejemplo n.º 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()
        {
            LocalPlayerRegistry.InitialisePlayer(PlayerIndex.One);
            // TODO: Add your initialization logic here
            _inputManager = new Input(this);
            _inputManager.AddCommandToCheckKeyboard(Keys.W, Keys.A, Keys.S, Keys.D, Keys.Q, Keys.E);
            _inputs = _inputManager.RetrieveInputContainer;

            //_test = new ANSKTest(this, Vector3.Zero, 3, Content.Load<ANSKModelContent>("CubeTest"));

            //_test._model.PlayAnimation("One");
            //_test._model.PauseAnimation();

            //_camera = new Camera(this, Vector3.Backward * 15, Vector3.Forward, Vector3.Up);
            _camera = new Camera(this, Vector3.Backward * 20, Vector3.Forward, Vector3.Up);
            _camera.Target = new GameObject(this, Matrix.Identity.Translation);
            //_camera.TargetPos = Matrix.Identity.Translation;
            //_camera.Target = _test;
            _camera.TargetSpecified = true;

            _model = new ANSKModel(Content.Load<ANSKModelContent>("CubeTest"));
            _model.ManualInitialise(GraphicsDevice, Content.Load<Effect>("Effects/AnimatableModel"), this);
            _model.PlayAnimation("One");
            //_camera.Translate(Vector3.Left * 15);
            //_camera.Translate(Vector3.Forward * 15);

            //_model = Content.Load<ANSKModel>("CubeTest");
            world = Matrix.CreateTranslation(0, 0, 0);
            view = Matrix.CreateLookAt(new Vector3(0, 0, 3), new Vector3(0, 0, 0), new Vector3(0, 1, 0));
            proj = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45), 800f / 480f, 0.01f, 100f);

            _modelTrans = Matrix.CreateTranslation(Vector3.Zero);// *Matrix.CreateScale(50);

            base.Initialize();
        }