예제 #1
0
파일: MenuMain.cs 프로젝트: datnewb/Kartus
 void OnEnable()
 {
     mainMenuHandler = GetComponent <MainMenuHandler>();
     mainMenuCanvas  = mainMenuHandler.mainMenuCanvas;
     MainMenuHandler.DisableAllCanvases();
     mainMenuCanvas.enabled = true;
 }
예제 #2
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);
         }
     }
 }
예제 #3
0
    void OnEnable()
    {
        mainMenuHandler  = GetComponent <MainMenuHandler>();
        createGameCanvas = mainMenuHandler.createGameCanvas;

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

        MainMenuHandler.DisableAllCanvases();
        createGameCanvas.enabled = true;
    }
예제 #4
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;
    }
예제 #5
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;
    }
예제 #6
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);
            }
        }
    }