Working on quest functions and increased map

This commit is contained in:
2026-02-13 17:32:58 +00:00
parent a45873aee0
commit 047d4d8464
24 changed files with 10804 additions and 1043 deletions

View File

@@ -0,0 +1,134 @@
using UnityEngine;
using System.Collections;
/// <summary>
/// Utility class for common animation coroutines and animation helpers.
/// Provides reusable animation patterns used across multiple scripts.
/// </summary>
public static class AnimationUtilities
{
/// <summary>
/// Smoothly rotate an object from its current rotation to a target rotation
/// </summary>
public static Coroutine RotateTo(MonoBehaviour source, Transform target, Quaternion targetRotation, float duration)
{
return source.StartCoroutine(RotateToRoutine(target, targetRotation, duration));
}
private static IEnumerator RotateToRoutine(Transform target, Quaternion targetRotation, float duration)
{
if (duration <= 0) yield break;
float elapsedTime = 0f;
Quaternion startRotation = target.rotation;
while (elapsedTime < duration)
{
elapsedTime += Time.deltaTime;
float t = Mathf.Clamp01(elapsedTime / duration);
target.rotation = Quaternion.Slerp(startRotation, targetRotation, t);
yield return null;
}
target.rotation = targetRotation;
}
/// <summary>
/// Smoothly move an object from its current position to a target position
/// </summary>
public static Coroutine MoveTo(MonoBehaviour source, Transform target, Vector3 targetPosition, float duration)
{
return source.StartCoroutine(MoveToRoutine(target, targetPosition, duration));
}
private static IEnumerator MoveToRoutine(Transform target, Vector3 targetPosition, float duration)
{
if (duration <= 0) yield break;
float elapsedTime = 0f;
Vector3 startPosition = target.position;
while (elapsedTime < duration)
{
elapsedTime += Time.deltaTime;
float t = Mathf.Clamp01(elapsedTime / duration);
target.position = Vector3.Lerp(startPosition, targetPosition, t);
yield return null;
}
target.position = targetPosition;
}
/// <summary>
/// Smoothly rotate an object around a specific axis by a specified angle
/// </summary>
public static Coroutine RotateAround(MonoBehaviour source, Transform target, float targetAngle, Vector3 axis, float duration)
{
return source.StartCoroutine(RotateAroundRoutine(target, targetAngle, axis, duration));
}
private static IEnumerator RotateAroundRoutine(Transform target, float targetAngle, Vector3 axis, float duration)
{
if (duration <= 0) yield break;
float elapsedTime = 0f;
Vector3 eulerAngles = target.localEulerAngles;
float startAngle = 0;
if (axis == Vector3.right) startAngle = eulerAngles.x;
else if (axis == Vector3.up) startAngle = eulerAngles.y;
else if (axis == Vector3.forward) startAngle = eulerAngles.z;
while (elapsedTime < duration)
{
elapsedTime += Time.deltaTime;
float t = Mathf.Clamp01(elapsedTime / duration);
float currentAngle = Mathf.Lerp(startAngle, targetAngle, t);
eulerAngles = target.localEulerAngles;
if (axis == Vector3.right) eulerAngles.x = currentAngle;
else if (axis == Vector3.up) eulerAngles.y = currentAngle;
else if (axis == Vector3.forward) eulerAngles.z = currentAngle;
target.localEulerAngles = eulerAngles;
yield return null;
}
eulerAngles = target.localEulerAngles;
if (axis == Vector3.right) eulerAngles.x = targetAngle;
else if (axis == Vector3.up) eulerAngles.y = targetAngle;
else if (axis == Vector3.forward) eulerAngles.z = targetAngle;
target.localEulerAngles = eulerAngles;
}
/// <summary>
/// Fade in/out by modifying material color alpha
/// </summary>
public static Coroutine Fade(MonoBehaviour source, Renderer renderer, float targetAlpha, float duration)
{
return source.StartCoroutine(FadeRoutine(renderer, targetAlpha, duration));
}
private static IEnumerator FadeRoutine(Renderer renderer, float targetAlpha, float duration)
{
if (renderer == null || duration <= 0) yield break;
float elapsedTime = 0f;
Material material = renderer.material;
Color startColor = material.color;
while (elapsedTime < duration)
{
elapsedTime += Time.deltaTime;
float t = Mathf.Clamp01(elapsedTime / duration);
Color newColor = startColor;
newColor.a = Mathf.Lerp(startColor.a, targetAlpha, t);
material.color = newColor;
yield return null;
}
Color finalColor = startColor;
finalColor.a = targetAlpha;
material.color = finalColor;
}
}

View File

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

View File

@@ -0,0 +1,63 @@
using UnityEngine;
/// <summary>
/// Centralized debug logging manager for consistent logging across all systems.
/// Provides a global debug toggle and formatted log output.
/// </summary>
public class DebugManager : MonoBehaviour
{
public static DebugManager Instance { get; private set; }
[SerializeField]
private bool enableGlobalDebugLogs = true;
void Awake()
{
if (Instance != null && Instance != this)
{
Debug.LogWarning("Multiple DebugManager instances detected. Destroying duplicate.", gameObject);
Destroy(gameObject);
return;
}
Instance = this;
}
void OnDestroy()
{
if (Instance == this) Instance = null;
}
/// <summary>
/// Log a message if debug logging is enabled
/// </summary>
public static void Log(string category, string message, Object context = null)
{
if (Instance == null || !Instance.enableGlobalDebugLogs) return;
Debug.Log($"[{category}] {message}", context);
}
/// <summary>
/// Log a warning message
/// </summary>
public static void LogWarning(string category, string message, Object context = null)
{
Debug.LogWarning($"[{category}] {message}", context);
}
/// <summary>
/// Log an error message
/// </summary>
public static void LogError(string category, string message, Object context = null)
{
Debug.LogError($"[{category}] {message}", context);
}
/// <summary>
/// Set global debug logging state
/// </summary>
public static void SetDebugEnabled(bool enabled)
{
if (Instance != null)
Instance.enableGlobalDebugLogs = enabled;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 03b75d1f7b86ca241b28fa04bf7a3968

View File

@@ -0,0 +1,69 @@
using UnityEngine;
/// <summary>
/// Utility class for proximity and distance-based calculations.
/// Centralizes common distance checking logic used throughout the game.
/// </summary>
public static class ProximityUtility
{
/// <summary>
/// Check if two objects are within a specified distance
/// </summary>
public static bool IsWithinDistance(Vector3 from, Vector3 to, float distance)
{
return Vector3.Distance(from, to) <= distance;
}
/// <summary>
/// Check if two Transform objects are within a specified distance
/// </summary>
public static bool IsWithinDistance(Transform from, Transform to, float distance)
{
if (from == null || to == null) return false;
return IsWithinDistance(from.position, to.position, distance);
}
/// <summary>
/// Check if GameObject is within a specified distance
/// </summary>
public static bool IsWithinDistance(GameObject from, GameObject to, float distance)
{
if (from == null || to == null) return false;
return IsWithinDistance(from.transform.position, to.transform.position, distance);
}
/// <summary>
/// Get the distance between two positions
/// </summary>
public static float GetDistance(Vector3 from, Vector3 to)
{
return Vector3.Distance(from, to);
}
/// <summary>
/// Get the distance between two Transform objects
/// </summary>
public static float GetDistance(Transform from, Transform to)
{
if (from == null || to == null) return float.MaxValue;
return GetDistance(from.position, to.position);
}
/// <summary>
/// Get the distance between two GameObjects
/// </summary>
public static float GetDistance(GameObject from, GameObject to)
{
if (from == null || to == null) return float.MaxValue;
return GetDistance(from.transform.position, to.transform.position);
}
/// <summary>
/// Check if object is in range and handle both close and far cases
/// </summary>
public static bool CheckRange(Vector3 from, Vector3 to, float minDistance, float maxDistance, out float distance)
{
distance = GetDistance(from, to);
return distance >= minDistance && distance <= maxDistance;
}
}

View File

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