You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.6 KiB
92 lines
2.6 KiB
using System.IO;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class BuffManager : MonoBehaviour
|
|
{
|
|
GameObject debuffGameObject;
|
|
GameObject buffGameObject;
|
|
public List<Buff> buffs = new List<Buff>();
|
|
public List<Buff> debuffs = new List<Buff>();
|
|
public List<Buff> specialBuffs = new List<Buff>();
|
|
Character self;
|
|
private void Awake()
|
|
{
|
|
self = transform.parent.GetComponent<Character>();
|
|
buffGameObject = transform.Find("Buff").gameObject;
|
|
debuffGameObject = transform.Find("Debuff").gameObject;
|
|
}
|
|
public void AddBuff(Buff newBuff)
|
|
{
|
|
if(newBuff.amount > 0)
|
|
buffs.Add(newBuff);
|
|
else
|
|
debuffs.Add(newBuff);
|
|
newBuff.Apply(self);
|
|
if(debuffs != null && debuffs.Count != 0)
|
|
debuffGameObject.SetActive(true);
|
|
if(buffs != null && buffs.Count != 0)
|
|
buffGameObject.SetActive(true);
|
|
}
|
|
public void AddSpecial(Buff newBuff)
|
|
{
|
|
specialBuffs.Add(newBuff);
|
|
}
|
|
public void TurnEnd()
|
|
{
|
|
if(buffs != null && buffs.Count != 0)
|
|
foreach(var buff in buffs)
|
|
{
|
|
buff.timer -= 1;
|
|
if(buff.timer == 0)
|
|
{
|
|
buff.Remove(self);
|
|
buffs.Remove(buff);
|
|
}
|
|
}
|
|
if(!(buffs != null && buffs.Count != 0))
|
|
buffGameObject.SetActive(false);
|
|
if(debuffs != null && debuffs.Count != 0)
|
|
foreach(var debuff in debuffs)
|
|
{
|
|
debuff.timer -= 1;
|
|
if(debuff.timer == 0)
|
|
{
|
|
debuff.Remove(self);
|
|
debuffs.Remove(debuff);
|
|
}
|
|
}
|
|
if(!(debuffs != null && debuffs.Count != 0))
|
|
debuffGameObject.SetActive(false);
|
|
}
|
|
public void ApplyActiveSpecial(Character enemy)
|
|
{
|
|
foreach (var buff in self.buffManager.specialBuffs)
|
|
{
|
|
if(buff.type == 0)
|
|
buff.Apply(self, enemy);
|
|
}
|
|
}
|
|
public void ApplyPassiveSpecial(Character enemy)
|
|
{
|
|
foreach (var buff in self.buffManager.specialBuffs)
|
|
{
|
|
if(buff.type == 1)
|
|
buff.Apply(self,enemy);
|
|
}
|
|
}
|
|
public void RemoveSpecial(Buff buff)
|
|
{
|
|
specialBuffs.Remove(buff);
|
|
}
|
|
public void RemoveAllBuffs()
|
|
{
|
|
buffs.Clear();
|
|
debuffs.Clear();
|
|
specialBuffs.Clear();
|
|
buffGameObject.SetActive(false);
|
|
debuffGameObject.SetActive(false);
|
|
}
|
|
}
|