コード例 #1
0
ファイル: GreatGame.cs プロジェクト: DrPandemic/EraParadox
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Start the screen init.
            if (GameState == InitSate.Openning)
            {
                Window.ClientSizeChanged += OnScreenSizeChanged;
                SetupScreen();
                GameState = InitSate.ScreenIniting;
            }
            // Checking that the screen had been really inited.
            else if (GameState == InitSate.ScreenIniting)
            {
                if (Window.ClientBounds.Width == graphics.PreferredBackBufferWidth && Window.ClientBounds.Height == graphics.PreferredBackBufferHeight)
                {
                    GameState = InitSate.GameIniting;
                }
            }
            // The screen is good, now let's init the game.
            else if (GameState == InitSate.GameIniting)
            {
                Console.WriteLine("Starting client...");

                //gameplay = new TestScreen(Content, this);
                gameplay = new GameplayScreen(Content, this, client);                 // when testing: new TestScreen(Content);

                client.Start();

                Console.WriteLine("Loading game content...");

                gameplay.LoadContent(GraphicsDevice);
                gameplay.WindowIsReady(true);
                GameState = InitSate.GameRunning;
            }
            else if (GameState == InitSate.GameRunning)
            {
                client.Update(gameTime.ElapsedGameTime.TotalSeconds);

                gameplay.Update(gameTime);

                if (gameplay.Exit)
                {
                    Exit();
                }
            }

#if LINUX
            if (ScreenResized && GameState != InitSate.Openning && GameState != InitSate.ScreenIniting)
            {
                // Safety net, I really hate MonoGame (on Linux).
                if ((!(Window.ClientBounds.Width == graphics.PreferredBackBufferWidth && Window.ClientBounds.Height == graphics.PreferredBackBufferHeight)) || Window.IsResizable())
                {
                    if (FailCount > 2000)
                    {
                        Console.WriteLine("I'm really really sorry, but the screen was not able to be initialized.");
                        Exit();
                    }
                    FailCount++;
                    Console.WriteLine("Error for the window resize, trying to save the world from burning down.");
                    SetupScreen();
                }
                else
                {
                    FailCount = 0;
                }
            }
#endif
            base.Update(gameTime);
        }
コード例 #2
0
ファイル: GreatGame.cs プロジェクト: DrPandemic/EraParadox
		/// <summary>
		/// Allows the game to run logic such as updating the world,
		/// checking for collisions, gathering input, and playing audio.
		/// </summary>
		/// <param name="gameTime">Provides a snapshot of timing values.</param>
		protected override void Update(GameTime gameTime)
		{
			// Start the screen init.
			if (GameState == InitSate.Openning) {
				Window.ClientSizeChanged += OnScreenSizeChanged;
				SetupScreen();
				GameState = InitSate.ScreenIniting;
			} 
			// Checking that the screen had been really inited.
			else if (GameState == InitSate.ScreenIniting) {
				if (Window.ClientBounds.Width == graphics.PreferredBackBufferWidth && Window.ClientBounds.Height == graphics.PreferredBackBufferHeight) {
					GameState = InitSate.GameIniting;
				}
			}
			// The screen is good, now let's init the game.
			else if(GameState == InitSate.GameIniting) {
				Console.WriteLine("Starting client...");

				//gameplay = new TestScreen(Content, this);
				gameplay = new GameplayScreen(Content, this, client); // when testing: new TestScreen(Content);

				client.Start();

				Console.WriteLine("Loading game content...");

				gameplay.LoadContent(GraphicsDevice);
				gameplay.WindowIsReady(true);
				GameState = InitSate.GameRunning;
			} else if (GameState == InitSate.GameRunning) {
				client.Update(gameTime.ElapsedGameTime.TotalSeconds);

				gameplay.Update(gameTime);

				if(gameplay.Exit)
					Exit();
			}
					
#if LINUX
			if (ScreenResized && GameState != InitSate.Openning  && GameState != InitSate.ScreenIniting) {
				// Safety net, I really hate MonoGame (on Linux).
				if ((!(Window.ClientBounds.Width == graphics.PreferredBackBufferWidth && Window.ClientBounds.Height == graphics.PreferredBackBufferHeight)) || Window.IsResizable()) {
					if (FailCount > 2000) {
						Console.WriteLine("I'm really really sorry, but the screen was not able to be initialized.");
						Exit();
					}
					FailCount++;
					Console.WriteLine("Error for the window resize, trying to save the world from burning down.");
					SetupScreen();
				} else {
					FailCount=0;
				}
			}
#endif
			base.Update(gameTime);
		}