private void NarrationTriggered(object sender, NarrationData data) { LogMessage("Received Narration:\nType: " + data.type + "\nFile: " + data.file, Color.SlateGray); if (!checkBoxNarration.Checked) { return; } string path; switch (data.type) { case "gamestart": path = "narration/GameStartEvents/" + data.file + ".ogg"; break; case "random": path = "narration/RandomEvents/" + data.file + ".ogg"; break; case "win": path = "narration/WinEvents/" + data.file + ".ogg"; break; case "death": path = "narration/DeathEvents/" + data.file + ".ogg"; break; default: return; } //Download file if it isn't already downloaded if (!File.Exists(path)) { LogMessage("Downloading " + path, Color.Pink); using (WebClient client = new WebClient()) { client.DownloadFile("https://static.hivemc.com/bp/" + path, path); } } LogMessage("Playing " + path, Color.HotPink); //Play it Mixer.PlaySound(path); }
private void event_narration(SocketIOClient.Messages.IMessage message) { Debug.WriteLine("\nevent_narration:\n" + message.MessageText); EventJson <NarrationData> received = JsonConvert.DeserializeObject <EventJson <NarrationData> >(message.Json.ToJsonString()); //Validate if (!received.Validate()) { return; } NarrationData data = received.args[0].data; NarrationTriggered?.Invoke(this, data); }