Beispiel #1
0
        /// <summary>
        /// Statically creates an InputSet for four different players.
        /// </summary>
        static InputSet()
        {
            instances_ = new InputSet[4];

            // Not expensive to create 4 InputSets, so we aren't
            // worried about lazy instantiation.  If we instantiate
            // them now, and later we use multithreading, we won't
            // have to use sync locks - just pull the InputSet and
            // read from it.
            for (int i = 0; i < 4; i++)
            {
                instances_[i] = new InputSet();
            }
        }
 /// <summary>
 /// Moves the Gameplay camera based upon either player or mouse position
 /// </summary>
 /// <param name="inputs">This frame's controller input</param>
 protected void adjustCamera(InputSet inputs)
 {
     if (player_ == null)
     {
         Vector2 moveVector = Vector2.Zero;
         Vector2 cameraPosition = new Vector2(inputs.getRightDirectionalX(), inputs.getRightDirectionalY());
         if (cameraPosition.X < 100.0f)
         {
             moveVector.X = -3f;
         }
         else if (cameraPosition.X > engine_.GraphicsDevice.Viewport.Width - 100.0f)
         {
             moveVector.X = 3f;
         }
         if (cameraPosition.Y < 100.0f)
         {
             moveVector.Y = -3f;
         }
         else if (cameraPosition.Y > engine_.GraphicsDevice.Viewport.Height - 100.0f)
         {
             moveVector.Y = 3f;
         }
         GlobalHelper.getInstance().getCurrentCamera().move(moveVector.X, moveVector.Y);
     }
     else
     {
         GlobalHelper.getInstance().getCurrentCamera().setCenter(player_.getPosition().X, player_.getPosition().Y);
     }
 }
 /// <summary>
 /// Constructor which allows specification of a player.
 /// </summary>
 /// <param name="engine">The engine using the controller.</param>
 /// <param name="player">The player whose input should be read.</param>
 public X360ControllerInput(Engine engine, PlayerIndex player)
 {
     engine_ = engine;
     player_ = player;
     inputs_ = InputSet.getInstance(player);
 }
 /// <summary>
 /// Default constructor; assigns itself to Player One's input device.
 /// </summary>
 /// <param name="engine">The engine using the controller.</param>
 public X360ControllerInput(Engine engine)
 {
     engine_ = engine;
     player_ = PlayerIndex.One;
     inputs_ = InputSet.getInstance();
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="engine">The engine using the controller.</param>
 public PCControllerInput(Engine engine)
 {
     engine_ = engine;
     inputs_ = InputSet.getInstance();
 }
 /// <summary>
 /// Set the current InputSet to use for controlling the character.
 /// </summary>
 /// <param name="inputSet">The InputSet associated with the current control scheme.</param>
 public void setInputSet(controls.InputSet inputSet)
 {
     inputSet_ = inputSet;
 }