58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
using UnityEngine;
|
|
|
|
namespace Gameplay.PostProcess.BlackArea
|
|
{
|
|
public class LightPoint
|
|
{
|
|
public bool isLight;
|
|
public int cellIndex;
|
|
public float remainTime;
|
|
|
|
private MeshRenderer _meshRenderer;
|
|
private readonly GameObject _lightObj;
|
|
|
|
public LightPoint(int cellIndex, GameObject lightObj)
|
|
{
|
|
this.cellIndex = cellIndex;
|
|
_lightObj = lightObj;
|
|
isLight = false;
|
|
remainTime = 0f;
|
|
|
|
_meshRenderer = _lightObj.GetComponentInChildren<MeshRenderer>();
|
|
}
|
|
|
|
public void LightUp()
|
|
{
|
|
isLight = true;
|
|
_lightObj.SetActive(true);
|
|
}
|
|
|
|
public void LightOff()
|
|
{
|
|
isLight = false;
|
|
_lightObj.SetActive(false);
|
|
}
|
|
|
|
public void MarkLight(float duringTime)
|
|
{
|
|
remainTime = Mathf.Max(duringTime, remainTime);
|
|
if (!isLight)
|
|
{
|
|
LightUp();
|
|
}
|
|
}
|
|
|
|
public void LogicUpdate(float dt)
|
|
{
|
|
if (isLight)
|
|
{
|
|
remainTime -= dt;
|
|
if (remainTime < 0)
|
|
{
|
|
LightOff();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|