Inheritance: MonoBehaviour
Beispiel #1
0
    public void Quit()
    {
        MainMenuHandler.DisableInputReceive();

        string title   = "QUIT";
        string message = "Do you really want to quit?";

        if (Network.isServer)
        {
            message += " Other players will immediately get disconnected.";
        }
        UnityAction yesAction = () =>
        {
            FindObjectOfType <GameManager>().LoadLevel("Main Menu", 0);
            Network.Disconnect(200);
        };
        UnityAction noAction = () =>
        {
            Destroy(confirmDialogInstance);
            confirmDialogInstance = null;
            MainMenuHandler.EnableInputReceive();
        };

        confirmDialogInstance = Instantiate(confirmDialogPrefab);
        ConfirmBox confirmDialogInfo = confirmDialogInstance.GetComponent <ConfirmBox>();

        confirmDialogInfo.title.text   = title;
        confirmDialogInfo.message.text = message;
        confirmDialogInfo.yesButton.onClick.AddListener(yesAction);
        confirmDialogInfo.noButton.onClick.AddListener(noAction);
    }
Beispiel #2
0
    public void BackToMainMenu()
    {
        if (gameSettings.valueChanged)
        {
            string      title     = "UNSAVED CHANGES";
            string      message   = "There are unsaved changes in the settings. Would you like to apply them first?";
            UnityAction yesAction = () =>
            {
                ApplySettings();
                mainMenuHandler.GoToMainMenu();
                Destroy(mainMenuHandler.dialogInstance);
                MainMenuHandler.EnableInputReceive();
            };
            UnityAction noAction = () =>
            {
                ResetSettings();
                mainMenuHandler.GoToMainMenu();
                Destroy(mainMenuHandler.dialogInstance);
                MainMenuHandler.EnableInputReceive();
            };

            mainMenuHandler.ShowConfirmDialog(title, message, yesAction, noAction);
        }
        else
        {
            mainMenuHandler.GoToMainMenu();
        }
    }
Beispiel #3
0
 void OnEnable()
 {
     mainMenuHandler = GetComponent <MainMenuHandler>();
     mainMenuCanvas  = mainMenuHandler.mainMenuCanvas;
     MainMenuHandler.DisableAllCanvases();
     mainMenuCanvas.enabled = true;
 }
Beispiel #4
0
 void OnDisconnectedFromServer(NetworkDisconnection info)
 {
     foreach (NetworkView networkView in FindObjectsOfType <NetworkView>())
     {
         if (networkView.stateSynchronization != NetworkStateSynchronization.Off)
         {
             Destroy(networkView.gameObject);
         }
     }
     if (Network.isClient)
     {
         if (info == NetworkDisconnection.Disconnected)
         {
             MainMenuHandler.DisableAllCanvases();
             string      title    = "SERVER CLOSED";
             string      message  = "The host left the game.";
             UnityAction okAction = () =>
             {
                 Destroy(mainMenuHandler.dialogInstance);
                 MainMenuHandler.EnableInputReceive();
                 mainMenuHandler.GoToMainMenu();
             };
             mainMenuHandler.ShowErrorDialog(title, message, okAction);
         }
     }
 }
Beispiel #5
0
 public void Awake()
 {
     menuState       = transform.parent.GetComponent <MainMenuHandler>();
     anim            = GetComponent <Animator>();
     bg              = GetComponentInChildren <Image>();
     mainMenuHandler = transform.parent.GetComponent <IMainMenuHandler>();
 }
Beispiel #6
0
    void OnEnable()
    {
        mainMenuHandler = GetComponent<MainMenuHandler>();
        joinGameCanvas = mainMenuHandler.joinGameCanvas;

        MainMenuHandler.DisableAllCanvases();
        joinGameCanvas.enabled = true;
    }
Beispiel #7
0
 public void OnTaskCompleted(int index)
 {
     PlaySound(taskCompletedSFX);
     if (menuHandlerClass == null)
     {
         menuHandlerClass = FindObjectOfType <MainMenuHandler>().GetComponent <MainMenuHandler>();
     }
     menuHandlerClass.CompleteTask(index);
 }
Beispiel #8
0
 public void OnPrevChapterArrowClicked()
 {
     PlaySound(buttonClick);
     if (menuHandlerClass == null)
     {
         menuHandlerClass = FindObjectOfType <MainMenuHandler>().GetComponent <MainMenuHandler>();
     }
     menuHandlerClass.LeftArrowClicked();
 }
Beispiel #9
0
 public void LoadChapter()
 {
     PlaySound(wooshSFX);
     if (menuHandlerClass == null)
     {
         menuHandlerClass = FindObjectOfType <MainMenuHandler>().GetComponent <MainMenuHandler>();
     }
     menuHandlerClass.LoadChapter();
 }
Beispiel #10
0
    void OnConnectedToServer()
    {
        Destroy(mainMenuHandler.dialogInstance);
        MainMenuHandler.EnableInputReceive();

        enabled = false;
        GetComponent <LobbyManager>().enabled = true;
        GetComponent <MenuLobby>().enabled    = true;
        Network.Instantiate(mainMenuHandler.playerInfoPrefab, Vector3.zero, Quaternion.identity, 0);
    }
Beispiel #11
0
    public void PlayerNameOK()
    {
        if (mainMenuHandler.dialogInstance.GetComponent <TextInputBox>().inputField.text != "")
        {
            ApplyPlayerName(mainMenuHandler.dialogInstance.GetComponent <TextInputBox>().inputField.text);

            Destroy(mainMenuHandler.dialogInstance);
            MainMenuHandler.EnableInputReceive();
        }
    }
Beispiel #12
0
    void OnEnable()
    {
        mainMenuHandler = GetComponent<MainMenuHandler>();
        createGameCanvas = mainMenuHandler.createGameCanvas;

        selectedGameMode = null;
        gameModeTitle.text = "";
        gameModeDesc.text = "";

        MainMenuHandler.DisableAllCanvases();
        createGameCanvas.enabled = true;
    }
Beispiel #13
0
    private void ErrorTeamNotSelected()
    {
        string      title    = "ERROR";
        string      message  = "Not all players are in a team. Wait for them to choose a team.";
        UnityAction okAction = () =>
        {
            MainMenuHandler.EnableInputReceive();
            Destroy(mainMenuHandler.dialogInstance);
        };

        mainMenuHandler.ShowErrorDialog(title, message, okAction);
    }
Beispiel #14
0
    void OnEnable()
    {
        mainMenuHandler  = GetComponent <MainMenuHandler>();
        createGameCanvas = mainMenuHandler.createGameCanvas;

        selectedGameMode   = null;
        gameModeTitle.text = "";
        gameModeDesc.text  = "";

        MainMenuHandler.DisableAllCanvases();
        createGameCanvas.enabled = true;
    }
Beispiel #15
0
        public static void Main()
        {
            // Resolved deps.
            var output           = new ConsoleOutput();
            var characterService = new CharacterService();

            var textGenerator                  = new TextGenerator();
            var dialogModalScreenHandler       = new DialogModalScreenHandler(textGenerator, output);
            var screenNavigation               = new ScreenNavigation(dialogModalScreenHandler);
            var connectionManager              = new ConnectionManager();
            var mainMenuHandler                = new MainMenuHandler(screenNavigation, connectionManager);
            var mainMenuPrinter                = new MainMenuPrinter(output, characterService);
            var mainMenuScreenHandler          = new MainMenuScreenHandler(textGenerator, mainMenuHandler, mainMenuPrinter);
            var characterCreationHandler       = new CharacterCreationHandler(screenNavigation);
            var characterCreationPrinter       = new CharacterCreationPrinter(output, characterService);
            var characterCreationScreenHandler = new CharacterCreationScreenHandler(textGenerator, characterCreationHandler, characterCreationPrinter);

            var screenProvider = new ScreenHandlerProvider(screenNavigation, mainMenuScreenHandler, characterCreationScreenHandler, dialogModalScreenHandler);

            // Authenticated and got list of characters from API.
            var characters = new[] { "1", "2", "ivan-id" };

            mainMenuScreenHandler.UpdateState(new MainMenuState(characters));

            while (true)
            {
                Console.Clear();
                var screen = screenProvider.GetCurrentScreenHandler();

                screen.PrintState();

                var key = Console.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.Escape:
                    screen.Escape();
                    break;

                case ConsoleKey.Backspace:
                    screen.Backspace();
                    break;

                case ConsoleKey.Tab:
                    screen.Tab();
                    break;

                default:
                    screen.Type(key.KeyChar);
                    break;
                }
            }
        }
    // Start is called before the first frame update
    void Start()
    {
        sounds        = GetComponent <SoundHandler>();
        containerRect = container.GetComponent <RectTransform>();

        instance = this;

        perks = new UIPerksList(perkList, perkDescPrefab);
        perks.LoadPerks((perk, title, desc) =>
        {
            perk.LevelUp();
            title.text = $"{perk.Name} lvl {perk.Level}";
            desc.text  = perk.Description;
        });
    }
Beispiel #17
0
    public void StartButton()
    {
        if (ReservesCount() > 0)
        {
            ErrorTeamNotSelected();
            return;
        }
        if (!CheckIfAllSelected())
        {
            ErrorKartNotSelected();
            return;
        }

        MainMenuHandler.DisableInputReceive();
        StartCoroutine(CountDownToStart());
    }
Beispiel #18
0
        public void OnEnabled()
        {
            try
            {
                Log.Info("Attempting to patch Cities: Skylines using Harmony...");
                _harmony = new Harmony("com.citiesskylinesmultiplayer");
                _harmony.PatchAll(Assembly.GetExecutingAssembly());
                Log.Info("Successfully patched Cities: Skylines!");
            }
            catch (Exception ex)
            {
                Log.Error("Patching failed", ex);
            }

            MainMenuHandler.CreateOrUpdateJoinGameButton();

            Log.Info("Construction Complete!");
        }
Beispiel #19
0
        public void OnEnabled()
        {
            try
            {
                _logger.Info("Attempting to patch Cities: Skylines using Harmony...");
                _harmony = new Harmony("net.gridentertainment.csm");
                _harmony.PatchAll(Assembly.GetExecutingAssembly());
                _logger.Info("Successfully patched Cities: Skylines!");
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Patching failed");
            }

            MainMenuHandler.CreateOrUpdateJoinGameButton();

            _logger.Info("Construction Complete!");
        }
Beispiel #20
0
    public void BackToPauseMenu()
    {
        if (gameSettings.valueChanged)
        {
            string      title     = "UNSAVED CHANGES";
            string      message   = "There are unsaved changes in the settings. Would you like to apply them first?";
            UnityAction yesAction = () =>
            {
                ApplySettings();
                FindObjectOfType <UIPauseMenu>().pauseCanvas.enabled = true;
                settingsCanvas.enabled = false;
                Destroy(dialogInstance);
                dialogInstance = null;
                MainMenuHandler.EnableInputReceive();
            };
            UnityAction noAction = () =>
            {
                ResetSettings();
                FindObjectOfType <UIPauseMenu>().pauseCanvas.enabled = true;
                settingsCanvas.enabled = false;
                Destroy(dialogInstance);
                dialogInstance = null;
                MainMenuHandler.EnableInputReceive();
            };

            MainMenuHandler.DisableInputReceive();
            dialogInstance = Instantiate(confirmDialogBox);

            ConfirmBox confirmDialogInfo = dialogInstance.GetComponent <ConfirmBox>();
            confirmDialogInfo.title.text   = title;
            confirmDialogInfo.message.text = message;
            confirmDialogInfo.yesButton.onClick.AddListener(yesAction);
            confirmDialogInfo.noButton.onClick.AddListener(noAction);
        }
        else
        {
            FindObjectOfType <UIPauseMenu>().pauseCanvas.enabled = true;
            settingsCanvas.enabled = false;
        }
    }
Beispiel #21
0
    private void ErrorTooManyOfSameKart(GameModeTeams teams)
    {
        string title   = "ERROR";
        string message = "";

        switch (teams)
        {
        case GameModeTeams.None:
            message = "Two other players have already selected this kart. Choose something else.";
            break;

        case GameModeTeams.Two:
            message = "Your teammate has already selected this kart. Choose something else.";
            break;
        }
        UnityAction okAction = () =>
        {
            MainMenuHandler.EnableInputReceive();
            Destroy(mainMenuHandler.dialogInstance);
        };

        mainMenuHandler.ShowErrorDialog(title, message, okAction);
    }
Beispiel #22
0
    void OnEnable()
    {
        if (GetComponent <MainMenuHandler>() != null)
        {
            mainMenuHandler = GetComponent <MainMenuHandler>();
            MainMenuHandler.DisableAllCanvases();
            mainMenuHandler.settingsCanvas.enabled = true;
        }

        gameSettings          = FindObjectOfType <GameSettings>();
        fullScreenToggle.isOn = gameSettings.currentFS;
        vSyncToggle.isOn      = gameSettings.currentVsync;
        SetResolutionText();
        SetTextureQualityText();
        SetAntiAliasingText();
        motionBlurToggle.isOn = gameSettings.currentMotionBlur;

        audioVolumeSlider.value = gameSettings.currentAudioVolume;
        SetAudioVolumeText();
        mouseSensitivitySlider.value = gameSettings.currentMouseSensitivity;
        SetMouseSensitivityText();

        dialogInstance = null;
    }
Beispiel #23
0
    void OnEnable()
    {
        mainMenuHandler = GetComponent <MainMenuHandler>();
        lobbyCanvas     = mainMenuHandler.lobbyCanvas;
        lobbyManager    = GetComponent <LobbyManager>();

        MainMenuHandler.DisableAllCanvases();
        lobbyCanvas.enabled  = true;
        lobbyManager.enabled = true;
        KartHelpClose();

        countdownText.text      = "";
        reservePlayersText.text = "";
        ClearPlayerList(playerListNoTeamText);
        ClearPlayerList(playerListWithTeamText);

        SetGameMode();
        SetIPAddress();
        SetPlayerListView();

        EnableKartSelection();
        EnableNonKartSelectionButtons();
        EnableTeamSelection();

        if (Network.isServer)
        {
            startGameButton.SetActive(true);
        }
        else if (Network.isClient)
        {
            startGameButton.SetActive(false);
        }

        kartPreview           = null;
        previousKartVariation = 0;
    }
Beispiel #24
0
 public void ConnectionFailedConfirm()
 {
     Destroy(mainMenuHandler.dialogInstance);
     MainMenuHandler.EnableInputReceive();
 }
Beispiel #25
0
 public void GameModeNotSelectedOK()
 {
     Destroy(mainMenuHandler.dialogInstance);
     MainMenuHandler.EnableInputReceive();
 }
Beispiel #26
0
 public void ExitDecline()
 {
     Destroy(mainMenuHandler.dialogInstance);
     MainMenuHandler.EnableInputReceive();
 }
 // Use this for initialization
 void Start()
 {
     MH       = canvas.transform.GetChild(1).GetComponent <MainMenuHandler> ();
     instance = this;
 }
Beispiel #28
0
    void OnEnable()
    {
        if (GetComponent<MainMenuHandler>() != null)
        {
            mainMenuHandler = GetComponent<MainMenuHandler>();
            MainMenuHandler.DisableAllCanvases();
            mainMenuHandler.settingsCanvas.enabled = true;
        }

        gameSettings = FindObjectOfType<GameSettings>();
        fullScreenToggle.isOn = gameSettings.currentFS;
        vSyncToggle.isOn = gameSettings.currentVsync;
        SetResolutionText();
        SetTextureQualityText();
        SetAntiAliasingText();
        motionBlurToggle.isOn = gameSettings.currentMotionBlur;

        audioVolumeSlider.value = gameSettings.currentAudioVolume;
        SetAudioVolumeText();
        mouseSensitivitySlider.value = gameSettings.currentMouseSensitivity;
        SetMouseSensitivityText();

        dialogInstance = null;
    }
Beispiel #29
0
 public void PlayerNameCancel()
 {
     Destroy(mainMenuHandler.dialogInstance);
     MainMenuHandler.EnableInputReceive();
 }
Beispiel #30
0
 void Start()
 {
     mainMenuHandler = GetComponent<MainMenuHandler>();
 }
Beispiel #31
0
 void Start()
 {
     mainMenuHandler = GetComponent <MainMenuHandler>();
 }
Beispiel #32
0
    IEnumerator AsyncLoadLevel(string level, int levelPrefix)
    {
        AsyncOperation loadLevel = Application.LoadLevelAsync(levelPrefix);

        if (FindObjectOfType <MainMenuHandler>() != null)
        {
            MainMenuHandler.DisableAllCanvases();
            FindObjectOfType <MainMenuHandler>().loadingScreenCanvas.enabled = true;
            FindObjectOfType <MainMenuHandler>().lobbyCanvas.enabled         = false;
            while (!loadLevel.isDone)
            {
                yield return(loadLevel.isDone);

                if (FindObjectOfType <MenuLoadingScreen>() != null)
                {
                    FindObjectOfType <MenuLoadingScreen>().SetProgressBar(loadLevel);
                }
            }
        }

        foreach (PlayerInfo playerInfo in FindObjectsOfType <PlayerInfo>())
        {
            if (playerInfo.GetComponent <NetworkView>().isMine)
            {
                playerInfo.loadingFinished = true;
                break;
            }
        }

        while (true)
        {
            bool allFinished = true;
            foreach (PlayerInfo playerInfo in FindObjectsOfType <PlayerInfo>())
            {
                if (!playerInfo.loadingFinished)
                {
                    allFinished = false;
                    break;
                }
            }

            if (allFinished)
            {
                break;
            }

            yield return(null);
        }

        if (levelPrefix > 0)
        {
            currentGameState = GameState.Game;
        }
        else
        {
            currentGameState = GameState.MainMenu;
        }
        if (FindObjectOfType <MainMenuHandler>() != null)
        {
            FindObjectOfType <MenuLoadingScreen>().enabled = false;
        }

        foreach (GameManager gameManager in FindObjectsOfType <GameManager>())
        {
            if (gameManager != this)
            {
                Destroy(gameManager);
            }
        }
    }
Beispiel #33
0
 public Arena(MainMenuHandler menu, MapHandler map)
     : base(menu, map, new Dictionary <string, (float, string[])>() {