ball 项目提交
This commit is contained in:
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BallKingdomCrush
|
||||
{
|
||||
public class RewardDisplayData
|
||||
{
|
||||
public RewardSingleData rewardSingleData;
|
||||
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 RewardDisplayData(RewardSingleData rewardSingleData)
|
||||
{
|
||||
this.rewardSingleData = rewardSingleData;
|
||||
showValue = rewardSingleData.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user