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;
            }
        }