59 lines
1.8 KiB
C#
59 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
// ============================================================================
|
|
// 6. USAGE EXAMPLES - How to Use in Your Existing Code
|
|
// ============================================================================
|
|
|
|
public class AbilityUsageExamples : MonoBehaviour
|
|
{
|
|
[Header("Your Existing Abilities")]
|
|
public BaseAbility fireballAbility;
|
|
public BaseAbility healingAbility;
|
|
|
|
// These can now be RuntimeAbilityInstances!
|
|
private RuntimeAbilityInstance runtimeFireball;
|
|
private RuntimeAbilityInstance runtimeHealing;
|
|
|
|
private void Start()
|
|
{
|
|
// Convert your existing abilities
|
|
runtimeFireball = fireballAbility.ToRuntime();
|
|
runtimeHealing = healingAbility.ToRuntime();
|
|
|
|
// Example: Add legendary item effect
|
|
AddLegendaryFireballEffect();
|
|
}
|
|
|
|
private void AddLegendaryFireballEffect()
|
|
{
|
|
// This is how you'd handle your legendary item!
|
|
var explosionBehavior = new ExplodeOnHitBehavior
|
|
{
|
|
explosionRadius = 5f,
|
|
explosionDamage = 50f
|
|
};
|
|
|
|
runtimeFireball.AddBehavior(explosionBehavior);
|
|
|
|
// Also add a damage boost
|
|
var damageBoost = AbilityModifier.CreateDamageBoost(1.5f, "Legendary Damage");
|
|
runtimeFireball.AddModifier(damageBoost);
|
|
}
|
|
|
|
// Your existing ability usage code works exactly the same!
|
|
public void CastFireball()
|
|
{
|
|
var user = GetComponent<Taggable>();
|
|
|
|
// This works exactly like your old BaseAbility.Execute()
|
|
runtimeFireball.Execute(user);
|
|
}
|
|
|
|
public void CastFireballAtTarget(Transform target)
|
|
{
|
|
var user = GetComponent<Taggable>();
|
|
runtimeFireball.Execute(user, target);
|
|
}
|
|
} |