public void ReturnToGame() // Will return to the game by chekcing if player is alive or not { if (PlayerTankmanager.GetPlayer() && PlayerTankmanager.GetPlayer().GetComponent <RTCTankController>().CheckAlive()) // checking if player is alive { if (!gameWon) { Cursor.visible = false; Cursor.lockState = CursorLockMode.Locked; } else { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } } else { Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } // Returinng to the game by disabling the Pause Menu's components GetComponent <Canvas>().enabled = false; EventManager.TriggerEvent("GameUnPaused"); // Triggering the event that will resume the game loadingOverlay.SetActive(false); Time.timeScale = 1; winScreen.GetComponent <Canvas>().enabled = false; gameObject.GetComponent <Canvas>().enabled = false; if (GameObject.Find("AudioSource")) { GameObject.Find("AudioSource").GetComponent <AudioSource>().volume = 1f; // changing the volume } uiComponents.SetActive(true); }
// Coroutine that loads up the PlayerTankManager, as it necessary for the player to interact IEnumerator LoadUpPTM(Action OnExisting) { PlayerTankManager = CreateSubsystem <PlayerTankmanager>() as PlayerTankmanager; yield return(new WaitWhile(() => PlayerTankManager != null)); OnExisting.SafeInvoke(); StartCoroutine(LoadUpUnlock(OnExisting)); }
public override void Initialize(Action <SystemBase> OnInitialized = null) { if (Inst == null) { Inst = this; } if (IsInitialized) { Destroy(gameObject); } DontDestroyOnLoad(this.gameObject); LoadPlayerPrefs(); DinoEffectsContainer firstItem; firstItem = new DinoEffectsContainer(); m_DinoEffects.Insert(0, firstItem); if (m_loadout.Count == 0 || m_loadout[0] == null) // Add bullets to weapon { m_loadout.Clear(); m_loadout.Add(Resources.Load("RTCBullet") as GameObject); } // Auto populate arcade bool in case we are loading into level direct Level currentMatchingLevel = PlayerTankmanager.GetLevelFromName(SceneManager.GetActiveScene().name); if (currentMatchingLevel != null) { isArcade = currentMatchingLevel.isArcade; } else { isArcade = false; } // overriding for the specific build m_loadout.CleanList(); IsInitialized = true; if (OnInitialized != null) { OnInitialized.Invoke(this); } }
public void RestartMission() // Will restart the current mission/level name { bool isArcade = PlayerTankmanager.GetLevelFromName(SceneManager.GetActiveScene().name).isArcade; if (isArcade) // If current level is active, it will restart it { ArcadeController.instance.towerHealth.gameObject.SetActive(false); SceneManager.LoadScene(SceneManager.GetActiveScene().name); } else { APP.PlayerTankManager.AddCheckPointForLevel(SceneManager.GetActiveScene().name, 0); restartMissionPrompt.SetActive(false); loadingOverlay.SetActive(true); SceneManager.LoadScene("LoadingScene"); } }
IEnumerator ObjectiveComplete() // Coroutine to check if the objective has been complete and based on that assign a winning team, switching of the UI elements { EventManager.TriggerEvent("DeathCam"); PlayerTankmanager.GetPlayer().GetComponent <RTCTankController>().gasInput = 0; PlayerTankmanager.GetPlayer().GetComponent <RTCTankController>().steerInput = 0; // Chekcing if the current game mode is arcade and the based on that get all the details and info required for this mode, from scores to all the stats if (APP.PlayerTankManager.isArcade) { Cursor.lockState = CursorLockMode.None; Cursor.visible = false; ArcadeController.instance.arcadeRetryScreen.GetComponent <Canvas>().enabled = true; ArcadeController.instance.yesButton.gameObject.SetActive(false); ArcadeController.instance.noButton.gameObject.SetActive(false); ArcadeController.instance.info.enabled = false; ArcadeController.instance._Overlay.enabled = false; ArcadeController.instance.reviveText.enabled = false; statsPanel.transform.GetChild(2).gameObject.SetActive(false); win.transform.GetChild(6).gameObject.SetActive(false); win.GetComponent <Canvas>().enabled = true; ArcadeController.instance.towerHealth.gameObject.SetActive(false); if (GameObject.Find("ArcadeLives")) { GameObject.Find("ArcadeLives").SetActive(false); } if (GameObject.Find("ScoreName")) { GameObject.Find("ScoreName").SetActive(false); } ArcadeController.instance.waveText.SetActive(false); win.transform.GetChild(4).GetComponent <Text>().text = "Round Complete"; statsPanel.SetActive(true); statsPanel.GetComponent <StatsDisplayController>().PopulateStats(); hasWon = true; if (APP.PlayerTankManager._ArcadeMode == arcadeMode.SearchAndDestroy) { foreach (GameObject tank in EnemyWaveController.instance.spawnedTanks) { tank.GetComponent <RTCTankController>().targetToAttack = null; tank.GetComponent <RTCTankController>().aiState = aiStates.idle; } ArcadeController.instance.labels.SetActive(false); ArcadeController.instance.playerPanel_RED.SetActive(false); ArcadeController.instance.playerPanel_BLUE.SetActive(false); ArcadeController.instance.UpdateRounds(); if (APP.PlayerTankManager.REDTeamTotalScoresVal == 2) { win.transform.GetChild(4).GetComponent <Text>().text = "Red Team Wins"; ArcadeController.instance.arcadeButton.gameObject.SetActive(true); ArcadeController.instance.retryButton.gameObject.SetActive(true); } } } else { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; win.GetComponent <Canvas>().enabled = true; LevelEndAwardController awardController = FindObjectOfType <LevelEndAwardController>(); if (awardController != null) { if (awardController.awardTankAtEndOfLevel) { statsPanel.SetActive(false); tankAwardBadge.SetActive(true); tankAwardBadge.GetComponent <TankAwardBadge>().SetBadgeImage(awardController.tankToAward); yield return(new WaitUntil(() => claimReward)); } } tankAwardBadge.SetActive(false); statsPanel.SetActive(true); statsPanel.GetComponent <StatsDisplayController>().PopulateStats(); } }
void SetLoadState(LoadStates loadState) { LoadState = loadState; switch (LoadState) { case LoadStates.Idle: break; case LoadStates.Starting: DEBUG.Log("Starting Game..."); SetLoadState(LoadStates.LoadingData); break; case LoadStates.LoadingData: // Fetch Google Sheet Data if (Application.internetReachability != NetworkReachability.NotReachable) { GameData.Reload(onCallLoaded: () => { DEBUG.Log("Data Loaded...", Warning_Types.Good); DataLoaded = true; SetLoadState(LoadStates.OpeningScene); }); } else { DEBUG.Log("Not Connected to the internet, GameData and multiplayer offline", Warning_Types.Error); DataLoaded = true; SetLoadState(LoadStates.OpeningScene); } break; case LoadStates.OpeningScene: DEBUG.Log(string.Format("Opening scene {0}...", SceneManager.GetActiveScene().name)); SceneManager.sceneLoaded += ReloadCurrentScene; SceneManager.LoadScene(SceneManager.GetActiveScene().name); break; case LoadStates.StartingSystems: SceneManager.sceneLoaded -= ReloadCurrentScene; DEBUG.Log("Scene Loaded...", Warning_Types.Log); CreateSubsystem <ObjectPool>(); PlayerTankManager = CreateSubsystem <PlayerTankmanager>() as PlayerTankmanager; CreateSubsystem <UnlockManager>(); CreateSubsystem <AudioManager>(); CreateSubsystem <EventManager>(); DEBUG.Log("Systems Started...", Warning_Types.Good); SetLoadState(LoadStates.Connecting); break; case LoadStates.Connecting: if (Application.internetReachability != NetworkReachability.NotReachable) { DEBUG.Log("Connecting...", Warning_Types.Log); PhotonNetwork.ConnectUsingSettings("v1"); } else { DEBUG.Log("Network not reachable...", Warning_Types.Warning); SetLoadState(LoadStates.LoadingPlayer); } break; case LoadStates.LoadingPlayer: StartLevelManager(); SetLoadState(LoadStates.Ready); break; case LoadStates.Ready: // App is ready, nothing further to do here DEBUG.Log("Ready", Warning_Types.Good); break; } }