Files
gold_dolphin/unity/Assets/Script/GameObject/Other/Door.cs
2026-06-20 19:35:25 +08:00

45 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Door : MonoBehaviour
{
public Animator _ani;
public BoxCollider2D bx;
public bool isOpen=false;
public GameObject boss;
private void Awake()
{
_ani = GetComponentInChildren<Animator>();
bx = GetComponent<BoxCollider2D>();
boss = GameObject.FindWithTag("Boss");
}
private void Update()
{
if(isOpen)
{
Debug.Log("¿ªÃÅ");
_ani.Play("activate");
StartCoroutine(nameof(Open));
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.CompareTag("Player")&&!isOpen)
{
UIManager.Instance.Show<UIOpen>();
}
}
private IEnumerator Open()
{
yield return new WaitForSeconds(7f);
bx.isTrigger = true;
boss.GetComponentInChildren<BossAI>().SetBegin(true);
isOpen=false;
this.gameObject.SetActive(false);
}
}