Files
BingoGrassland/Assets/BingoBrain/Model/Game/GodDa.cs
T

103 lines
2.1 KiB
C#
Raw Normal View History

2026-04-20 13:49:36 +08:00
using System;
using UnityEngine;
namespace BingoBrain
{
public class GodDa
{
public Goda Goda;
public bool isPlayAudio;
public string audioName;
public bool isNeedFly;
public bool isNeedValueChange;
public event Action<decimal> UpdateCb;
public event Action EndEventCb;
public event Action UICloseEventCb;
private decimal coinAddTime = 0.45m;
public bool isSingle;
private decimal showValue;
private decimal showAddValue;
private bool isCompleted;
public GodDa(Goda goda)
{
this.Goda = goda;
showValue = goda.GetTotalValue();
showAddValue = showValue;
}
public void SetUpdate(Action<decimal> updateCb)
{
UpdateCb = updateCb;
}
public void Update()
{
if (isCompleted)
{
return;
}
var val = showValue * Convert.ToDecimal(Time.deltaTime) / coinAddTime;
if (showAddValue >= val)
{
showAddValue -= val;
if (isNeedValueChange)
{
UpdateCb?.Invoke(val);
}
}
else if (showAddValue > 0)
{
if (isNeedValueChange)
{
UpdateCb?.Invoke(showAddValue);
}
showAddValue = 0;
}
else
{
EndEvent();
}
}
public void SetUpdateComplete(Action endEventCb)
{
EndEventCb = endEventCb;
}
public void EndEvent()
{
EndEventCb?.Invoke();
EndEventCb = null;
isCompleted = true;
}
public void UICloseEvent()
{
UICloseEventCb?.Invoke();
}
public void Dispose()
{
UpdateCb = null;
EndEventCb = null;
UICloseEventCb = null;
}
}
}