protected override void Update(GameTime gameTime) { Event_Update?.Invoke(); base.Update(gameTime); }
protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } if (Global.gamseStarted) { Event_Update?.Invoke();//update happend } else { Tools.update(); } Window.Title = "my score: " + Global.myScore + " enemy score: " + Global.enemyScore + " cop score: " + Global.copScore; base.Update(gameTime); #region online //Tools.update(); //switch (state) //{ // case OnlineState.AskingRole: // if (Tools.ks.IsKeyDown(Keys.H)) // { // onlineGame = new HostOnlineGame(int.Parse(File.ReadAllText("port.txt"))); // onlineGame.OnConnection += new OnConnectionHandler(onlineGame_OnConnection); // onlineGame.Init(); // state = OnlineState.Connecting; // } // else if (Tools.ks.IsKeyDown(Keys.J)) // { // onlineGame = new JoinOnlineGame(File.ReadAllText("ip.txt"), int.Parse(File.ReadAllText("port.txt"))); // onlineGame.OnConnection += new OnConnectionHandler(onlineGame_OnConnection); // onlineGame.Init(); // state = OnlineState.Connecting; // } // break; // case OnlineState.Connecting: // break; // case OnlineState.Playing: // Event_Update?.Invoke();//update happend // Window.Title = "my score: " + Global.myScore + " enemy score: " + Global.enemyScore + " cop score: " + Global.copScore; // break; //} //this.Window.Title = state.ToString(); //base.Update(gameTime); #endregion }
/// <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) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { Exit(); } G.gameTime = gameTime; Event_Update?.Invoke(); if (nextstate != null) { currstate = nextstate; } currstate.Update(gameTime); base.Update(gameTime); }