BuffController.cs 823 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class BuffController : MonoBehaviour
  5. {
  6. private MoveCharacter owner;
  7. public List<BuffBase> buffList;
  8. private void Awake()
  9. {
  10. owner = GetComponent<MoveCharacter>();
  11. }
  12. private void OnEnable()
  13. {
  14. buffList = new List<BuffBase>();
  15. }
  16. public void AddBuff(BuffBase buff)
  17. {
  18. buffList.Add(buff);
  19. buff.AddBuff(owner);
  20. //Debug.Log("Ìî¼Óbuff");
  21. }
  22. public void RemoveBuff(BuffBase buff)
  23. {
  24. buffList.Remove(buff);
  25. buff.RemoveBuff(owner);
  26. //Debug.Log("ÒÆ³ýbuff");
  27. }
  28. private void OnDisable()
  29. {
  30. foreach(BuffBase buff in buffList)
  31. {
  32. buff.RemoveBuff(owner);
  33. }
  34. buffList.Clear();
  35. }
  36. }