public void Initialize()
 {
     Deinitialize();
     rootElement.AddChild(new Image(x, y, bounds.width, bounds.height, new game.Sprite(backgroundPath, true, false)));
     rootElement.AddChild(new Button(buttonPositions[0].x, buttonPositions[0].y, buttonPositions[0].width, buttonPositions[0].height, "Back", ButtonStyle.Transparent, () => { Deinitialize(); }));
     rootElement.AddChild(new Button(buttonPositions[1].x, buttonPositions[1].y, buttonPositions[1].width, buttonPositions[1].height, "Song1", ButtonStyle.Transparent, () => {
         NetworkManager.Instance.StopPlayingSound(CurrentlyPlaying);
         CurrentlyPlaying = songs[0];
         NetworkManager.Instance.PlaySound(CurrentlyPlaying, true);
     }));
     rootElement.AddChild(new Button(buttonPositions[2].x, buttonPositions[2].y, buttonPositions[2].width, buttonPositions[2].height, "Song2", ButtonStyle.Transparent, () => {
         NetworkManager.Instance.StopPlayingSound(CurrentlyPlaying);
         CurrentlyPlaying = songs[1];
         NetworkManager.Instance.PlaySound(CurrentlyPlaying, true);
     }));
     rootElement.AddChild(new Button(buttonPositions[3].x, buttonPositions[3].y, buttonPositions[3].width, buttonPositions[3].height, "Song3", ButtonStyle.Transparent, () => {
         NetworkManager.Instance.StopPlayingSound(CurrentlyPlaying);
         CurrentlyPlaying = songs[2];
         NetworkManager.Instance.PlaySound(CurrentlyPlaying, true);
     }));
     rootElement.AddChild(new Button(buttonPositions[4].x, buttonPositions[4].y, buttonPositions[4].width, buttonPositions[4].height, "Song4", ButtonStyle.Transparent, () => {
         NetworkManager.Instance.StopPlayingSound(CurrentlyPlaying);
         CurrentlyPlaying = songs[3];
         NetworkManager.Instance.PlaySound(CurrentlyPlaying, true);
     }));
     rootElement.AddChild(new Button(buttonPositions[5].x, buttonPositions[5].y, buttonPositions[5].width, buttonPositions[5].height, "Song5", ButtonStyle.Transparent, () => {
         NetworkManager.Instance.StopPlayingSound(CurrentlyPlaying);
         CurrentlyPlaying = songs[4];
         NetworkManager.Instance.PlaySound(CurrentlyPlaying, true);
     }));
     rootElement.AddChild(new Button(buttonPositions[6].x, buttonPositions[6].y, buttonPositions[6].width, buttonPositions[6].height, "Stop", ButtonStyle.Transparent, () => {
         NetworkManager.Instance.StopPlayingSound(CurrentlyPlaying);
         CurrentlyPlaying = "none";
     }));
 }
Esempio n. 2
0
    //------------------------------------------------------------------------------------
    //                                      SetupOutput
    //------------------------------------------------------------------------------------
    private void SetupOutput()
    {
        _rotationPoint = new Pivot();
        _rotationPoint.SetXY(this._width / 2, this._height / 2);
        AddChild(_rotationPoint);

        _camera = new Camera(0, 0, game.width, game.height);
        _rotationPoint.AddChild(_camera);
    }
        public static GameObject CreateJoinPublicRoomEntryCoffee(string roomName, string roomDesc, bool isNSFW, string roomId)
        {
            var roomContainer = new Pivot();

            roomContainer.name = $"ROOM: {roomId}";
            roomContainer.AddChild(new Label(40, 0, 500f - 80f, 20, roomName, RoomTitleStyleCoffee));
            roomContainer.AddChild(new Label(40, 30, 500f - 80f, 70f, roomDesc, RoomDescStyleCoffee));
            roomContainer.AddChild(new Button(40, 110, 500f - 80f, 40f, "JOIN", RoomButtonStyleCoffee, () => NetworkManager.Instance.TryJoinRoom(roomId, "")));
            if (isNSFW)
            {
                roomContainer.AddChild(new Image(500 - 32 - 40, 0, 32, 32, new game.Sprite("data/sprites/warning.png", false, false)
                {
                    scale = 32f / 480f
                }));
                roomContainer.AddChild(new Label(500 - 32 - 40 - 32 - 24, 0, 50, 32, "NSFW", RoomDescStyleCoffee.Alter(textAlignmentNormal: FontLoader.RightCenterAlignment)));
            }

            return(roomContainer);
        }
        public static GameObject CreateJoinPrivateRoomEntryFellini(string roomName, string roomDesc, string roomCode, bool isNSFW, string roomId)
        {
            TextField textfield;
            var       roomContainer = new Pivot();

            roomContainer.name = $"ROOM: {roomId}";
            roomContainer.AddChild(new Label(40, 0, 500f - 80f, 20, roomName, RoomTitleStyleFellini));
            roomContainer.AddChild(new Label(40, 30, 500f - 80f, 70f, roomDesc, RoomDescStyleFellini));
            roomContainer.AddChild(textfield = new TextField(40, 110f, 500f - 80f, 40f, "Room code", RoomCodeStyleFellini));
            roomContainer.AddChild(new Button(40, 160, 500f - 80f, 40f, "JOIN", RoomButtonStyleFellini, () => {
                if (textfield.Text != roomCode)
                {
                    textfield.Text = "";
                    return;
                }
                NetworkManager.Instance.TryJoinRoom(roomId, roomCode);
            }));
            if (isNSFW)
            {
                roomContainer.AddChild(new Image(500 - 32 - 40, 0, 32, 32, new game.Sprite("data/sprites/warning.png", false, false)
                {
                    scale = 32f / 480f
                }));
                roomContainer.AddChild(new Label(500 - 32 - 40 - 32 - 24, 0, 50, 32, "NSFW", RoomDescStyleFellini.Alter(textAlignmentNormal: FontLoader.RightCenterAlignment)));
            }

            return(roomContainer);
        }
        public override void Load() {
            username = "";
            avatarIndex = 0;
            consent = true;
            
            var avatarButtonStyle = new ButtonStyle(
                textSizeNormal: 14f, textSizeHover: 14f, textSizePressed: 14f,
                textColorNormal: Color.Black, textColorHover: Color.Black, textColorPressed: Color.Black,
                fontLoaderInstance: FontLoader.SourceCodeBold);

            Root.AddChild(new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/login.jpg")));
            Root.AddChild(new TextField(670, 417, 500, 60, "", new TextFieldStyle(placeholderTextSizeNormal: 12f, placeholderTextSizeFocused: 12f), onValueChanged: (oldValue, newValue) => username = newValue));
            var avatarContainer = new Pivot {x = -100000f, y = 582};
            var avatarButton = new SpriteButton(856, 582, 128, 128, "Click\r\nto switch", new game.Sprite("data/sprites/avatars/female_1_128.png", true), avatarButtonStyle);
            avatarButton.OnClick += () => {
                avatarContainer.x = 230f;
                avatarButton.x = -100000f;
                MouseCursor.Instance.PreventMouseEventPropagation = true;
            };
            Root.AddChild(avatarButton);
            Root.AddChild(avatarContainer);
            var female1 = UIFactory.CreateAvatarSelectionEntry(128 * 0, 0, "data/sprites/avatars/female_1_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female1.OnClick += () => avatarIndex = 0;
            var female2 = UIFactory.CreateAvatarSelectionEntry(128 * 1 + 20, 0, "data/sprites/avatars/female_2_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female2.OnClick += () => avatarIndex = 1;
            var female3 = UIFactory.CreateAvatarSelectionEntry(128 * 2 + 20, 0, "data/sprites/avatars/female_3_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female3.OnClick += () => avatarIndex = 2;
            var female4 = UIFactory.CreateAvatarSelectionEntry(128 * 3 + 20, 0, "data/sprites/avatars/female_4_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female4.OnClick += () => avatarIndex = 3;
            var female5 = UIFactory.CreateAvatarSelectionEntry(128 * 4 + 20, 0, "data/sprites/avatars/female_5_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            female5.OnClick += () => avatarIndex = 4;
            var male1 = UIFactory.CreateAvatarSelectionEntry(128 * 5 + 20, 0, "data/sprites/avatars/male_1_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male1.OnClick += () => avatarIndex = 5;
            var male2 = UIFactory.CreateAvatarSelectionEntry(128 * 6 + 20, 0, "data/sprites/avatars/male_2_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male2.OnClick += () => avatarIndex = 6;
            var male3 = UIFactory.CreateAvatarSelectionEntry(128 * 7 + 20, 0, "data/sprites/avatars/male_3_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male3.OnClick += () => avatarIndex = 7;
            var male4 = UIFactory.CreateAvatarSelectionEntry(128 * 8 + 20, 0, "data/sprites/avatars/male_4_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male4.OnClick += () => avatarIndex = 8;
            var male5 = UIFactory.CreateAvatarSelectionEntry(128 * 9 + 20, 0, "data/sprites/avatars/male_5_128.png", avatarButton, avatarContainer, avatarButtonStyle);
            male5.OnClick += () => avatarIndex = 9;
            avatarContainer.AddChild(female1);
            avatarContainer.AddChild(female2);
            avatarContainer.AddChild(female3);
            avatarContainer.AddChild(female4);
            avatarContainer.AddChild(female5);
            avatarContainer.AddChild(male1);
            avatarContainer.AddChild(male2);
            avatarContainer.AddChild(male3);
            avatarContainer.AddChild(male4);
            avatarContainer.AddChild(male5);
            
            Root.AddChild(new Checkbox(475, 775, 815, 60, "", (oldValue, newValue) => {
                consent = newValue;
            }) {IsChecked = true});
            Root.AddChild(new Button(800, 912, 243, 77, "Submit", ButtonStyle.Transparent, onClick: () => {
                if (string.IsNullOrEmpty(username)) return;
                NetworkManager.Instance.CreateAccount(username, avatarIndex, consent);
                SceneManager.Instance.LoadScene("Map");
            }));
            IsLoaded = true;
        }
        public override void Load()
        {
            var textFieldStyle = TextFieldStyle.Default.Alter(backgroundNormal: Color.Transparent, backgroundFocused: Color.Transparent, borderNormal: Color.FromArgb(255, 255, 255, 0), borderFocused: Color.FromArgb(255, 255, 255, 0), borderSizeNormal: 4f, borderSizeFocused: 4f);
            var checkboxStyle  = CheckboxStyle.Default.Alter(tickColorNormal: Color.FromArgb(255, 255, 255, 0), tickColorHover: Color.FromArgb(255, 255, 255, 0), tickColorPressed: Color.FromArgb(255, 255, 255, 0));

            backgroundImage1 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/fellini/menu_1.png", false, false))
            {
                x = 0f
            };
            backgroundImage2 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/fellini/menu_2.png", false, false))
            {
                x = -100000f
            };
            backgroundImage3 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/fellini/menu_3.png", false, false))
            {
                x = -100000f
            };
            Root.AddChild(backgroundImage1);
            Root.AddChild(backgroundImage2);
            Root.AddChild(backgroundImage3);
            var tab1 = new Pivot();

            tab2 = new Pivot();
            tab2.SetXY(width / 3f, 0f);
            tab3 = new Pivot();
            tab3.SetXY(2f * width / 3f, 0f);
            Root.AddChild(tab1);
            Root.AddChild(tab2);
            Root.AddChild(tab3);
            var tab1Main         = new Pivot();
            var tab1CreatePublic = new Pivot {
                x = -100000f
            };
            var tab1CreatePrivate = new Pivot {
                x = -100000f
            };

            tab1.AddChild(tab1Main);
            tab1.AddChild(tab1CreatePublic);
            tab1.AddChild(tab1CreatePrivate);
            tab1Main.AddChild(new Button(148, 266, 434, 134, "Create public room", ButtonStyle.Transparent, () => {
                tab1CreatePublic.x = 0f;
                backgroundImage2.x = 0f;
                tab1Main.x         = -100000f;
                backgroundImage1.x = -100000f;
            }));
            tab1Main.AddChild(new Button(148, 458, 434, 134, "Create private room", ButtonStyle.Transparent, () => {
                tab1CreatePrivate.x = 0;
                backgroundImage3.x  = 0f;
                tab1Main.x          = -100000f;
                backgroundImage1.x  = -100000f;
            }));
            tab1Main.AddChild(new Button(253, 900, 210, 95, "Back", ButtonStyle.Transparent, () => {
                NetworkManager.Instance.JoinLocation("none", false);
            }));
            tab1CreatePublic.AddChild(publicRoomNameTextField        = new TextField(99, 341 - 2, 540, 52, "", textFieldStyle));
            tab1CreatePublic.AddChild(publicRoomDescriptionTextField = new TextField(99, 562 - 2, 540, 52, "", textFieldStyle));
            tab1CreatePublic.AddChild(publicRoomNSFWCheckbox         = new Checkbox(99 + 64f, 670, 540 - 64f, 52, "", checkboxStyle));
            tab1CreatePublic.AddChild(new Button(180, 797, 372, 67, "Create", ButtonStyle.Transparent, () => {
                if (string.IsNullOrEmpty(publicRoomNameTextField.Text) || string.IsNullOrEmpty(publicRoomDescriptionTextField.Text))
                {
                    return;
                }
                NetworkManager.Instance.CreateAndJoinRoom(publicRoomNameTextField.Text, publicRoomDescriptionTextField.Text, "", publicRoomNSFWCheckbox.IsChecked, true);
                publicRoomNameTextField.Text        = "";
                publicRoomDescriptionTextField.Text = "";
                publicRoomNSFWCheckbox.IsChecked    = false;
                tab1CreatePublic.x = -100000f;
                backgroundImage2.x = -100000f;
                tab1Main.x         = 0f;
                backgroundImage1.x = 0f;
                RefreshRooms();
            }));
            tab1CreatePublic.AddChild(new Button(253, 900, 210, 95, "Back", ButtonStyle.Transparent, () => {
                tab1CreatePublic.x = -100000f;
                backgroundImage2.x = -100000f;
                tab1Main.x         = 0f;
                backgroundImage1.x = 0f;
            }));
            tab1CreatePrivate.AddChild(privateRoomNameTextField        = new TextField(99, 341 - 2, 540, 52, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomDescriptionTextField = new TextField(99, 473 - 2, 540, 52, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomCodeTextField        = new TextField(100, 613 - 2, 540, 52, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomNSFWCheckbox         = new Checkbox(99 + 64f, 682, 540 - 64f, 52, "", checkboxStyle));
            tab1CreatePrivate.AddChild(new Button(180, 797, 372, 67, "Create", ButtonStyle.Transparent, () => {
                if (string.IsNullOrEmpty(privateRoomNameTextField.Text) || string.IsNullOrEmpty(privateRoomDescriptionTextField.Text) || string.IsNullOrEmpty(privateRoomCodeTextField.Text))
                {
                    return;
                }
                NetworkManager.Instance.CreateAndJoinRoom(privateRoomNameTextField.Text, privateRoomDescriptionTextField.Text, privateRoomCodeTextField.Text, privateRoomNSFWCheckbox.IsChecked, false);
                privateRoomNameTextField.Text        = "";
                privateRoomDescriptionTextField.Text = "";
                privateRoomCodeTextField.Text        = "";
                privateRoomNSFWCheckbox.IsChecked    = false;
                tab1CreatePrivate.x = -100000f;
                backgroundImage3.x  = -100000f;
                tab1Main.x          = 0f;
                backgroundImage1.x  = 0f;
                RefreshRooms();
            }));
            tab1CreatePrivate.AddChild(new Button(253, 900, 210, 95, "Back", ButtonStyle.Transparent, () => {
                tab1CreatePrivate.x = -100000f;
                backgroundImage3.x  = -100000f;
                tab1Main.x          = 0f;
                backgroundImage1.x  = 0f;
            }));

            tab2.AddChild(loadingPrivateRooms = new AnimatedSprite(Texture2D.GetInstance("data/sprites/spinner.png", true), 12, 1, 0.083F)
            {
                x = -100000f, y = 207 + 64f - 48f, scale = 0.75f
            });
            tab2.AddChild(new Button(370f, 900, 360, 95, "Refresh", ButtonStyle.Transparent, () => { RefreshRooms(); }));

            tab3.AddChild(loadingPublicRooms = new AnimatedSprite(Texture2D.GetInstance("data/sprites/spinner.png", true), 12, 1, 0.083F)
            {
                x = -100000f, y = 207 + 64f - 48f, scale = 0.75f
            });

            RefreshRooms();
            IsLoaded = true;
        }
        public void Initialize(int state)
        {
            Deinitialize();
            var activeMinigameCopy = NetworkManager.Instance.ActiveMinigame2;
            var isOwner            = NetworkManager.Instance.PlayerData.GUID == activeMinigameCopy.Owner;
            var backgroundPath     = "data/sprites/minigames/2/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)));

            // question
            questionLabel = new Label(93, 18, 912, 125, activeMinigameCopy.ActiveQuestion.Question, questionStyle);
            rootElement.AddChild(questionLabel);
            if (state == 0)   // not voted
            {
                situationAButton = new Button(57, 160 + topOffset, 420, 180, "s1", situationButtonStyle, () => { OnVoteClicked(activeMinigameCopy.ActiveQuestion.SituationA); });
                situationBButton = new Button(620, 160 + topOffset, 420, 180, "s2", situationButtonStyle, () => { OnVoteClicked(activeMinigameCopy.ActiveQuestion.SituationB); });
                situationALabel  = new Label(57, 160 + topOffset, 420, 180, activeMinigameCopy.ActiveQuestion.SituationA, situationLabelStyle);
                situationBLabel  = new Label(620, 160 + topOffset, 420, 180, activeMinigameCopy.ActiveQuestion.SituationB, situationLabelStyle);
                rootElement.AddChild(situationAButton);
                rootElement.AddChild(situationALabel);
                rootElement.AddChild(situationBButton);
                rootElement.AddChild(situationBLabel);
            }
            else if (state == 1)     // voted
            {
                var votedSituation = activeMinigameCopy.ActiveQuestionVotes[NetworkManager.Instance.PlayerData.GUID];
                if (votedSituation == activeMinigameCopy.ActiveQuestion.SituationA)
                {
                    situationAButton = new Button(57, 160 + topOffset, 420, 180, "s1", situationButtonStyle);
                    situationALabel  = new Label(57, 160 + topOffset, 420, 180, activeMinigameCopy.ActiveQuestion.SituationA, situationLabelStyle);
                    rootElement.AddChild(situationAButton);
                    rootElement.AddChild(situationALabel);
                }
                else
                {
                    situationBButton = new Button(57, 160 + topOffset, 420, 180, "s2", situationButtonStyle);
                    situationBLabel  = new Label(57, 160 + topOffset, 420, 180, activeMinigameCopy.ActiveQuestion.SituationB, situationLabelStyle);
                    rootElement.AddChild(situationBButton);
                    rootElement.AddChild(situationBLabel);
                }
                var totalVotes     = NetworkManager.Instance.ActiveRoom.Players.Count;
                var remainingVotes = activeMinigameCopy.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     // results
            {
                var totalVotes = NetworkManager.Instance.ActiveRoom.Players.Count;
                var(winnerSituation, winnerVotes) = activeMinigameCopy.Result();
                if (winnerSituation == activeMinigameCopy.ActiveQuestion.SituationA)
                {
                    situationAButton = new Button(57, 160 + topOffset, 420, 180, "s1", situationButtonStyle);
                    situationALabel  = new Label(57, 160 + topOffset, 420, 180, activeMinigameCopy.ActiveQuestion.SituationA, situationLabelStyle);
                    rootElement.AddChild(situationAButton);
                    rootElement.AddChild(situationALabel);
                }
                else
                {
                    situationBButton = new Button(57, 160 + topOffset, 420, 180, "s2", situationButtonStyle);
                    situationBLabel  = new Label(57, 160 + topOffset, 420, 180, activeMinigameCopy.ActiveQuestion.SituationB, situationLabelStyle);
                    rootElement.AddChild(situationBButton);
                    rootElement.AddChild(situationBLabel);
                }
                resultLabel = new Label(620, 160 + topOffset, 420, 90, $"WINNER\nWith {winnerVotes}/{totalVotes} votes", resultStyle);
                rootElement.AddChild(resultLabel);
                if (!isOwner)
                {
                    rootElement.AddChild(new Label(620, 250 + topOffset, 420, 90, "WAITING FOR CREATOR TO MOVE ON TO THE NEXT QUESTION", alertStyle));
                }
            }

            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);
        }
        public override void Load()
        {
            var textFieldBackground = Color.FromArgb(255, 73, 65, 54);
            var textFieldText       = Color.FromArgb(255, 227, 227, 222);
            var textFieldStyle      = TextFieldStyle.Default.Alter(backgroundNormal: textFieldBackground, backgroundFocused: textFieldBackground, borderNormal: Color.Transparent, borderFocused: Color.Transparent, borderSizeNormal: 4f, borderSizeFocused: 4f, caretNormal: textFieldText, caretFocused: textFieldText, textNormal: textFieldText, textFocused: textFieldText);
            var checkboxStyle       = CheckboxStyle.Default.Alter(backgroundColorNormal: textFieldBackground, backgroundColorHover: textFieldBackground, backgroundColorPressed: textFieldBackground, borderColorNormal: Color.Transparent, borderColorHover: Color.Transparent, borderColorPressed: Color.Transparent, tickColorHover: textFieldText, tickColorNormal: textFieldText, tickColorPressed: textFieldText);

            backgroundImage1 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/rocks/menu_1.jpg", false, false))
            {
                x = 0f
            };
            backgroundImage2 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/rocks/menu_2.jpg", false, false))
            {
                x = -100000f
            };
            backgroundImage3 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/rocks/menu_3.jpg", false, false))
            {
                x = -100000f
            };
            Root.AddChild(backgroundImage1);
            Root.AddChild(backgroundImage2);
            Root.AddChild(backgroundImage3);
            var tab1 = new Pivot();

            tab2 = new Pivot();
            tab2.SetXY(width / 3f, 0f);
            tab3 = new Pivot();
            tab3.SetXY(2f * width / 3f, 0f);
            Root.AddChild(tab1);
            Root.AddChild(tab2);
            Root.AddChild(tab3);
            var tab1Main         = new Pivot();
            var tab1CreatePublic = new Pivot {
                x = -100000f
            };
            var tab1CreatePrivate = new Pivot {
                x = -100000f
            };

            tab1.AddChild(tab1Main);
            tab1.AddChild(tab1CreatePublic);
            tab1.AddChild(tab1CreatePrivate);
            tab1Main.AddChild(new Button(133, 358, 449, 83, "Create public room", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePublic.x = 0f;
                backgroundImage2.x = 0f;
                tab1Main.x         = -100000f;
                backgroundImage1.x = -100000f;
            }));
            tab1Main.AddChild(new Button(133, 509, 449, 83, "Create private room", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePrivate.x = 0;
                backgroundImage3.x  = 0f;
                tab1Main.x          = -100000f;
                backgroundImage1.x  = -100000f;
            }));
            tab1Main.AddChild(new Button(267, 836, 177, 83, "Back", ButtonStyle.Transparent, () => {
                NetworkManager.Instance.JoinLocation("none", false);
            }));
            tab1CreatePublic.AddChild(publicRoomNameTextField        = new TextField(111, 315, 499, 60, "", textFieldStyle));
            tab1CreatePublic.AddChild(publicRoomDescriptionTextField = new TextField(111, 462, 499, 60, "", textFieldStyle));
            tab1CreatePublic.AddChild(publicRoomNSFWCheckbox         = new Checkbox(80, 617, 564, 40, "", checkboxStyle));
            tab1CreatePublic.AddChild(new Button(190, 679, 338, 83, "Create", ButtonStyle.Transparent, onClick: () => {
                if (string.IsNullOrEmpty(publicRoomNameTextField.Text) || string.IsNullOrEmpty(publicRoomDescriptionTextField.Text))
                {
                    return;
                }
                NetworkManager.Instance.CreateAndJoinRoom(publicRoomNameTextField.Text, publicRoomDescriptionTextField.Text, "", publicRoomNSFWCheckbox.IsChecked, true);
                publicRoomNameTextField.Text        = "";
                publicRoomDescriptionTextField.Text = "";
                publicRoomNSFWCheckbox.IsChecked    = false;
                tab1CreatePublic.x = -100000f;
                backgroundImage2.x = -100000f;
                tab1Main.x         = 0f;
                backgroundImage1.x = 0f;
                RefreshRooms();
            }));
            tab1CreatePublic.AddChild(new Button(267, 836, 177, 83, "Back", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePublic.x = -100000f;
                backgroundImage2.x = -100000f;
                tab1Main.x         = 0f;
                backgroundImage1.x = 0f;
            }));
            tab1CreatePrivate.AddChild(privateRoomNameTextField        = new TextField(111, 315, 499, 60, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomDescriptionTextField = new TextField(111, 442, 499, 60, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomCodeTextField        = new TextField(111, 568, 499, 60, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomNSFWCheckbox         = new Checkbox(85, 650, 560, 40, "", checkboxStyle));
            tab1CreatePrivate.AddChild(new Button(191, 709, 338, 83, "Create", ButtonStyle.Transparent, onClick: () => {
                if (string.IsNullOrEmpty(privateRoomNameTextField.Text) || string.IsNullOrEmpty(privateRoomDescriptionTextField.Text) || string.IsNullOrEmpty(privateRoomCodeTextField.Text))
                {
                    return;
                }
                NetworkManager.Instance.CreateAndJoinRoom(privateRoomNameTextField.Text, privateRoomDescriptionTextField.Text, privateRoomCodeTextField.Text, privateRoomNSFWCheckbox.IsChecked, false);
                privateRoomNameTextField.Text        = "";
                privateRoomDescriptionTextField.Text = "";
                privateRoomCodeTextField.Text        = "";
                privateRoomNSFWCheckbox.IsChecked    = false;
                tab1CreatePrivate.x = -100000f;
                backgroundImage3.x  = -100000f;
                tab1Main.x          = 0f;
                backgroundImage1.x  = 0f;
                RefreshRooms();
            }));
            tab1CreatePrivate.AddChild(new Button(267, 836, 177, 83, "Back", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePrivate.x = -100000f;
                backgroundImage3.x  = -100000f;
                tab1Main.x          = 0f;
                backgroundImage1.x  = 0f;
            }));

            tab2.AddChild(loadingPrivateRooms = new AnimatedSprite(Texture2D.GetInstance("data/sprites/spinner.png", true), 12, 1, 0.083F)
            {
                x = -100000f, y = 232 + 64f - 48f, scale = 0.75f
            });
            tab2.AddChild(new Button(815f - width / 3f, 838, 283, 83, "Refresh", ButtonStyle.Transparent, onClick: () => { RefreshRooms(); }));

            tab3.AddChild(loadingPublicRooms = new AnimatedSprite(Texture2D.GetInstance("data/sprites/spinner.png", true), 12, 1, 0.083F)
            {
                x = -100000f, y = 232 + 64f - 48f, scale = 0.75f
            });
            tab3.AddChild(new Button(1390 - 2 * width / 3f, 838, 283, 83, "Refresh", ButtonStyle.Transparent, onClick: () => { RefreshRooms(); }));

            RefreshRooms();
            IsLoaded = true;
        }
        public override void Load()
        {
            var textFieldStyle = TextFieldStyle.Default.Alter(backgroundNormal: Color.FromArgb(255, 73, 73, 81), backgroundFocused: Color.FromArgb(255, 73, 73, 81), borderNormal: Color.Transparent, borderFocused: Color.Transparent, borderSizeNormal: 4f, borderSizeFocused: 4f, caretNormal: Color.White, caretFocused: Color.White);
            var checkboxStyle  = CheckboxStyle.Default.Alter(backgroundColorNormal: Color.FromArgb(255, 73, 73, 81), backgroundColorHover: Color.FromArgb(255, 73, 73, 81), backgroundColorPressed: Color.FromArgb(255, 73, 73, 81), borderColorNormal: Color.Transparent, borderColorHover: Color.Transparent, borderColorPressed: Color.Transparent);

            backgroundImage1 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/coffee_fellows/menu_1.jpg", true, false))
            {
                x = 0f
            };
            backgroundImage2 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/coffee_fellows/menu_2.jpg", true, false))
            {
                x = -100000f
            };
            backgroundImage3 = new Image(0, 0, Globals.WIDTH, Globals.HEIGHT, new game.Sprite("data/sprites/locations/coffee_fellows/menu_3.jpg", true, false))
            {
                x = -100000f
            };
            Root.AddChild(backgroundImage1);
            Root.AddChild(backgroundImage2);
            Root.AddChild(backgroundImage3);
            var tab1 = new Pivot();

            tab2 = new Pivot();
            tab2.SetXY(width / 3f, 0f);
            tab3 = new Pivot();
            tab3.SetXY(2f * width / 3f, 0f);
            Root.AddChild(tab1);
            Root.AddChild(tab2);
            Root.AddChild(tab3);
            var tab1Main         = new Pivot();
            var tab1CreatePublic = new Pivot {
                x = -100000f
            };
            var tab1CreatePrivate = new Pivot {
                x = -100000f
            };

            tab1.AddChild(tab1Main);
            tab1.AddChild(tab1CreatePublic);
            tab1.AddChild(tab1CreatePrivate);
            tab1Main.AddChild(new Button(135, 373, 448, 55, "Create public room", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePublic.x = 0f;
                backgroundImage2.x = 0f;
                tab1Main.x         = -100000f;
                backgroundImage1.x = -100000f;
            }));
            tab1Main.AddChild(new Button(111, 521, 494, 58, "Create private room", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePrivate.x = 0;
                backgroundImage3.x  = 0f;
                tab1Main.x          = -100000f;
                backgroundImage1.x  = -100000f;
            }));
            tab1Main.AddChild(new Button(253, 851, 168, 65, "Back", ButtonStyle.Transparent, () => {
                NetworkManager.Instance.JoinLocation("none", false);
            }));
            tab1CreatePublic.AddChild(publicRoomNameTextField        = new TextField(103, 284, 518, 40, "", textFieldStyle));
            tab1CreatePublic.AddChild(publicRoomDescriptionTextField = new TextField(103, 422, 518, 40, "", textFieldStyle));
            tab1CreatePublic.AddChild(publicRoomNSFWCheckbox         = new Checkbox(103 - 16f, 507, 518 + 16f, 40, "", checkboxStyle));
            tab1CreatePublic.AddChild(new Button(200, 597, 293, 57, "Create", ButtonStyle.Transparent, onClick: () => {
                if (string.IsNullOrEmpty(publicRoomNameTextField.Text) || string.IsNullOrEmpty(publicRoomDescriptionTextField.Text))
                {
                    return;
                }
                NetworkManager.Instance.CreateAndJoinRoom(publicRoomNameTextField.Text, publicRoomDescriptionTextField.Text, "", publicRoomNSFWCheckbox.IsChecked, true);
                publicRoomNameTextField.Text        = "";
                publicRoomDescriptionTextField.Text = "";
                publicRoomNSFWCheckbox.IsChecked    = false;
                tab1CreatePublic.x = -100000f;
                backgroundImage2.x = -100000f;
                tab1Main.x         = 0f;
                backgroundImage1.x = 0f;
                RefreshRooms();
            }));
            tab1CreatePublic.AddChild(new Button(253, 851, 168, 65, "Back", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePublic.x = -100000f;
                backgroundImage2.x = -100000f;
                tab1Main.x         = 0f;
                backgroundImage1.x = 0f;
            }));
            tab1CreatePrivate.AddChild(privateRoomNameTextField        = new TextField(103, 284, 518, 40, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomDescriptionTextField = new TextField(103, 403, 518, 40, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomCodeTextField        = new TextField(103, 528, 518, 40, "", textFieldStyle));
            tab1CreatePrivate.AddChild(privateRoomNSFWCheckbox         = new Checkbox(103 - 16f, 595, 518 + 16f, 40, "", checkboxStyle));
            tab1CreatePrivate.AddChild(new Button(200, 640, 293, 57, "Create", ButtonStyle.Transparent, onClick: () => {
                if (string.IsNullOrEmpty(privateRoomNameTextField.Text) || string.IsNullOrEmpty(privateRoomDescriptionTextField.Text) || string.IsNullOrEmpty(privateRoomCodeTextField.Text))
                {
                    return;
                }
                NetworkManager.Instance.CreateAndJoinRoom(privateRoomNameTextField.Text, privateRoomDescriptionTextField.Text, privateRoomCodeTextField.Text, privateRoomNSFWCheckbox.IsChecked, false);
                privateRoomNameTextField.Text        = "";
                privateRoomDescriptionTextField.Text = "";
                privateRoomCodeTextField.Text        = "";
                privateRoomNSFWCheckbox.IsChecked    = false;
                tab1CreatePrivate.x = -100000f;
                backgroundImage3.x  = -100000f;
                tab1Main.x          = 0f;
                backgroundImage1.x  = 0f;
                RefreshRooms();
            }));
            tab1CreatePrivate.AddChild(new Button(253, 851, 168, 65, "Back", ButtonStyle.Transparent, onClick: () => {
                tab1CreatePrivate.x = -100000f;
                backgroundImage3.x  = -100000f;
                tab1Main.x          = 0f;
                backgroundImage1.x  = 0f;
            }));

            tab2.AddChild(loadingPrivateRooms = new AnimatedSprite(Texture2D.GetInstance("data/sprites/spinner.png", true), 12, 1, 0.083F)
            {
                x = -100000f, y = 250 + 64f - 48f, scale = 0.75f
            });
            tab2.AddChild(new Button(809f - width / 3f, 858, 270, 65, "Refresh", ButtonStyle.Transparent, onClick: () => { RefreshRooms(); }));

            tab3.AddChild(loadingPublicRooms = new AnimatedSprite(Texture2D.GetInstance("data/sprites/spinner.png", true), 12, 1, 0.083F)
            {
                x = -100000f, y = 250 + 64f - 48f, scale = 0.75f
            });
            tab3.AddChild(new Button(1400 - 2 * width / 3f, 858, 270, 65, "Refresh", ButtonStyle.Transparent, onClick: () => { RefreshRooms(); }));

            RefreshRooms();
            IsLoaded = true;
        }
        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);
        }
Esempio n. 11
0
        public void Initialize(int state)
        {
            Deinitialize();
            var isOwner        = NetworkManager.Instance.PlayerData.GUID == NetworkManager.Instance.ActiveMinigame1.Owner;
            var backgroundPath = "data/sprites/minigames/1/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, NetworkManager.Instance.ActiveMinigame1.ActiveQuestion, questionStyle);
            rootElement.AddChild(questionLabel);
            if (state == 0)
            {
                playerAvatars = new List <PlayerAvatarElement>();
                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, () => { OnVoteClicked(player.GUID); }, spriteSize);
                    index++;
                    playerAvatars.Add(playerAvatar);
                }

                playerAvatars.ForEach(avatar => rootElement.AddChild(avatar));
            }
            else if (state == 1)
            {
                var votedGUID = NetworkManager.Instance.ActiveMinigame1.ActiveQuestionVotes[NetworkManager.Instance.PlayerData.GUID];
                var voted     = NetworkManager.Instance.ActiveRoom.Players[votedGUID];
                votedPlayer = new PlayerAvatarElement(bounds.width / 4f - 64f, bounds.height / 2f - 64f + topOffset, voted.Username, voted.AvatarIndex, playerNameStyle);
                rootElement.AddChild(votedPlayer);
                var totalVotes     = NetworkManager.Instance.ActiveRoom.Players.Count;
                var remainingVotes = NetworkManager.Instance.ActiveMinigame1.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 totalVotes = NetworkManager.Instance.ActiveRoom.Players.Count;
                var(winnerGuid, winnerVotes) = NetworkManager.Instance.ActiveMinigame1.Result();
                var winner = NetworkManager.Instance.ActiveRoom.Players[winnerGuid];
                resultPlayer = new PlayerAvatarElement(20, bounds.height / 2f - 64f + topOffset, winner.Username, winner.AvatarIndex, playerNameStyle);
                rootElement.AddChild(resultPlayer);
                resultLabel = new Label(168f, 100 + topOffset, bounds.width / 2f, 250, $"WINNER\nWith {winnerVotes}/{totalVotes} votes", resultStyle);
                rootElement.AddChild(resultLabel);
                if (!isOwner)
                {
                    rootElement.AddChild(new Label(bounds.width / 2f, 100 + topOffset, bounds.width / 2f, 250, "WAITING FOR CREATOR TO MOVE ON TO THE NEXT QUESTION", alertStyle));
                }
            }

            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);
        }