init: version 1

This commit is contained in:
Job
2025-07-17 17:16:02 +02:00
commit a76c0f6445
519 changed files with 202925 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
/// <summary>
/// HelpTextManager manages the display of help text messages in the UI.
/// </summary>
[RequireComponent(typeof(TextMeshProUGUI))]
public class HelpTextManager : MonoBehaviour
{
public static HelpTextManager Instance => _instance;
private static HelpTextManager _instance;
[Header("Display Settings")]
public float displayTime = 5f;
public float fadeDuration = .5f;
private Queue<string> _helpMessages;
private TextMeshProUGUI _textMesh;
private Coroutine _currentCoroutine;
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
return;
}
_instance = this;
_textMesh = GetComponent<TextMeshProUGUI>();
}
public void DisplayHelpText(string[] text)
{
_helpMessages = new Queue<string>(text);
if (_currentCoroutine != null) StopCoroutine(_currentCoroutine);
_currentCoroutine = StartCoroutine(CycleMessages());
}
private IEnumerator CycleMessages()
{
while (_helpMessages.Count > 0)
{
_textMesh.text = _helpMessages.Dequeue();
_textMesh.alpha = 1f;
yield return new WaitForSeconds(displayTime);
}
yield return StartCoroutine(FadeOut());
}
private IEnumerator FadeOut()
{
float elapsed = 0f;
float startAlpha = _textMesh.alpha;
while (elapsed < fadeDuration)
{
elapsed += Time.deltaTime;
_textMesh.alpha = Mathf.Lerp(startAlpha, 0f, elapsed / fadeDuration);
yield return null;
}
_textMesh.alpha = 0f;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 2c45e148781e014e08d920c1a600c188

View File

@@ -0,0 +1,26 @@
using UnityEngine;
/// <summary>
/// HelpTextTriggerController is responsible for displaying
/// help text when the player enters a trigger area.
/// </summary>
public class HelpTextTriggerController : MonoBehaviour
{
[Header("Configuration")]
public string[] helpText;
public float cooldown = 60f;
private float _lastTriggerTime = -Mathf.Infinity;
private void OnTriggerEnter2D(Collider2D other)
{
if (other.CompareTag("Player"))
{
if (Time.time - _lastTriggerTime >= cooldown)
{
HelpTextManager.Instance.DisplayHelpText(helpText);
_lastTriggerTime = Time.time;
}
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: c0599bb0eda8a856985a30c4edbc7066

View File

@@ -0,0 +1,17 @@
using TMPro;
using UnityEngine;
/// <summary>
/// LevelIndicatorController updates the UI text to show the current level.
/// </summary>
[RequireComponent(typeof(TextMeshProUGUI))]
public class LevelIndicatorController : MonoBehaviour
{
private TextMeshProUGUI _textMeshPro;
private void Start()
{
_textMeshPro = GetComponent<TextMeshProUGUI>();
_textMeshPro.text = $"Level {TransitionManager.Instance.currentLevel}";
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: e5dece53d536883c18045c47c425f751

View File

@@ -0,0 +1,42 @@
using UnityEngine;
using UnityEngine.UI;
/// <summary>
/// MapIndicatorController updates the UI to show the current map.
/// </summary>
[RequireComponent(typeof(Image))]
public class MapIndicatorController : MonoBehaviour
{
[Header("Configuration")]
public Color[] colors =
{
new(34f / 255, 139f / 255, 230f / 255),
new(250f / 255, 82f / 255, 82f / 255),
new(64f / 255, 192f / 255, 87f / 255)
};
private Image _image;
private void Start()
{
_image = GetComponent<Image>();
_image.color = colors[GameManager.Instance.currentMapIdx];
}
private void OnEnable()
{
GameManager manager = GameManager.Instance;
manager.onMapSwitch.AddListener(OnMapSwitch);
}
private void OnDisable()
{
GameManager manager = GameManager.Instance;
manager.onMapSwitch.RemoveListener(OnMapSwitch);
}
private void OnMapSwitch(int idx, Vector3 o)
{
_image.color = colors[idx];
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6117a95bb22347c798d964d09bd4037c
timeCreated: 1751876872