Add game over text and death type to credits volume, but doesnt work

This commit is contained in:
Nick 2023-03-18 16:04:53 -04:00
parent 9080b45c14
commit bd61a87cf6
3 changed files with 74 additions and 14 deletions

View File

@ -1,5 +1,6 @@
using NewHorizons.Components.Volumes;
using NewHorizons.External.Modules;
using OWML.Utils;
using UnityEngine;
namespace NewHorizons.Builder.Volumes
@ -11,6 +12,8 @@ namespace NewHorizons.Builder.Volumes
var volume = VolumeBuilder.Make<LoadCreditsVolume>(planetGO, sector, info);
volume.creditsType = info.creditsType;
volume.gameOverText = info.gameOverText;
volume.deathType = EnumUtils.Parse(info.deathType.ToString(), DeathType.Default);
return volume;
}

View File

@ -1,4 +1,6 @@
using NewHorizons.External.Modules;
using NewHorizons.Handlers;
using System.Collections;
using UnityEngine;
namespace NewHorizons.Components.Volumes
@ -7,29 +9,74 @@ namespace NewHorizons.Components.Volumes
{
public VolumesModule.LoadCreditsVolumeInfo.CreditsType creditsType = VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast;
public string gameOverText;
public DeathType deathType = DeathType.Default;
private GameOverController _gameOverController;
private PlayerCameraEffectController _playerCameraEffectController;
public void Start()
{
_gameOverController = GameObject.FindObjectOfType<GameOverController>();
_playerCameraEffectController = GameObject.FindObjectOfType<PlayerCameraEffectController>();
}
public override void OnTriggerVolumeEntry(GameObject hitObj)
{
if (hitObj.CompareTag("PlayerDetector") && enabled)
{
switch(creditsType)
{
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast:
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final:
LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo:
TimelineObliterationController.s_hasRealityEnded = true;
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
}
StartCoroutine(GameOver());
}
}
public override void OnTriggerVolumeExit(GameObject hitObj)
private IEnumerator GameOver()
{
OWInput.ChangeInputMode(InputMode.None);
ReticleController.Hide();
Locator.GetPromptManager().SetPromptsVisible(false);
Locator.GetPauseCommandListener().AddPauseCommandLock();
_playerCameraEffectController.OnPlayerDeath(deathType);
yield return new WaitForSeconds(_playerCameraEffectController._deathFadeLength);
if (!string.IsNullOrEmpty(gameOverText) && _gameOverController != null)
{
_gameOverController._deathText.text = TranslationHandler.GetTranslation(gameOverText, TranslationHandler.TextType.UI);
_gameOverController.SetupGameOverScreen(5f);
// We set this to true to stop it from loading the credits scene, so we can do it ourselves
_gameOverController._loading = true;
yield return new WaitUntil(ReadytoLoadCreditsScene);
LoadCreditsScene();
}
else
{
LoadCreditsScene();
}
}
private bool ReadytoLoadCreditsScene() => _gameOverController._fadedOutText && _gameOverController._textAnimator.IsComplete();
public override void OnTriggerVolumeExit(GameObject hitObj) { }
private void LoadCreditsScene()
{
switch (creditsType)
{
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Fast:
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Final:
LoadManager.LoadScene(OWScene.Credits_Final, LoadManager.FadeType.ToBlack);
break;
case VolumesModule.LoadCreditsVolumeInfo.CreditsType.Kazoo:
TimelineObliterationController.s_hasRealityEnded = true;
LoadManager.LoadScene(OWScene.Credits_Fast, LoadManager.FadeType.ToBlack);
break;
}
}
}
}

View File

@ -171,6 +171,16 @@ namespace NewHorizons.External.Modules
[DefaultValue("fast")]
public CreditsType creditsType = CreditsType.Fast;
/// <summary>
/// Text displayed in orange on game over. For localization, put translations under UI.
/// </summary>
public string gameOverText;
/// <summary>
/// The type of death the player will have if they enter this volume.
/// </summary>
[DefaultValue("default")] public DeathType deathType = DeathType.Default;
}
[JsonObject]