private IEnumerator StartRoutine() { float startTime = Time.time; GameMode selectedGameMode = PlayerDataManager.SelectedGameMode; IsLoading = true; instance.loadingText.gameObject.SetActive(selectedGameMode == GameMode.Adventure); instance.waitingForOpponentText.gameObject.SetActive(selectedGameMode == GameMode.Arena); instance.waitingForPlayersText.gameObject.SetActive(selectedGameMode == GameMode.Arena2v2); for (int i = 0; i < logos.Length; i++) { logos[i].enabled = (selectedGameMode == GameMode.Adventure); } for (int j = 0; j < gameLogoParts.Length; j++) { gameLogoParts[j].SetNativeSize(); } cancelWaitingForOpponentButton.gameObject.SetActive(PlayerDataManager.IsSelectedGameModePvP); if (PlayerDataManager.IsSelectedGameModePvP) { cancelWaitingForOpponentButton.onClick.RemoveAllListeners(); cancelWaitingForOpponentButton.onClick.AddListener(delegate { StopCoroutine(loadingRoutine); IsLoading = false; TankGame.Running = false; PlayerDataManager.SelectedGameMode = GameMode.Adventure; ReloadGame(delegate { PlayerDataManager.SelectedGameMode = selectedGameMode; MenuController.HideMenu <GarageMenu>(); MenuController.ShowMenu <MainMenu>(); }); }); } canvasGroup.gameObject.SetActive(value: true); canvasGroup.alpha = 1f; while (!PlayerDataManager.IsInitialized) { yield return(null); } yield return(null); StartCoroutine(AddProgress(0.1f)); if (TankPrefs.IsInitialized) { TankPrefs.Save(); } while (selectedGameMode == GameMode.Arena && PlayerDataManager.ArenaMatchData == null) { if (!BackendManager.IsRequestingChallenge) { BackendManager.GetChallenge(PlayerDataManager.GetRating()); } yield return(null); } while (selectedGameMode == GameMode.Arena2v2 && PlayerDataManager.ArenaMultiMatchData == null) { if (!BackendManager.IsRequestingChallenge) { BackendManager.GetChallenges(PlayerDataManager.GetRating(selectedGameMode), PlayerDataManager.ArenaMultiplayerAICount); } yield return(null); } StartCoroutine(AddProgress(0.1f)); cancelWaitingForOpponentButton.onClick.RemoveAllListeners(); cancelWaitingForOpponentButton.gameObject.SetActive(value: false); if (SceneManager.GetSceneByName("Game").isLoaded) { AsyncOperation unload2 = SceneManager.UnloadSceneAsync("Game"); while (!unload2.isDone) { yield return(null); } } StartCoroutine(AddProgress(0.1f)); if (TankGame.Running) { AsyncOperation unload2 = SceneManager.LoadSceneAsync("Game", LoadSceneMode.Additive); while (!unload2.isDone) { yield return(null); } StartCoroutine(AddProgress(0.2f)); } Action newReloadAction = null; if (OnFinish != null) { OnFinish(); } else if (PlayerDataManager.AppJustStarted && !PlayerDataManager.BeenInAppBefore) { PlayerDataManager.AppJustStarted = false; PlayerDataManager.SelectedGameMode = GameMode.Adventure; TankGame.Running = true; newReloadAction = delegate { MenuController.HideMenu <MainMenu>(); //MenuController.ShowMenu<PrivacyPolicyPopup>(); }; } if (Time.time - startTime < 1f) { yield return(new WaitForSecondsRealtime(1f - (Time.time - startTime))); } Time.timeScale = 1f; StartCoroutine(AddProgress(1f)); while (loadingProgressImage.fillAmount < 0.99f) { yield return(null); } IsLoading = false; if (newReloadAction != null) { ReloadGame(delegate { newReloadAction(); }); } else { StartCoroutine(FadeOut()); } }