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

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;
}
}
}