Adding Text Mesh Pro, new enemies, new enemy waves, new HUD functionality, New animators, a retry function, and floating text for gold earned and lives lost.

This commit is contained in:
Matt F 2026-05-13 17:39:16 -07:00
parent 3287e8ea43
commit f6cc6a7102
110 changed files with 62003 additions and 251 deletions

View file

@ -60,6 +60,7 @@ namespace TD.Gameplay
private List<Vector2Int> remainingPath = new List<Vector2Int>();
private PlayerSlot currentZone = PlayerSlot.None;
private EnemyStatus status;
private bool hasReachedGoal;
// ----- Events ---------------------------------------------------------
@ -139,12 +140,20 @@ namespace TD.Gameplay
float effectiveSpeed = moveSpeed * (status != null ? status.GetSpeedMultiplier() : 1f);
Vector3 targetWorld = GridCoordinates.GridToWorld(remainingPath[0]);
Vector3 toTarget = targetWorld - transform.position;
// XZ-only delta. Some enemy prefabs (e.g. the skeleton) have their root
// sitting above Y=0; if we measured 3D distance, the Y offset would push
// it permanently above the snap threshold and waypoints would never
// complete. Tile arrival is a horizontal-plane concept anyway.
Vector3 toTarget = targetWorld - transform.position;
toTarget.y = 0f;
if (toTarget.sqrMagnitude <= WaypointSnapSq)
{
// Snap to the tile center then handle the waypoint transition.
transform.position = targetWorld;
// Snap XZ to the tile center. Preserve Y so we don't drag a visual
// pivot down through the plane.
transform.position = new Vector3(
targetWorld.x, transform.position.y, targetWorld.z);
AdvanceWaypoint();
}
else
@ -187,11 +196,16 @@ namespace TD.Gameplay
private void HandleGoalReached()
{
if (hasReachedGoal) return; // belt-and-suspenders: never fire twice
hasReachedGoal = true;
var health = GetComponent<EnemyHealth>();
int livesCost = health != null ? health.LivesCost : 1;
OnReachedGoal?.Invoke(this, livesCost);
NetworkObject.Despawn();
if (NetworkObject != null && NetworkObject.IsSpawned)
NetworkObject.Despawn();
}
// ----- Path invalidation ----------------------------------------------