Global Game Jam 2022
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.

38 lines
903 B

  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using UnityEngine;
  5. using Variables;
  6. public class ChestController : MonoBehaviour
  7. {
  8. [SerializeField, Header("References")]
  9. private Animator m_chestAnimator;
  10. [SerializeField]
  11. private Animator m_playerAnimator;
  12. [SerializeField]
  13. private Reference<bool> m_freezePlayer;
  14. [SerializeField]
  15. private Reference<bool> m_isVictory;
  16. private void OnTriggerEnter2D(Collider2D collision)
  17. {
  18. Animator[] animators = collision.GetComponentsInChildren<Animator>().Concat(collision.GetComponentsInParent<Animator>()).ToArray();
  19. if (animators.Contains(m_playerAnimator))
  20. {
  21. m_chestAnimator.SetBool("Open", true);
  22. m_playerAnimator.SetTrigger("Victory");
  23. m_freezePlayer.Value = true;
  24. m_isVictory.Value = true;
  25. }
  26. }
  27. }