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.

34 lines
802 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. private void OnTriggerEnter2D(Collider2D collision)
  15. {
  16. Animator[] animators = collision.GetComponentsInChildren<Animator>().Concat(collision.GetComponentsInParent<Animator>()).ToArray();
  17. if (animators.Contains(m_playerAnimator))
  18. {
  19. m_chestAnimator.SetBool("Open", true);
  20. m_playerAnimator.SetTrigger("Victory");
  21. m_freezePlayer.Value = true;
  22. }
  23. }
  24. }