46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
namespace Beyond
|
|
{
|
|
[CreateAssetMenu(menuName = "Magic/Spells/Spawn At Player Spell")]
|
|
public class SpawnAtPlayerSpell : SpellDefinition
|
|
{
|
|
public GameObject effectPrefab;
|
|
public float duration = 3f;
|
|
public float delay = 0.0f;
|
|
public bool attachToPlayer = true;
|
|
|
|
[Header("Trinket Special Interactions")]
|
|
public bool isShieldSpell; // Flag to apply Calmness
|
|
|
|
public override void Cast(MagicAttacks caster, Transform target)
|
|
{
|
|
caster.StartCoroutine(SpawnRoutine(caster));
|
|
}
|
|
|
|
private IEnumerator SpawnRoutine(MagicAttacks caster)
|
|
{
|
|
yield return new WaitForSeconds(delay);
|
|
|
|
GameObject instance;
|
|
|
|
if (attachToPlayer)
|
|
instance = Instantiate(effectPrefab, caster.transform);
|
|
else
|
|
instance = Instantiate(effectPrefab, caster.transform.position, caster.transform.rotation);
|
|
|
|
// Apply specific Trinket logic (Strategy pattern allows custom overrides too)
|
|
float finalDuration = duration;
|
|
if (isShieldSpell && Player.Instance.CurrentTrinketStats.effectCalmness)
|
|
{
|
|
finalDuration *= 1.5f;
|
|
}
|
|
|
|
caster.ApplyDamageModifiers(instance);
|
|
|
|
yield return new WaitForSeconds(finalDuration);
|
|
Destroy(instance);
|
|
}
|
|
}
|
|
} |