add world map and fast travel

This commit is contained in:
2026-07-08 21:06:57 -05:00
parent b8d5a52148
commit 778653994d
10 changed files with 33576 additions and 940 deletions
@@ -13,6 +13,19 @@ private void Start()
playerController = GetComponent<PlayerController>();
}
/// <summary>
/// Triggers the fast travel coroutine
/// </summary>
public void FastTravel(Transform position, bool isPaused)
{
if (isPaused)
{
GameManager.Instance.PlayerController.TogglePause();
}
StartCoroutine(FastTravelCoroutine(position));
}
/// <summary>
/// Triggers the room entrance coroutine, only works if the character is not controllable (keeps from double transitioning)
/// </summary>
@@ -74,4 +87,41 @@ IEnumerator EnterRoomCoroutine(RoomDoor door)
playerController.SetCharacterControl(true);
}
/// <summary>
/// Handle teleportation and timing for fast travel
/// </summary>
IEnumerator FastTravelCoroutine(Transform location)
{
float fadeDuration = 0.2f; // how long to fade to/from black
float fadeTime = 0;
Color blackScreenColor = Color.black;
playerController.SetCharacterControl(false);
while (fadeTime < fadeDuration)
{
blackScreenColor.a = Mathf.Lerp(0, 1, fadeTime / fadeDuration);
GameManager.Instance.BlackScreen.color = blackScreenColor;
fadeTime += Time.deltaTime;
yield return null;
}
fadeTime = 0;
playerController.CharacterControllerSetPosition(location.position);
while (fadeTime < fadeDuration)
{
blackScreenColor.a = Mathf.Lerp(1, 0, fadeTime / fadeDuration);
GameManager.Instance.BlackScreen.color = blackScreenColor;
fadeTime += Time.deltaTime;
yield return null;
}
fadeTime = 0;
yield return new WaitForSeconds(0.2f);
playerController.SetCharacterControl(true);
}
}