private void SetupSocket_Minigames_1() { socket.On("started_minigame_1", data => { Debug.LogInfo($"Socket.IO: 'started_minigame_1', received data:\n{data?.ToString()}\n", "NETWORK"); var minigameData = (JObject)data; ActiveMinigame1 = new NetworkMostLikelyTo(minigameData.Value <string>("gameGuid"), minigameData.Value <string>("ownerGuid")); startedMinigame1 = true; }); socket.On("voted_minigame_1", data => { Debug.LogInfo($"Socket.IO: 'voted_minigame_1', received data:\n{data?.ToString()}\n", "NETWORK"); var minigameData = (JObject)data; var redirect = minigameData.TryGetValue("redirect", out _); ActiveMinigame1.SetVote(minigameData.Value <string>("guid"), minigameData.Value <string>("vote")); if (redirect) { return; } if (ActiveMinigame1.Owner == PlayerData.GUID && ActiveMinigame1.IsQuestionDone) { socket.Emit("results_minigame_1", ""); Debug.LogInfo($"Socket.IO Emit: 'results_minigame_1', sent data: \"\"", "NETWORK"); showResultsMinigame1 = true; } else { newVoteMinigame1 = true; } }); socket.On("request_minigame_1", data => { Debug.LogInfo($"Socket.IO: 'request_minigame_1', received data:\n{data?.ToString()}\n", "NETWORK"); var minigameData = (JObject)data; var questionIndex = minigameData.Value <int>("question"); var question = Minigame1Element.GetQuestion(questionIndex); ActiveMinigame1.StartNewQuestion(question); newQuestionMinigame1 = true; }); socket.On("results_minigame_1", data => { Debug.LogInfo($"Socket.IO: 'results_minigame_1', received data:\n{data?.ToString()}\n", "NETWORK"); showResultsMinigame1 = true; }); socket.On("finished_minigame_1", data => { Debug.LogInfo($"Socket.IO: 'finished_minigame_1', received data:\n{data?.ToString()}\n", "NETWORK"); finishedMinigame1 = true; }); }
public override void Load() { Root.AddChild(new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/fellini/bar.png"))); Root.AddChild(chatInstance = new ChatElement(0, 0, Globals.WIDTH / 3f, Globals.HEIGHT)); Root.AddChild(new Button(Globals.WIDTH / 3f + 20, 40, 200, 40, "Start minigame", () => { NetworkManager.Instance.StartMinigame1(); })); Root.AddChild(minigame1Element = new Minigame1Element(730f, 314f, 1100f, 450f, LabelStyle.Default.Alter(textSizeNormal: 24f, textAlignmentNormal: FontLoader.CenterCenterAlignment, textColorNormal: Color.Yellow), LabelStyle.Default.Alter(textColorNormal: Color.Yellow), LabelStyle.Default.Alter(textSizeNormal: 12f, textColorNormal: Color.Yellow, textAlignmentNormal: FontLoader.CenterTopAlignment), LabelStyle.Default.Alter(textAlignmentNormal: FontLoader.LeftCenterAlignment, textColorNormal: Color.Yellow), LabelStyle.Default.Alter(textAlignmentNormal: FontLoader.CenterCenterAlignment, textColorNormal: Color.Yellow), ButtonStyle.Transparent)); Root.AddChild(jukeboxInstance = new JukeboxElement(0, 0, Globals.WIDTH, Globals.HEIGHT, "data/sprites/locations/fellini/jukebox.png", new [] { "Song11", "Song12", "Song13", "Song14", "Song15" })); Root.AddChild(new Button(1642, 490, 246, 310, "Open jukebox", ButtonStyle.Transparent, () => { jukeboxInstance.Initialize(); })); Root.AddChild(new Button(10, 10, Globals.WIDTH / 3f - 20f, 40, "Leave room", () => { SoundManager.Instance.StopPlaying(jukeboxInstance.CurrentlyPlaying); NetworkManager.Instance.LeaveRoom(); })); ChatElement.ActiveChat = chatInstance; Minigame1Element.ActiveMinigame = minigame1Element; JukeboxElement.ActiveJukebox = jukeboxInstance; IsLoaded = true; }