1
This commit is contained in:
44
unity/Assets/Script/GameObject/Other/Door.cs
Normal file
44
unity/Assets/Script/GameObject/Other/Door.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user