using System.Collections; using UnityEngine; public class BoxInteractiveComponent : InteractiveComponent { public bool isOpen; private Animator boxAnimator; private void Start() { } private void Update() { } public override void Interact() { // Open the box Debug.Log("Box Interact"); isOpen = true; // playSound(); var clipInfo = boxAnimator.GetCurrentAnimatorClipInfo(0); var animationLength = clipInfo[0].clip.length; boxAnimator.enabled = true; boxAnimator.SetTrigger("chest-open"); // set active box id BoxManager.Instance.SetActiveBox(Interactable.ID); StartCoroutine(WaitForAnimation(animationLength)); // wait for animation to finish // play open animation and sound // boxAnimator.SetTrigger("Open"); // check if box is locked. /*if (box.isLocked) { Debug.Log("Box is locked"); return; }*/ // open the inventory UI and set the active box id. } private IEnumerator WaitForAnimation(float animationLength) { yield return new WaitForSeconds(animationLength); UIManager.Instance.ToggleInventory(); boxAnimator.enabled = false; } }