示例#1
0
 internal Game1()
     : base()
 {
     graphics = new GraphicsDeviceManager( this );
      Content.RootDirectory = "Content";
      _inputState = new InputState();
 }
示例#2
0
        // Move the camera's position based on input
        internal void HandleInput( InputState inputState, PlayerIndex? controllingPlayer )
        {
            Vector2 cameraMovement = Vector2.Zero;

             if ( inputState.IsScrollLeft( controllingPlayer ) )
             {
            cameraMovement.X = -1;
             }
             else if ( inputState.IsScrollRight( controllingPlayer ) )
             {
            cameraMovement.X = 1;
             }
             if ( inputState.IsScrollUp( controllingPlayer ) )
             {
            cameraMovement.Y = -1;
             }
             else if ( inputState.IsScrollDown( controllingPlayer ) )
             {
            cameraMovement.Y = 1;
             }
             if ( inputState.IsZoomIn( controllingPlayer ) )
             {
            AdjustZoom( 0.25f );
             }
             else if ( inputState.IsZoomOut( controllingPlayer ) )
             {
            AdjustZoom( -0.25f );
             }

             // to match the thumbstick behavior, we need to normalize non-zero vectors in case the user
             // is pressing a diagonal direction.
             if ( cameraMovement != Vector2.Zero )
             {
            cameraMovement.Normalize();
             }

             // scale our movement to move 25 pixels per second
             cameraMovement *= 25f;

             // move the camera
             MoveCamera( cameraMovement, true );
        }
示例#3
0
 internal bool HandleInput( InputState inputState, IMap map )
 {
     if ( inputState.IsLeft( PlayerIndex.One ) )
      {
     int tempX = X - 1;
     if ( map.IsWalkable( tempX, Y ) )
     {
        var enemy = Global.CombatManager.EnemyAt( tempX, Y );
        if ( enemy == null )
        {
           X = tempX;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      else if ( inputState.IsRight( PlayerIndex.One ) )
      {
     int tempX = X + 1;
     if ( map.IsWalkable( tempX, Y ) )
     {
        var enemy = Global.CombatManager.EnemyAt( tempX, Y );
        if ( enemy == null )
        {
           X = tempX;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      else if ( inputState.IsUp( PlayerIndex.One ) )
      {
     int tempY = Y - 1;
     if ( map.IsWalkable( X, tempY ) )
     {
        var enemy = Global.CombatManager.EnemyAt( X, tempY );
        if ( enemy == null )
        {
           Y = tempY;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      else if ( inputState.IsDown( PlayerIndex.One ) )
      {
     int tempY = Y + 1;
     if ( map.IsWalkable( X, tempY ) )
     {
        var enemy = Global.CombatManager.EnemyAt( X, tempY );
        if ( enemy == null )
        {
           Y = tempY;
        }
        else
        {
           Global.CombatManager.Attack( this, enemy );
        }
        return true;
     }
      }
      return false;
 }