magic powers refactor WIP
This commit is contained in:
46
Assets/Scripts/Characters/Skills/SpawnAtPlayerSpell.cs
Normal file
46
Assets/Scripts/Characters/Skills/SpawnAtPlayerSpell.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user