Example #1
0
        private void CreateEventHandlers()
        {
            // Create a new scene system to handle the events.
            this.SceneSystem = new SceneSystem();


            // For mouse related events, just pass off the coords to the scene system.
            this.DrawingSurface.MouseButtonPressed += (sender, e) => {
                this.SceneSystem.MouseDown(e.Button.ToString().ToLower(), e.X, e.Y);
            };
            this.DrawingSurface.MouseButtonReleased += (sender, e) => {
                this.SceneSystem.MouseUp(e.Button.ToString().ToLower(), e.X, e.Y);
            };
            this.DrawingSurface.MouseMoved += (sender, e) => {
                this.SceneSystem.MouseMove(e.X, e.Y);
            };

            // For key related events, pass off the filtered keyname to the scene system.
            this.DrawingSurface.KeyPressed += (sender, e) => {
                this.SceneSystem.KeyDown(this.FilterKey(e));
            };

            // When the close button is pressed, set the game flag to 'closing' so
            // the application can begin to close.
            this.DrawingSurface.Closed += (sender, e) => {
                TowerDefense.SetGameFlag(GameFlag.Closing);
            };
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            if (InputManager.Instance.KeyPressed(Keys.Space))
            {
                TowerDefense.ExitGame();
            }
            if (InputManager.Instance.KeyPressed(Keys.F10))
            {
                ScreenManager.Instance.ChangeScreens(ScreenType.Victory);
            }
        }
Example #3
0
 public static void OnExitClick()
 {
     TowerDefense.ExitGame();
 }