Spirits_Cook.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using TMPro;
  5. public class Spirits_Cook : MonoBehaviour
  6. {
  7. public GameObject attributeUpEffect;
  8. public float reductionDegree;
  9. public float reductionTime;
  10. public List<MoveCharacter> mcs = new List<MoveCharacter>();
  11. private void OnTriggerEnter(Collider other)
  12. {
  13. if (other.gameObject.layer == 6 || other.gameObject.layer == 7)
  14. {
  15. MoveCharacter mc = other.GetComponentInParent<MoveCharacter>();
  16. if (!mc.isDamageReduction)
  17. {
  18. mc.DamageReductionStateOn(reductionDegree, attributeUpEffect);
  19. mcs.Add(mc);
  20. }
  21. }
  22. }
  23. private void OnTriggerExit(Collider other)
  24. {
  25. if (other.gameObject.layer == 6 || other.gameObject.layer == 7)
  26. {
  27. MoveCharacter mc = other.GetComponentInParent<MoveCharacter>();
  28. if (mc.isDamageReduction)
  29. {
  30. mc.DamageReductionStateToOff(reductionTime);
  31. }
  32. }
  33. }
  34. private void OnDisable()
  35. {
  36. foreach(MoveCharacter mc in mcs)
  37. {
  38. if (mc.isDamageReduction)
  39. {
  40. mc.DamageReductionStateToOff(reductionTime);
  41. }
  42. }
  43. }
  44. }