Spell System – Ability Cast with Mana Cost (Infravision)
A downloadable tool

Overview
Showcase a reusable spell framework that validates and consumes mana on cast, then runs a timed gameplay effect with clean VFX lifecycle handling.
Key points
-
Base
Spellsclass provides shared validation and mana cost (CanCast()+TryCast()) -
Spell-specific behavior implemented via
OnCast()in derived classes -
Infravision uses a timed coroutine: enable VFX → wait(duration) → disable VFX
-
UI updates through a simple mana bar binding (
magicNow / maximumMagic)
Architecture Overview
Architecture Overview
Character (base)
├─ magicNow / maximumMagic
└─ (UI reads current mana)
Spells (base)
├─ duration / magicCost
├─ CanCast() → validates mana
└─ TryCast() → consumes mana + calls OnCast()
InfravisionSpell : PlayerSpells
├─ PlayCastVFX()
└─ InfravisionRoutine() → enable VFX → wait(duration) → disable VFX
ManaBar (UI)
└─ fillAmount = magicNow / maximumMagic
Execution Flow
VALIDATE → CONSUME → CAST VFX → ENABLE → WAIT → DISABLE
------------------------------------------------------------
Code Highlights (full source)
-
Spells framework:
Spells.cs(GitHub) -
Infravision implementation:
InfravisionSpell.cs(GitHub) -
UI binding:
ManaBar.cs(GitHub) -
Player spell wrapper / ownership rules:
PlayerSpells/Elf.cs(if applicable)
A) Base Spell Contract (Spells.cs)

View full implementation → Spells.cs
https://github.com/VelardLugossian/gameplay-systems-portfolio/blob/main/src/Spells.cs
B) Spell-specific behavior (InfravisionSpell.cs)

View full implementation → InfravisionSpell.cs
https://github.com/VelardLugossian/gameplay-systems-portfolio/blob/main/src/InfravisionSpell.cs
C) UI binding (ManaBar.cs)

View full implementation → ManaBar.cs
https://github.com/VelardLugossian/gameplay-systems-portfolio/blob/main/src/ManaBar.cs
* * *
Go back →Gameplay Systems Portfolio – Velard (Main)
https://velard.itch.io/portfolio-gameplay