FireEffectMover
is responsible for animating the fire effect as it moves along a path of fuse points. It manages traversal using interpolation between waypoints, handles environmental interactions such as wind and speed modifiers, and visually communicates the burning process to the associated fuse object. The script also manages fade-out and destruction when the path ends or is interrupted.
This component serves as the core driver of the ignition mechanic in the game, coordinating motion, visual updates, and termination logic.
FireEffectMover
Namespace: global
Inherits from: MonoBehaviour
private float burnSpeed = 5f
The default travel speed of the fire effect along the fuse path.
private List<Vector2> waypoints
Stores the series of points the fire will follow.
private int currentPointIndex
The current index in the waypoints list that the fire is moving toward.
private float speedModifier = 1f
A multiplier applied to the base speed (used by power-ups or slow zones).
private bool isSpeedModified = false
Tracks whether a temporary speed modifier is currently active.
private Vector2 windForce = Vector2.zero
Vector used to apply directional wind forces during travel.
private fuse_draw fuseReference
Reference to the fuse object being traversed, used to update burn visuals.
private Coroutine burnCoroutine
Stores a reference to the currently running burn coroutine, allowing it to be stopped and restarted safely.
void SetWaypoints(List<Vector2> points, int startIndex = 0, fuse_draw fuse = null)
Initializes the fire path and begins the burning process from a specific point.
points
: The list of world-space points the fire should follow.startIndex
: Optional index to begin traversal (defaults to 0
).fuse
: Optional reference to the originating fuse line for visual updates.void
void ApplySpeedModifier(float modifier, float duration)
Temporarily alters the fire’s burn speed.
modifier
: A float multiplier (e.g., 0.5f
to slow down).duration
: Duration in seconds for which the speed change remains active.void
void ApplyWindForce(Vector2 force)
Applies an additive directional wind force to influence movement.
force
: A Vector2
representing the wind’s direction and strength.void
IEnumerator FadeOutAndDestroy(float time = 0.5f, bool isWin = false)
Fades out the fire effect visually and removes it from the scene. Optionally triggers a win or fail state via GameOverManager
.
time
: Duration of the fade (default: 0.5f
seconds).isWin
: If true
, triggers a win; otherwise, triggers a loss.IEnumerator
IEnumerator BurnFuse()
Core routine that animates the fire between waypoints, marks fuse points as burned, and checks for out-of-bounds or endpoint conditions.
IEnumerator ModifySpeed(float modifier, float duration)
Temporarily overrides burnSpeed
using speedModifier
and resets it after a delay.
bool IsOutOfBounds()
Returns true
if the fire has no path data (used as a fallback to trigger fade-out).
LineRendererExtensions.SetPointColor(int index, Color color)
An extension method to highlight a specific point in a LineRenderer
.
index
: Index of the point to recolor.color
: Target color to assign to the selected point.void
lineRenderer.SetPointColor(5, Color.red);
fireEffectMover.SetWaypoints(fuse.GetPoints(), 0, fuse);
fireEffectMover.ApplySpeedModifier(0.5f, 3f);
fireEffectMover.ApplyWindForce(new Vector2(1f, 0f));
SetWaypoints
to avoid premature termination.fuseReference.MarkPointBurned()
to synchronize visual feedback.GameOverManager
is present in the scene for proper end-state handling.windForce *= 0.95f
) for smooth transitions.