您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
51 行
1.0 KiB
51 行
1.0 KiB
using System;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
|
|
[RequireComponent (typeof(Animator))]
|
|
public class Chest : MonoBehaviour
|
|
{
|
|
private Animator m_Animator;
|
|
|
|
[SerializeField]
|
|
private ParticleSystem m_ParticleSystem;
|
|
|
|
[SerializeField]
|
|
private float m_ParticlePlayDelayTime = 0.75f;
|
|
|
|
[SerializeField]
|
|
private GameObject m_Key;
|
|
|
|
[SerializeField]
|
|
private float m_KeyDestroyDelayTime = 0.75f;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
m_Animator = GetComponent<Animator>();
|
|
}
|
|
|
|
public void Open()
|
|
{
|
|
// TODO: cache the string as a hash
|
|
m_Animator.SetTrigger("Open");
|
|
|
|
StartCoroutine(PlayParticles());
|
|
|
|
StartCoroutine(DestroyKey());
|
|
}
|
|
|
|
private IEnumerator DestroyKey()
|
|
{
|
|
yield return new WaitForSeconds(m_KeyDestroyDelayTime);
|
|
|
|
m_Key.SetActive(false);
|
|
}
|
|
|
|
private IEnumerator PlayParticles()
|
|
{
|
|
yield return new WaitForSeconds(m_ParticlePlayDelayTime);
|
|
|
|
m_ParticleSystem.Play();
|
|
}
|
|
}
|