public LeaderboardScene(Client client, int width, int height, LeaderboardPacket leaderboardPacket) { Client = client; _width = width; _height = height; _leaderboard = leaderboardPacket; _sceneState = LeaderboardSceneState.WaitingForSelection; _readyRematchCount = 0; _isReadyRematch = false; _playersLeftInInstance = leaderboardPacket.PlayerCount; }
public void RecieveServerResponse(BasePacket recievedPacket) { switch ((MessageType)recievedPacket.MessageType) { case MessageType.LB_ServerSend_UpdateLeaderboard: { var packet = (LeaderboardUpdatePacket)recievedPacket; _isReadyRematch = packet.IsClientReady; _readyRematchCount = packet.PlayerReadyCount; _playersLeftInInstance = packet.PlayerCount; if (_playersLeftInInstance == 1) { _sceneState = LeaderboardSceneState.WaitingForExit; } ReformatButtons(); break; } } }
public void ProcessInput(GameTime gameTime, InputInformation inputInfo) { if (_sceneState == LeaderboardSceneState.WaitingForSelection) { if (inputInfo.CurrentMouseState.LeftButton == ButtonState.Pressed && inputInfo.PreviousMouseState.LeftButton == ButtonState.Released) { if (_rematchButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { // READY _sceneState = LeaderboardSceneState.RematchSelected; SendMessageToTheServer(new BasePacket(), MessageType.LB_ClientSend_RematchReady); } else if (_exitButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { // LEAVE GAME LeaveGame(); } } else if (inputInfo.PreviousMouseState.LeftButton == ButtonState.Released) // If hover { if (_rematchButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { _rematchButtonColour = Color.LightGreen; } else { _rematchButtonColour = Color.Blue; } if (_exitButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { _exitButtonColour = Color.LightGreen; } else { _exitButtonColour = Color.Blue; } } } else if (_sceneState == LeaderboardSceneState.WaitingForExit) { _rematchButtonColour = Color.Red; // If clicked if (inputInfo.CurrentMouseState.LeftButton == ButtonState.Pressed && inputInfo.PreviousMouseState.LeftButton == ButtonState.Released) { if (_exitButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { // LEAVE GAME LeaveGame(); } } else if (inputInfo.PreviousMouseState.LeftButton == ButtonState.Released) // If hover { if (_exitButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { _exitButtonColour = Color.Orange; } else { _exitButtonColour = Color.Blue; } } } else { _exitButtonColour = Color.Red; // If clicked if (inputInfo.CurrentMouseState.LeftButton == ButtonState.Pressed && inputInfo.PreviousMouseState.LeftButton == ButtonState.Released) { if (_rematchButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { // UNREADY _sceneState = LeaderboardSceneState.WaitingForSelection; SendMessageToTheServer(new BasePacket(), MessageType.LB_ClientSend_RematchUnready); } } else if (inputInfo.PreviousMouseState.LeftButton == ButtonState.Released) // If hover { if (_rematchButtonRect.Contains(inputInfo.CurrentMouseState.Position)) { _rematchButtonColour = Color.Orange; } else { _rematchButtonColour = Color.LightGreen; } } } }