Files
gold_dolphin/unity/Assets/Script/LotterySystem/UIlottertOpen.cs
2026-06-20 19:35:25 +08:00

35 lines
868 B
C#

using Manager;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class UIlottertOpen : MonoBehaviour
{
private Animator animator;
private bool isOpen=true;
private void Awake()
{
animator = GetComponentInChildren<Animator>();
}
private void OnTriggerStay2D(Collider2D collision)
{
if (Input.GetKeyDown(KeyCode.E)&&isOpen)
{
Debug.Log("Open Box");
isOpen = false;
animator.Play("Box");
SoundManager.Instance.PlaySound(SoundDefine.BoxOpen);
StartCoroutine(nameof(Open));
}
}
private void OnTriggerExit2D(Collider2D collision)
{
StopCoroutine(nameof(Open));
}
IEnumerator Open()
{
yield return new WaitForSeconds(1.2f);
UIManager.Instance.Show<UILottery>();
}
}