Sunteți pe pagina 1din 3

using UnityEngine;

using System.Collections;
using System.Collections.Generic;
/// <summary>
/// This holds and manages a list of effects. Usually attached to a unit. WE mig
ht want to diversify into sub lists to improve performance.
/// </summary>
public class EffectHolder : MonoBehaviour {
public bool isIgnoreAllEffectsOnUnit = false; //Used as true on objects
// public BaseObject EffectHolderSource;
public List<EffectBasic> _effects;// { get; set; }

//Sub effect holders

//List of Modifier effects
//List of Additive effects
//List of Armour?
//list of force set?
public List<EffectBasic> effects
{
get {
if (_effects == null)
_effects = new List<EffectBasic>();
return _effects;
}
set { this._effects = value; }
}
public int Count
{
get {
if (_effects == null)
return 0;
else
return _effects.Count;
}
}
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void Add(EffectBasic effect, bool overrideTimeEffects = true)
{
if (isIgnoreAllEffectsOnUnit)
return;
else
{
if (this._effects == null) this._effects = new List<EffectBasic>();

//if(effect.durationType == DurationType.OVER_TIME && overrideTimeEf
fects)
//{
// for (int i = 0; i < _effects.Count; i++)
// {
// if(_effects[i] == effect){
// _effects[i].remainingDuration += effect.remainingDurat
ion;
// return;
// }
// }
//}
//else
//{
this._effects.Add(effect);
//}
}
}
public void Add(EffectHolder effectHolder)
{
if (isIgnoreAllEffectsOnUnit)
return;
else
{
if (this._effects == null) this._effects = new List<EffectBasic>();
this._effects.AddRange(effectHolder.effects);
}
}
public void Add(List<EffectBasic> effects)
{
if (isIgnoreAllEffectsOnUnit)
return;
else
{
if (this._effects == null) this._effects = new List<EffectBasic>();
this._effects.AddRange(effects);
}
}
public void Remove(EffectBasic effect)
{
if (isIgnoreAllEffectsOnUnit)
return;
else
{
if (_effects != null) _effects.Remove(effect);
}
}
public EffectBasic this[int i]
{
get { return _effects[i]; }
set { _effects[i] = (EffectBasic)value; }
}
public bool isASimiliarTimeEffect(List<EffectBasic> effects, EffectBasic inp
utEffect)
{
//if(in)
if (inputEffect.durationType == DurationType.OVER_TIME)
{
return true;
}
else
return false;
}
//public List<Effect> this{
// return effects;
//}
}

S-ar putea să vă placă și