using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using UnityEngine;
|
|
using Variables;
|
|
|
|
public class ChestController : MonoBehaviour
|
|
{
|
|
|
|
[SerializeField, Header("References")]
|
|
private Animator m_chestAnimator;
|
|
|
|
[SerializeField]
|
|
private Animator m_playerAnimator;
|
|
|
|
[SerializeField]
|
|
private Reference<bool> m_freezePlayer;
|
|
|
|
[SerializeField]
|
|
private Reference<bool> m_isVictory;
|
|
|
|
private void OnTriggerEnter2D(Collider2D collision)
|
|
{
|
|
Animator[] animators = collision.GetComponentsInChildren<Animator>().Concat(collision.GetComponentsInParent<Animator>()).ToArray();
|
|
|
|
if (animators.Contains(m_playerAnimator))
|
|
{
|
|
m_chestAnimator.SetBool("Open", true);
|
|
m_playerAnimator.SetTrigger("Victory");
|
|
m_freezePlayer.Value = true;
|
|
m_isVictory.Value = true;
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|