protected override void DidActivate(bool firstActivation, ActivationType type)
        {
            ui = BSMultiplayerUI._instance;

            _parentMasterViewController = transform.parent.GetComponent <MultiplayerLobbyViewController>();

            _leaderboardTableCellInstance = Resources.FindObjectsOfTypeAll <LeaderboardTableCell>().First(x => (x.name == "LeaderboardTableCell"));

            if (_leaderboardTableView == null)
            {
                _leaderboardTableView = new GameObject().AddComponent <TableView>();

                _leaderboardTableView.transform.SetParent(rectTransform, false);

                Mask viewportMask = Instantiate(Resources.FindObjectsOfTypeAll <Mask>().First(), _leaderboardTableView.transform, false);
                viewportMask.transform.DetachChildren();

                _leaderboardTableView.GetComponentsInChildren <RectTransform>().First(x => x.name == "Content").transform.SetParent(viewportMask.rectTransform, false);

                (_leaderboardTableView.transform as RectTransform).anchorMin        = new Vector2(0f, 0.5f);
                (_leaderboardTableView.transform as RectTransform).anchorMax        = new Vector2(1f, 0.5f);
                (_leaderboardTableView.transform as RectTransform).sizeDelta        = new Vector2(0f, 60f);
                (_leaderboardTableView.transform as RectTransform).anchoredPosition = new Vector3(0f, -3f);
            }
        }
예제 #2
0
        IEnumerator WaitForResults()
        {
            yield return(new WaitUntil(delegate() { return Resources.FindObjectsOfTypeAll <ResultsViewController>().Count() > 0; }));

            ResultsViewController results = Resources.FindObjectsOfTypeAll <ResultsViewController>().First();

            results.GetComponentsInChildren <Button>().First(x => x.name == "RestartButton").interactable = false;


            results.resultsViewControllerDidPressContinueButtonEvent += delegate(ResultsViewController viewController) {
                try
                {
                    MultiplayerServerHubViewController hub   = ui.CreateViewController <MultiplayerServerHubViewController>();
                    MultiplayerLobbyViewController     lobby = ui.CreateViewController <MultiplayerLobbyViewController>();

                    viewController.DismissModalViewController(null, true);
                    FindObjectOfType <SongSelectionMasterViewController>().DismissModalViewController(null, true);
                    FindObjectOfType <SoloModeSelectionViewController>().DismissModalViewController(null, true);

                    hub.doNotUpdate = true;
                    FindObjectOfType <MainMenuViewController>().PresentModalViewController(hub, null, true);
                    lobby.selectedServerIP   = lastServerIP;
                    lobby.selectedServerPort = lastServerPort;
                    hub.PresentModalViewController(lobby, null, true);
                }
                catch (Exception e)
                {
                    Console.WriteLine($"RESULTS EXCEPTION: {e}");
                }
            };
        }
        public void ConnectToServer(string serverIP, int serverPort)
        {
            MultiplayerLobbyViewController lobby = ui.CreateViewController <MultiplayerLobbyViewController>();

            lobby.selectedServerIP   = serverIP;
            lobby.selectedServerPort = serverPort;

            PresentModalViewController(lobby, null);
        }
예제 #4
0
        IEnumerator WaitForMenu()
        {
            yield return(new WaitUntil(delegate() { return Resources.FindObjectsOfTypeAll <VRUIScreenSystem>().Any(); }));

            VRUIScreenSystem screenSystem = Resources.FindObjectsOfTypeAll <VRUIScreenSystem>().First();

            yield return(new WaitWhile(delegate() { Console.WriteLine("Waiting for mainScreen"); return screenSystem.mainScreen == null; }));

            yield return(new WaitWhile(delegate() { Console.WriteLine("Waiting for rootViewController"); return screenSystem.mainScreen.rootViewController == null; }));

            try
            {
                VRUIViewController root = screenSystem.mainScreen.rootViewController;

                List <VRUIViewController> children = new List <VRUIViewController>();

                children.Add(root);

                while (children.Last().childViewController != null)
                {
                    children.Add(children.Last().childViewController);
                }

                children.Reverse();
                children.Remove(root);
                children.ForEach(x => { Console.WriteLine($"Dismissing {x.name}..."); x.DismissModalViewController(null, true); });

                MultiplayerServerHubViewController hub   = ui.CreateViewController <MultiplayerServerHubViewController>();
                MultiplayerLobbyViewController     lobby = ui.CreateViewController <MultiplayerLobbyViewController>();

                bool serverClosed = (lastCommands != null) ? lastCommands.Any(x => x.commandType == ServerCommandType.Kicked && x.kickReason == "Server closed") : false;

                hub.doNotUpdate = !serverClosed;
                FindObjectOfType <MainMenuViewController>().PresentModalViewController(hub, null, true);
                if (!serverClosed)
                {
                    lobby.selectedServerIP   = lastServerIP;
                    lobby.selectedServerPort = lastServerPort;
                    hub.PresentModalViewController(lobby, null, true);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"MENU EXCEPTION: {e}");
            }
        }
        private void CreateMultiplayerButton()
        {
            Button _multiplayerButton = CreateUIButton(_mainMenuRectTransform, "PartyButton");

            Console.ForegroundColor = ConsoleColor.Gray;

            (Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "SoloButton").transform as RectTransform).anchoredPosition  = new Vector2(-19f, 8f);
            (Resources.FindObjectsOfTypeAll <Button>().First(x => x.name == "PartyButton").transform as RectTransform).anchoredPosition = new Vector2(-18f, 8f);


            try
            {
                (_multiplayerButton.transform as RectTransform).anchoredPosition = new Vector2(19f, 8f);
                (_multiplayerButton.transform as RectTransform).sizeDelta        = new Vector2(36f, 36f);

                SetButtonText(ref _multiplayerButton, "Online");

                SetButtonIcon(ref _multiplayerButton, Base64ToSprite(Base64Sprites.onlineIcon));

                _multiplayerButton.onClick.AddListener(delegate() {
                    try
                    {
                        if (_multiplayerLobbyViewController == null)
                        {
                            _multiplayerLobbyViewController = CreateViewController <MultiplayerLobbyViewController>();
                        }
                        _mainMenuViewController.PresentModalViewController(_multiplayerLobbyViewController, null, false);
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("EXCETPION IN BUTTON: " + e.Message);
                    }
                });
            }
            catch (Exception e)
            {
                Console.WriteLine("EXCEPTION: " + e.Message);
            }
        }