Esempio n. 1
0
        public Game(string selectedLevelPath)
        {
            SelectedLevelPath = selectedLevelPath;
            menu      = new MainMenu(this);
            xmlParser = new XmlParser(SelectedLevelPath, this);
            if (xmlParser.entities == null)
            {
                MessageBox.Show("Xml file failed to validate, check console for errors.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Console.ReadKey();
            }
            else
            {
                Window    = new Window(this);
                Level     = new Level(this, Window.GameWidth, Window.GameHeight, xmlParser.entities);
                Stopwatch = new Stopwatch();
                Stopwatch.Start();
                LastUpdate = Stopwatch.ElapsedMilliseconds;

                fpsView        = new FPSView();
                timerScoreView = new TimerScoreView();

                this.AddView(new GameView());
                this.AddView(fpsView);
                this.AddView(timerScoreView);

                this.AddView(new DataView(this.Window));

                win  = new PopupWin(this);
                lose = new PopupLose(this);
            }
        }
Esempio n. 2
0
        // Shortcut keybind to 'P' for pausing and unpausing
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            switch (keyData)
            {
            case Keys.F1:
                if (CBDebugView.Checked)
                {
                    PopupLose lose = new PopupLose(this.Game);
                    lose.ShowDialog();
                }
                return(true);

            case Keys.F2:
                if (CBDebugView.Checked)
                {
                    PopupWin win = new PopupWin(this.Game);
                    win.ShowDialog();
                }
                return(true);

            case Keys.F3:
                if (CBDebugView.Checked)
                {
                    Game.Reset();
                }
                return(true);

            case Keys.P:
                pauseButton.PerformClick();
                return(base.ProcessCmdKey(ref msg, keyData));

            case Keys.N:
                if (CBDebugView.Checked)
                {
                    this.Game.Level.Update(0);
                }
                return(true);

            default:
                return(true);
            }
        }