62 lines
1.5 KiB
C#
62 lines
1.5 KiB
C#
|
using System;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
public class MagicDoorVampireController : MonoBehaviour
|
|||
|
{
|
|||
|
private Animator _animator;
|
|||
|
private EnemyController _vampire;
|
|||
|
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
_animator = GetComponent<Animator>();
|
|||
|
}
|
|||
|
|
|||
|
private void OnEnable()
|
|||
|
{
|
|||
|
GameManager.Instance.EventManager.OnVampireShow += GetGuardEvent;
|
|||
|
}
|
|||
|
|
|||
|
private void OnDisable()
|
|||
|
{
|
|||
|
GameManager.Instance.EventManager.OnVampireShow -= GetGuardEvent;
|
|||
|
}
|
|||
|
|
|||
|
public void RecycleSelf()
|
|||
|
{
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դ
|
|||
|
GameManager.Instance.PoolManager.RecycleResource(gameObject);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private void GetGuardEvent()
|
|||
|
{
|
|||
|
StartCoroutine(GetGuard());
|
|||
|
}
|
|||
|
|
|||
|
IEnumerator GetGuard()
|
|||
|
{
|
|||
|
_vampire = null;
|
|||
|
// <20><><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>б<EFBFBD><D0B1>а<EFBFBD>λ<EFBFBD>û<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
|
|||
|
while(null == _vampire)
|
|||
|
{
|
|||
|
GameManager.Instance.PoolManager.UseList.ForEach(obj =>
|
|||
|
{
|
|||
|
if ((Vector2)obj.transform.position == new Vector2(0, 0))
|
|||
|
{
|
|||
|
if (obj.GetComponent<EnemyController>() != null)
|
|||
|
{
|
|||
|
_vampire = obj.GetComponent<EnemyController>();
|
|||
|
_vampire.OnDeath += () => { _animator.SetTrigger("open"); };
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
yield return null;
|
|||
|
}
|
|||
|
yield break;
|
|||
|
}
|
|||
|
}
|