Adding the feature to sell towers with VFX and audio included
This commit is contained in:
parent
1794f65b19
commit
0b4cde4590
16 changed files with 5394 additions and 13 deletions
|
|
@ -21,8 +21,10 @@ namespace TD.Gameplay
|
|||
/// and stores the tile waypoint list.</item>
|
||||
/// <item>Each frame: moves toward the world center of <c>remainingPath[0]</c>.
|
||||
/// When within snap distance, pops the waypoint and checks for zone transitions.</item>
|
||||
/// <item>When <see cref="PathfindingService.OnPathsInvalidated"/> fires (tower placed /
|
||||
/// sold), <see cref="RecomputePath"/> reruns A* from the current tile.</item>
|
||||
/// <item>When the maze changes (tower placed / sold), <see cref="PathfindingService"/>'s
|
||||
/// budgeted scheduler calls <see cref="RecomputePath"/> (registered via
|
||||
/// <see cref="PathfindingService.RegisterMover"/>), rerunning A* from the current
|
||||
/// tile — spread across frames so a full wave never spikes.</item>
|
||||
/// <item>When <c>remainingPath</c> is empty after a pop, the enemy has reached the
|
||||
/// goal — <see cref="OnReachedGoal"/> fires and the enemy is despawned.</item>
|
||||
/// </list>
|
||||
|
|
@ -168,15 +170,18 @@ namespace TD.Gameplay
|
|||
|
||||
// Recompute when a tower is placed or sold — grounded enemies only.
|
||||
// Flyers path on the static baked grid, so tower changes can never affect
|
||||
// their route; subscribing would just trigger needless recomputes.
|
||||
// their route; registering would just trigger needless recomputes.
|
||||
// Registration (not a direct event subscription) lets PathfindingService
|
||||
// spread the recomputes across frames under a per-frame budget, so a maze
|
||||
// change with a full wave present never spikes a single frame.
|
||||
if (!isFlying && PathfindingService.Instance != null)
|
||||
PathfindingService.Instance.OnPathsInvalidated += RecomputePath;
|
||||
PathfindingService.Instance.RegisterMover(this);
|
||||
}
|
||||
|
||||
public override void OnNetworkDespawn()
|
||||
{
|
||||
if (PathfindingService.Instance != null)
|
||||
PathfindingService.Instance.OnPathsInvalidated -= RecomputePath;
|
||||
PathfindingService.Instance.UnregisterMover(this);
|
||||
}
|
||||
|
||||
// ----- Server update --------------------------------------------------
|
||||
|
|
@ -274,8 +279,9 @@ namespace TD.Gameplay
|
|||
|
||||
// ----- Path invalidation ----------------------------------------------
|
||||
|
||||
// Called on server when LevelLoader.OnWalkabilityChanged fires (tower placed/sold).
|
||||
private void RecomputePath()
|
||||
// Called by PathfindingService's budgeted scheduler after a walkability change
|
||||
// (tower placed/sold). Public so the scheduler can drive it across frames.
|
||||
public void RecomputePath()
|
||||
{
|
||||
if (!IsServer) return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue