48 lines
943 B
C#
48 lines
943 B
C#
|
|
using System;
|
||
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class LuckyGameCupCounter : MonoBehaviour
|
||
|
|
{
|
||
|
|
public int objectCount = 0;
|
||
|
|
public int refillobjectCount = 0;
|
||
|
|
|
||
|
|
Action<int> m_actcount;
|
||
|
|
bool isRefill;
|
||
|
|
|
||
|
|
public void Set(Action<int> actcount)
|
||
|
|
{
|
||
|
|
m_actcount = actcount;
|
||
|
|
EndRefill();
|
||
|
|
}
|
||
|
|
|
||
|
|
public void StartRefill()
|
||
|
|
{
|
||
|
|
isRefill = true;
|
||
|
|
}
|
||
|
|
public void EndRefill()
|
||
|
|
{
|
||
|
|
refillobjectCount = 0;
|
||
|
|
isRefill = false;
|
||
|
|
}
|
||
|
|
|
||
|
|
void OnTriggerEnter2D(Collider2D other)
|
||
|
|
{
|
||
|
|
if (other.CompareTag("LuckyGameObj")) // 오브젝트에 Tag 지정
|
||
|
|
{
|
||
|
|
objectCount++;
|
||
|
|
m_actcount(objectCount);
|
||
|
|
|
||
|
|
if (isRefill)
|
||
|
|
++refillobjectCount;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void OnTriggerExit2D(Collider2D other)
|
||
|
|
{
|
||
|
|
if (other.CompareTag("LuckyGameObj"))
|
||
|
|
{
|
||
|
|
objectCount--;
|
||
|
|
m_actcount(objectCount);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|