Esempio n. 1
0
        protected override void Update(GameTime gameTime)
        {
            KeyboardState newState = Keyboard.GetState();

            spell.Update(new Vector2(Mouse.GetState().X, Mouse.GetState().Y), gameTime, newState);

            // Allows the game to exit
            if ( GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                 newState.IsKeyDown( Keys.Escape ) )
                this.Exit();

            // Control map scaling
            if ( newState.IsKeyDown( Keys.Add ) && !prevState.IsKeyDown( Keys.Add ) )
            {
                mapScale = MathHelper.Clamp( mapScale + 0.05f, 0.05f, 5f );
                camSpeed += 5f;
            }
            else if ( newState.IsKeyDown( Keys.Subtract ) && !prevState.IsKeyDown( Keys.Subtract ) )
            {
                mapScale = MathHelper.Clamp( mapScale - 0.05f, 0.05f, 5f );
                camSpeed -= 5f;
            }
            if ( tileMap.Scale != mapScale )
            {
                tileMap.Scale = mapScale;
                tileMap.SetCameraToWorldBounds();
            }

            // Setup debug ability to toggle camera autonomy
            DbgAction action = new DbgAction();
            action.Activator = new DbgKey( Keys.C, Buttons.RightShoulder );
            action.Action = new DbgActionDel( () =>
                {
                    camera.Autonomous = !camera.Autonomous;
                    theDude.camBound = !theDude.camBound;
                } );
            dbg.AddDbgAction( action );

            prevState = newState;

            base.Update(gameTime);
        }
Esempio n. 2
0
 public int AddDbgAction( DbgAction action )
 {
     actions.Add( tokenCounter, action );
     return tokenCounter++;
 }