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
+32 -17
View File
@@ -43,23 +43,7 @@ void Update()
// TODO: Move input detection somewhere else
if (Input.GetKeyDown(KeyCode.Escape))
{
if (!paused)
{
Cursor.lockState = CursorLockMode.None;
Time.timeScale = 0;
canUseTools = false;
hasControl = false;
GameManager.Instance.MenuController.ShowScreen("Pause");
}
else
{
Time.timeScale = 1;
canUseTools = true;
hasControl = true;
GameManager.Instance.MenuController.HideAllScreens();
}
paused = !paused;
TogglePause();
}
if (hasControl)
@@ -86,6 +70,27 @@ void Update()
DoMovement();
}
public void TogglePause()
{
if (!paused)
{
Cursor.lockState = CursorLockMode.None;
Time.timeScale = 0;
canUseTools = false;
hasControl = false;
GameManager.Instance.MenuController.ShowScreen("Pause");
}
else
{
Time.timeScale = 1;
canUseTools = true;
hasControl = true;
GameManager.Instance.MenuController.HideAllScreens();
}
paused = !paused;
}
#region Movement Calculation/Input Processing
/// <summary>
/// If player presses space, jump
@@ -384,6 +389,16 @@ public void CharacterControllerMove(Vector3 movement)
characterController.Move(movement);
}
/// <summary>
/// Set the character controller's position
/// </summary>
public void CharacterControllerSetPosition(Vector3 pos)
{
characterController.enabled = false;
transform.position = pos;
characterController.enabled = true;
}
/// <summary>
/// Auto-walk the character in the specified direction. Uses character's walk
/// speed and camera rotation (per-frame)
@@ -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);
}
}
+18 -4
View File
@@ -15,7 +15,11 @@ public class Talkable : Interactable
public void Start()
{
voice = GetComponent<DialogueVoice>();
talkIndicator.SetActive(false);
if (talkIndicator != null)
{
talkIndicator.SetActive(false);
}
}
void DetermineDialogue()
@@ -90,17 +94,27 @@ public override void Interact()
else
GameManager.Instance.DialogueManager.DisplayNextSentence();
talkIndicator.SetActive(false);
if (talkIndicator != null)
{
talkIndicator.SetActive(false);
}
}
public override void MoveInsideRange()
{
talkIndicator.SetActive(true);
if (talkIndicator != null)
{
talkIndicator.SetActive(true);
}
}
public override void MoveOutsideRange()
{
GameManager.Instance.DialogueManager.EndDialogue();
talkIndicator.SetActive(false);
if (talkIndicator != null)
{
talkIndicator.SetActive(false);
}
}
}