using Core.Health; using Core.Utilities; using System.Collections; using System.Collections.Generic; using TowerDefense.Agents; using UnityEngine; public class AgentRegenEffect : AgentEffect { protected GameObject m_RegenFx; /// /// Initializes the slower with the parameters configured in the SlowAffector /// /// Normalized float that represents the % slowdown applied to the agent /// The instantiated object to visualize the slow effect /// /// public void Initialize( GameObject slowfxPrefab = null, Vector3 position = default(Vector3), float scale = 1) { LazyLoad(); if (m_RegenFx == null && slowfxPrefab != null) { m_RegenFx = Poolable.TryGetPoolable(slowfxPrefab); m_RegenFx.transform.parent = transform; m_RegenFx.transform.localPosition = position; m_RegenFx.transform.localScale *= scale; } m_Agent.removed += OnRemoved; } /// /// Agent has died, remove affect /// void OnRemoved( DamageableBehaviour targetable) { m_Agent.removed -= OnRemoved; ResetAgent(); } void ResetAgent() { if ( m_RegenFx != null) { Poolable.TryPool(m_RegenFx); m_RegenFx.transform.localScale = Vector3.one; m_RegenFx = null; } Destroy(this); } }