Lumen's Edge - Pattern System Feature
View on GitHubThis page explains a key gameplay feature: the Pattern System. It introduces timed hazards with dynamic lights and a countdown mechanic that players must interact with to survive.
Detecting Player Collisions - PatternPart.cs
Each bullet pattern is made of multiple parts. The PatternPart class detects when the player enters or exits a hazard and updates the collision state. This is essential for determining whether damage should be applied.
private void OnTriggerEnter2D(Collider2D other)
{
if(!collidingWithPlayer && other.gameObject.CompareTag("Player"))
{
collidingWithPlayer = true;
}
}
private void OnTriggerExit2D(Collider2D other)
{
if (collidingWithPlayer && other.gameObject.CompareTag("Player"))
{
collidingWithPlayer = false;
}
}
Countdown & Damage Logic - PatternScript.cs
The PatternScript handles timing and damage. Each pattern counts down, reduces light radius dynamically, and applies damage or affects boss health. Players need to dodge hazards and interact with safe zones to survive.
countTimer += Time.deltaTime;
foreach (PatternPart part in patternParts)
{
Light2D partLight = part.transform.GetChild(0).GetComponent<Light2D>();
lightFloat = Mathf.Lerp(partLight.pointLightInnerRadius, 0, countTimer / duration);
partLight.pointLightInnerRadius = lightFloat;
}
if (countTimer >= damageTime)
{
if (shouldTakeDamage)
{
playerHealth.playerHealth--;
hit.currentPlayerState = PlayerHit.PlayerState.Invincible;
hit.playSoundEffect();
}
Destroy(gameObject);
}
Feature Workflow
1. Patterns are spawned dynamically using PatternSpawner.
2. Each PatternPart detects player collision.
3. Lights decrease in intensity over time to signal pattern activation.
4. After the countdown, the pattern applies damage if the player is still in range, or affects boss health if the player successfully avoids it.
This system creates a reactive, visually clear challenge for the player, emphasizing timing, positioning, and risk management.