103 lines
2.1 KiB
C#
103 lines
2.1 KiB
C#
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;
|
|
}
|
|
}
|
|
} |