/// <summary> /// Coroutine that kills the player, stops the camera, resets the points. /// </summary> /// <returns>The player co.</returns> protected virtual IEnumerator SoloModeRestart() { if ((PlayerPrefabs.Count() <= 0) && (SceneCharacters.Count <= 0)) { yield break; } // if we've setup our game manager to use lives (meaning our max lives is more than zero) if (GameManager.Instance.MaximumLives > 0) { // we lose a life GameManager.Instance.LoseLife(); // if we're out of lives, we check if we have an exit scene, and move there if (GameManager.Instance.CurrentLives <= 0) { TopDownEngineEvent.Trigger(TopDownEngineEventTypes.GameOver, null); if ((GameManager.Instance.GameOverScene != null) && (GameManager.Instance.GameOverScene != "")) { LoadingSceneManager.LoadScene(GameManager.Instance.GameOverScene); } } } MMCameraEvent.Trigger(MMCameraEventTypes.StopFollowing); MMFadeInEvent.Trigger(OutroFadeDuration, FadeCurve, FaderID, true, Players[0].transform.position); yield return(new WaitForSeconds(OutroFadeDuration)); yield return(new WaitForSeconds(RespawnDelay)); GUIManager.Instance.SetPauseScreen(false); GUIManager.Instance.SetDeathScreen(false); MMFadeOutEvent.Trigger(OutroFadeDuration, FadeCurve, FaderID, true, Players[0].transform.position); MMCameraEvent.Trigger(MMCameraEventTypes.StartFollowing); if (CurrentCheckpoint == null) { CurrentCheckpoint = InitialSpawnPoint; } if (Players[0] == null) { InstantiatePlayableCharacters(); } if (CurrentCheckpoint != null) { CurrentCheckpoint.SpawnPlayer(Players[0]); } _started = DateTime.UtcNow; // we send a new points event for the GameManager to catch (and other classes that may listen to it too) TopDownEnginePointEvent.Trigger(PointsMethods.Set, 0); TopDownEngineEvent.Trigger(TopDownEngineEventTypes.RespawnComplete, Players[0]); yield break; }
/// <summary> /// When the player respawns, we reinstate this agent. /// </summary> /// <param name="checkpoint">Checkpoint.</param> /// <param name="player">Player.</param> public virtual void OnPlayerRespawn(CheckPoint checkpoint, Character player) { if (RepositionToInitOnPlayerRespawn) { this.transform.position = _initialPosition; } if (RespawnOnPlayerRespawn) { if (GetComponent <Health>() != null) { GetComponent <Health>().Revive(); } Revive(); } }
/// <summary> /// When the player respawns, we reinstate this agent. /// </summary> /// <param name="checkpoint">Checkpoint.</param> /// <param name="player">Player.</param> public virtual void OnPlayerRespawn(CheckPoint checkpoint, Character player) { if (RepositionToInitOnPlayerRespawn) { this.transform.position = _initialPosition; } if (RespawnOnPlayerRespawn) { if (_health != null) { _health.Revive(); } Revive(); } AutoRespawnRemainingAmount = AutoRespawnAmount; }
/// <summary> /// Sets the current checkpoint with the one set in parameter. This checkpoint will be saved and used should the player die. /// </summary> /// <param name="newCheckPoint"></param> public virtual void SetCurrentCheckpoint(CheckPoint newCheckPoint) { if (newCheckPoint.ForceAssignation) { CurrentCheckpoint = newCheckPoint; return; } if (CurrentCheckpoint == null) { CurrentCheckpoint = newCheckPoint; return; } if (newCheckPoint.CheckPointOrder >= CurrentCheckpoint.CheckPointOrder) { CurrentCheckpoint = newCheckPoint; } }