using System.IO; using System.Collections; using System.Collections.Generic; using UnityEngine; public class BuffManager : MonoBehaviour { GameObject debuffGameObject; GameObject buffGameObject; public List buffs = new List(); public List debuffs = new List(); public List specialBuffs = new List(); Character self; private void Awake() { self = transform.parent.GetComponent(); 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); } }