private void event_control(SocketIOClient.Messages.IMessage message) { Debug.WriteLine("\nevent_control:\n" + message.MessageText); EventJson <ControlData> received = JsonConvert.DeserializeObject <EventJson <ControlData> >(message.Json.ToJsonString()); //Validate if (!received.Validate()) { return; } ControlData data = received.args[0].data; ControlTriggered?.Invoke(this, data); }
private void ControlTriggered(object sender, ControlData data) { LogMessage("Received Control:\nPlay: " + data.play, Color.SlateGray); if (HasGameEnded) { return; } if (data.play == 0) { //Pause if (checkBoxKeystrokes.Checked) { MusicController.Pause(); LogMessage("Music paused", Color.Orange); } if (PauseSound != null) { Mixer.PlaySound(PauseSound); } } else if (data.play == 1) { //Play if (checkBoxKeystrokes.Checked) { MusicController.Play(); LogMessage("Music resumed", Color.Orange); } if (PlaySound != null) { Mixer.PlaySound(PlaySound); } if (ColourDisplay != null) { ColourDisplay.ClearColour(); } } }