Esempio n. 1
0
 private void TimerTick(object obj, EventArgs e)
 {
     _timer.Stop();
     if (_gameMenu != null)
     {
         _gameMenu.Show();
     }
     if (_game != null)
     {
         _game.Tick(PBGame.PointToClient(MousePosition));
         _game.Render();
         if (_game.Lose || _game.Won)
         {
             //_timer.Stop();
             MessageBox.Show(_game.Lose
     ? GameCoClassLibrary.Properties.Resources.Looser_message
     : GameCoClassLibrary.Properties.Resources.Winner_message);
             float scaling = _game.Scaling;
             _game     = null;
             _gameMenu = new MainMenu(_graphObject);
             GameResize(scaling);
             //_timer.Start();
             return;
         }
     }
     _graphObject.Render();
     _timer.Start();
 }
 private void CreateNewGame(FormType formType)
 {
   FormForSelection selectorForm = new FormForSelection(formType);
   if (selectorForm.ShowDialog() == DialogResult.OK)
   {
     if (_game != null)
     {
       if (_timer != null)
         _timer.Stop();
       _game = null;
     }
     try
     {
       _game = Game.Factory(selectorForm.ReturnFileName(),
                            formType == FormType.GameConfiguration ? FactoryAct.Create : FactoryAct.Load,
                            _graphObject);
     }
     catch
     {
       _game = null;
     }
     if (_game != null)
     {
       _game.Scaling = _currentScale;
       _gameMenu = null;
       MessageBox.Show("Game conf loaded successeful");
     }
     if (_timer != null)
       _timer.Start();
   }
 }
Esempio n. 3
0
        /// <summary>
        /// Creates the new game.
        /// </summary>
        /// <param name="formType">Type of the form.</param>
        private void CreateNewGame(FormType formType)
        {
            FormForSelection selectorForm = new FormForSelection(formType);

            if (selectorForm.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            _game = null;
            try
            {
                _game = Game.Factory(selectorForm.ReturnFileName(),
                                     formType == FormType.GameConfiguration ? FactoryAct.Create : FactoryAct.Load,
                                     _graphObject);
            }
            catch
            {
                _game = null;
            }
            if (_game == null)
            {
                return;
            }
            _game.Scaling = _currentScale;
            _gameMenu     = null;
            _graphObject.ClearCache();
            MessageBox.Show(Resources.Game_created_successeful);
        }
 /// <summary>
 /// Creates the new game.
 /// </summary>
 /// <param name="formType">Type of the form.</param>
 private void CreateNewGame(FormType formType)
 {
   FormForSelection selectorForm = new FormForSelection(formType);
   if(selectorForm.ShowDialog() != DialogResult.OK)
   {
     return;
   }
   _game = null;
   try
   {
     _game = Game.Factory(selectorForm.ReturnFileName(),
                          formType == FormType.GameConfiguration ? FactoryAct.Create : FactoryAct.Load,
                          _graphObject);
   }
   catch
   {
     _game = null;
   }
   if(_game == null)
   {
     return;
   }
   _game.Scaling = _currentScale;
   _gameMenu = null;
   _graphObject.ClearCache();
   MessageBox.Show(Resources.Game_created_successeful);
 }
 public GameForm()
 {
   InitializeComponent();
   _graphObject = new WinFormsGraphic(null);
   _currentScale = 1.0f;
   GameResize(1.0f);
   _gameMenu = new MainMenu(_graphObject);
   _timer = new Timer();
   _timer.Tick += TimerTick;
   _timer.Interval = 1;
   _timer.Start();
 }
Esempio n. 6
0
 public GameForm()
 {
     InitializeComponent();
     _graphObject  = new WinFormsGraphic(null);
     _currentScale = 1.0f;
     GameResize(1.0f);
     _gameMenu       = new MainMenu(_graphObject);
     _timer          = new Timer();
     _timer.Tick    += TimerTick;
     _timer.Interval = 1;
     _timer.Start();
 }
Esempio n. 7
0
 private Program()
     : base(
         Settings.WindowWidth, Settings.WindowHeight, new GraphicsMode(color: 32, depth: 0, stencil: 0, samples: 8),
         "Tower defense OpenGl Beta")
 {
     GL.Enable(EnableCap.PolygonSmooth);
     VSync           = VSyncMode.Adaptive;
     _graphObject    = new OpenGLGraphic(this.ClientSize);
     _currentScale   = 1.0f;
     _gameMenu       = new MainMenu(_graphObject);
     Mouse.ButtonUp += MouseUp;
     Mouse.Move     += MouseMove;
 }
Esempio n. 8
0
        protected override void OnUpdateFrame(FrameEventArgs e)
        {
            base.OnUpdateFrame(e);
            if (_game == null)
            {
                return;
            }
            _game.Tick(new Point(this.Mouse.X, this.Mouse.Y));
            if (!_game.Lose && !_game.Won)
            {
                return;
            }
            MessageBox.Show(_game.Lose
                        ? GameCoClassLibrary.Properties.Resources.Looser_message
                        : GameCoClassLibrary.Properties.Resources.Winner_message);
            float scaling = _game.Scaling;

            _game     = null;
            _gameMenu = new MainMenu(_graphObject);
            GameResize(scaling);
        }
Esempio n. 9
0
        private void CreateNewGame(FormType formType)
        {
            FormForSelection selectorForm = new FormForSelection(formType);

            if (selectorForm.ShowDialog() == DialogResult.OK)
            {
                if (_game != null)
                {
                    if (_timer != null)
                    {
                        _timer.Stop();
                    }
                    _game = null;
                }
                try
                {
                    _game = Game.Factory(selectorForm.ReturnFileName(),
                                         formType == FormType.GameConfiguration ? FactoryAct.Create : FactoryAct.Load,
                                         _graphObject);
                }
                catch
                {
                    _game = null;
                }
                if (_game != null)
                {
                    _game.Scaling = _currentScale;
                    _gameMenu     = null;
                    MessageBox.Show("Game conf loaded successeful");
                }
                if (_timer != null)
                {
                    _timer.Start();
                }
            }
        }
 private void TimerTick(object obj, EventArgs e)
 {
   _timer.Stop();
   if (_gameMenu != null)
   {
     _gameMenu.Show();
   }
   if (_game != null)
   {
     _game.Tick(PBGame.PointToClient(MousePosition));
     _game.Render();
     if (_game.Lose || _game.Won)
     {
       //_timer.Stop();
       MessageBox.Show(_game.Lose
         ? GameCoClassLibrary.Properties.Resources.Looser_message
         : GameCoClassLibrary.Properties.Resources.Winner_message);
       float scaling = _game.Scaling;
       _game = null;
       _gameMenu = new MainMenu(_graphObject);
       GameResize(scaling);
       //_timer.Start();
       return;
     }
   }
   _graphObject.Render();
   _timer.Start();
 }
 protected override void OnUpdateFrame(FrameEventArgs e)
 {
   base.OnUpdateFrame(e);
   if(_game == null)
   {
     return;
   }
   _game.Tick(new Point(this.Mouse.X, this.Mouse.Y));
   if(!_game.Lose && !_game.Won)
   {
     return;
   }
   MessageBox.Show(_game.Lose
                     ? GameCoClassLibrary.Properties.Resources.Looser_message
                     : GameCoClassLibrary.Properties.Resources.Winner_message);
   float scaling = _game.Scaling;
   _game = null;
   _gameMenu = new MainMenu(_graphObject);
   GameResize(scaling);
 }
 private Program()
   : base(
     Settings.WindowWidth, Settings.WindowHeight, new GraphicsMode(color: 32, depth: 0, stencil: 0, samples: 8),
     "Tower defense OpenGl Beta")
 {
   GL.Enable(EnableCap.PolygonSmooth);
   VSync = VSyncMode.Adaptive;
   _graphObject = new OpenGLGraphic(this.ClientSize);
   _currentScale = 1.0f;
   _gameMenu = new MainMenu(_graphObject);
   Mouse.ButtonUp += MouseUp;
   Mouse.Move += MouseMove;
 }