/// <summary> /// The main entry point for the application. /// </summary> static void Main(string[] args) { // Steam initialization if (!Steam_Manager.Initialize()) { return; } try { using (Game1 game = new Game1()) { game.Run(); } } catch (Exception e) { Steam_Manager.Unload(); Console.WriteLine("Error occured while running game: " + e); // Throw e again after catching error :) throw e; } // Steam shutdown Steam_Manager.Unload(); }
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; game = this; graphics.PreferredBackBufferHeight = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height; graphics.PreferredBackBufferWidth = GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width; //graphics.ToggleFullScreen(); //IntPtr hWnd = this.Window.Handle; //var control = System.Windows.Forms.Control.FromHandle(hWnd); //var form = control.FindForm(); //form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; //graphics.PreferredBackBufferWidth = 1200; //graphics.PreferredBackBufferHeight = 1000; displayRatio.X = (float)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / 1920.0); displayRatio.Y = (float)(GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 1080.0); //displayRatio.X = (float)(graphics.PreferredBackBufferWidth / 1920.0); //displayRatio.Y = (float)(graphics.PreferredBackBufferHeight/ 1080.0); IsMouseVisible = true; Steam_Manager.SetOverlordReference(this); }
protected override void Update(GameTime gameTime) { // Steam Update Steam_Manager.Update(); currentBackground.Update(gameTime); //Update input Input.Update(gameTime); switch (gameState) { case GameState.Menu: menu.Update(gameTime); break; case GameState.Game: thisIsOurGame.Update(gameTime); break; } base.Update(gameTime); }
public override void OnEnemyShapeChosen(PlayerIndex player, Shapes.Shape shape) { if (player == PlayerIndex.One) { MsgGameEnemyShapeChosen msg = new MsgGameEnemyShapeChosen(); msg.SetShape(shape); Steam_Manager.SendP2PMessage(Steam_Manager.ConnectedPlayer, msg, EP2PSend.k_EP2PSendReliable); } }
public override void OnLinesCompleted(PlayerIndex player, int linesCompleted) { if (player == PlayerIndex.One) { MsgGameLinesCompleted msg = new MsgGameLinesCompleted(); msg.SetLinesCompleted(linesCompleted); Steam_Manager.SendP2PMessage(Steam_Manager.ConnectedPlayer, msg, EP2PSend.k_EP2PSendReliable); } }
public override void OnLose(PlayerIndex player) { if (player == PlayerIndex.One) { MsgGameLose msg = new MsgGameLose(); Steam_Manager.SendP2PMessage(Steam_Manager.ConnectedPlayer, msg, EP2PSend.k_EP2PSendReliable); playerController.EndGame(); base.OnLose(player); } }
protected override void UpdateInGame(GameTime gameTime) { ReceiveNetworkData(); playerController.Update(gameTime); player.Update(gameTime); otherPlayer.Update(gameTime); MsgGameLevelUpdate msg = new MsgGameLevelUpdate(); msg.SetGrid(player.Grid); msg.SetShapeQueueShape(player.shapeQueue[0]); msg.SetFallingShape(player.FallingShape); Steam_Manager.SendP2PMessage(Steam_Manager.ConnectedPlayer, msg, EP2PSend.k_EP2PSendReliable); base.UpdateInGame(gameTime); }
protected override void UpdateLobby(GameTime gameTime) { ReceiveNetworkData(); // Wait for player to be ready and also other player to be ready before if (Input.IsKeyPress(Keys.Space) || Input.IsKeyPress(Keys.Enter)) { isReady = !isReady; if (!isReady) { ResetCountdown(); } // Send message on state of readyness MsgGameReady msg = new MsgGameReady(); msg.SetIsReady(isReady); Console.WriteLine("Sending Ready message: " + msg.GetMessageType()); Steam_Manager.SendP2PMessage(Steam_Manager.ConnectedPlayer, msg, EP2PSend.k_EP2PSendReliable); } // Pressing escape means cancel ready status if (Input.IsKeyPress(Keys.Escape)) { isReady = false; ResetCountdown(); // Send message on state of readyness MsgGameReady msg = new MsgGameReady(); msg.SetIsReady(isReady); Console.WriteLine("Sending Ready message: " + msg.GetMessageType()); Steam_Manager.SendP2PMessage(Steam_Manager.ConnectedPlayer, msg, EP2PSend.k_EP2PSendReliable); } if (isReady && isOtherReady) { gameState = GameState.InGame; } }
public void OnBeginExitGame() { Steam_Manager.Unload(); this.Exit(); }