This repository demonstrates the implementation of the Visitor design pattern in Unity. The Visitor pattern allows you to add further operations to objects without modifying them. In this example, we have a hero character that can receive power-ups by entering a light trigger or picking up items.
- ComponentExtensions.cs: Provides an extension method for adding or getting components.
- HealthComponent.cs: Represents the health component of the hero.
- Hero.cs: Represents the hero character with visitable components.
- IVisitable.cs: Interface for visitable components.
- IVisitor.cs: Interface for visitors.
- LightTrigger.cs: Handles the hero entering and exiting the light.
- ManaComponent.cs: Represents the mana component of the hero.
- PickUp.cs: Handles the triggering of power-ups.
- PowerUp.cs: ScriptableObject that defines the power-up behavior.