public MouseCursor() { name = "Mouse Cursor"; normal = new game.Sprite("data/sprites/cursors/cursor_normal.png") { scale = 0.05f }; normal.SetOrigin(512, 512); button = new game.Sprite("data/sprites/cursors/cursor_button.png") { scale = 0.05f }; button.SetOrigin(512, 512); text = new game.Sprite("data/sprites/cursors/cursor_text.png") { scale = 0.05f }; text.SetOrigin(512, 512); Normal(); }
public void Initialize(int state) { Deinitialize(); var activeMinigame = NetworkManager.Instance.ActiveMinigame3; var isOwner = NetworkManager.Instance.PlayerData.GUID == activeMinigame.Owner; var backgroundPath = "data/sprites/minigames/3/background"; backgroundPath += (isOwner ? "_owner" : "") + ".png"; var topOffset = isOwner ? 0f : 50; rootElement.AddChild(new Image(0, 0, bounds.width, bounds.height, new game.Sprite(backgroundPath, true, false))); //title // question questionLabel = new Label(0, 100, bounds.width, 60, activeMinigame.ActiveQuestion, questionStyle); rootElement.AddChild(questionLabel); if (state == 0) { yesChoiceButton = new Button(57, 170 + topOffset, 420, 160, "s1", choiceButtonStyle, () => { OnVoteClicked("yes"); }); noChoiceButton = new Button(620, 170 + topOffset, 420, 160, "s2", choiceButtonStyle, () => { OnVoteClicked("no"); }); yesChoiceLabel = new Label(57, 170 + topOffset, 420, 160, "I have", choiceLabelStyle); noChoiceLabel = new Label(620, 170 + topOffset, 420, 160, "I have never", choiceLabelStyle); rootElement.AddChild(yesChoiceButton); rootElement.AddChild(noChoiceButton); rootElement.AddChild(yesChoiceLabel); rootElement.AddChild(noChoiceLabel); } else if (state == 1) { var votedSituation = activeMinigame.ActiveQuestionVotes[NetworkManager.Instance.PlayerData.GUID]; if (votedSituation == "yes") { yesChoiceButton = new Button(57, 170 + topOffset, 420, 160, "s1", choiceButtonStyle, () => { OnVoteClicked("yes"); }); yesChoiceLabel = new Label(57, 170 + topOffset, 420, 160, "I have", choiceLabelStyle); rootElement.AddChild(yesChoiceButton); rootElement.AddChild(yesChoiceLabel); } else { noChoiceButton = new Button(57, 170 + topOffset, 420, 160, "s2", choiceButtonStyle, () => { OnVoteClicked("no"); }); noChoiceLabel = new Label(57, 170 + topOffset, 420, 160, "I have never", choiceLabelStyle); rootElement.AddChild(noChoiceButton); rootElement.AddChild(noChoiceLabel); } var totalVotes = NetworkManager.Instance.ActiveRoom.Players.Count; var remainingVotes = activeMinigame.RemainingVotes; var totalVoted = totalVotes - remainingVotes; remainingVotesLabel = new Label(bounds.width / 2f, bounds.height / 2f + topOffset, bounds.width / 2f, 170, $"Voted: {totalVoted}/{totalVotes} ({remainingVotes} remaining)", remainingVotesStyle); rootElement.AddChild(remainingVotesLabel); } else { var results = activeMinigame.Result(); var players = NetworkManager.Instance.ActiveRoom.Players; var index = 0; var spriteSize = 64f; var spacing = 8f; if (players.Count <= 8) { spriteSize = 128f; spacing = 11f; } foreach (var playerGUID in players.Keys.ToList().Sorted()) { var player = players[playerGUID]; var x = index * spriteSize + (index == 0 ? 0 : spacing); var playerAvatar = new PlayerAvatarElement(x, bounds.height / 2f - spriteSize / 2f + topOffset, player.Username, player.AvatarIndex, playerNameStyle, () => { }, spriteSize); index++; rootElement.AddChild(playerAvatar); if (!string.IsNullOrEmpty(results[playerGUID])) { var sprite = new game.Sprite($"data/sprites/{results[playerGUID]}Icon.png", true, false); rootElement.AddChild(new Image(x + spriteSize - 64f, bounds.height / 2f + spriteSize / 2f + topOffset - 64f, 64f, 64f, sprite)); } } } if (!isOwner) { return; } nextQuestionButton = new Button(0, 350, bounds.width / 2f, 100, "NEXT QUESTION", buttonStyle, OnNextQuestionClicked); stopPlayingButton = new Button(bounds.width / 2f, 350, bounds.width / 2f, 100, "STOP PLAYING", buttonStyle, OnStopPlayingClicked); rootElement.AddChild(nextQuestionButton); rootElement.AddChild(stopPlayingButton); }