Pink/Assets/Hero Knight - Pixel Art/Demo/Sensor_HeroKnight.cs

42 lines
677 B
C#
Raw Normal View History

2020-09-23 00:54:30 +01:00
using UnityEngine;
using System.Collections;
public class Sensor_HeroKnight : MonoBehaviour {
private int m_ColCount = 0;
private float m_DisableTimer;
private void OnEnable()
{
m_ColCount = 0;
}
public bool State()
{
if (m_DisableTimer > 0)
return false;
return m_ColCount > 0;
}
void OnTriggerEnter2D(Collider2D other)
{
m_ColCount++;
}
void OnTriggerExit2D(Collider2D other)
{
m_ColCount--;
}
void Update()
{
m_DisableTimer -= Time.deltaTime;
}
public void Disable(float duration)
{
m_DisableTimer = duration;
}
}