CustomEffect
Abstract Scriptable Object
Description
Abstract Methods
Example
using System.Collections;
using UnityEngine;
// Use StatusEffects.Custom namespace for organization.
namespace StatusEffects.Custom
{
// Setup scriptable object in create menu.
[CreateAssetMenu(fileName = "Poison Effect", menuName = "Custom Effects/Poison", order = 1)]
public class PoisonEffect : CustomEffect
{
// Unique value for this effect example
public float intervalSeconds = 1f;
public override IEnumerator Effect<T>(T monoBehaviour, StatusEffect statusEffect)
{
// Use your own character/entity class for this
Entity entity = monoBehaviour.GetComponent<Entity>();
for (; ; )
{
// Use your own TakeDamage() logic. This will
// occur every interval until the effect ends.
entity.TakeDamage(statusEffect.data.baseValue);
yield return new WaitForSeconds(intervalSeconds);
}
}
public override void EffectEnd<T>(T monoBehaviour, StatusEffect statusEffect) { }
}
}Last updated