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;
|
|
/// <summary>
|
/// Initializes the slower with the parameters configured in the SlowAffector
|
/// </summary>
|
/// <param name="slowFactor">Normalized float that represents the % slowdown applied to the agent</param>
|
/// <param name="slowfxPrefab">The instantiated object to visualize the slow effect</param>
|
/// <param name="position"></param>
|
/// <param name="scale"></param>
|
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;
|
}
|
|
/// <summary>
|
/// Agent has died, remove affect
|
/// </summary>
|
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);
|
}
|
}
|