备份CatanBuilding瘦身独立工程
This commit is contained in:
51
Assets/Scripts/EventBingo/EventBingoTaskView.cs
Normal file
51
Assets/Scripts/EventBingo/EventBingoTaskView.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using asap.core;
|
||||
using DG.Tweening;
|
||||
using GameCore;
|
||||
|
||||
public class EventBingoTaskView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image progressBar;
|
||||
[SerializeField] private RewardItemNew reward, finalReward;
|
||||
[SerializeField] private TMP_Text textProgress;
|
||||
private int _taskId;
|
||||
private float _progressGrowthDuration = 0.3f;
|
||||
private ItemData _reward;
|
||||
private const float RewardFlyDuration = 1.2f;
|
||||
public int TaskId => _taskId;
|
||||
|
||||
public void Init(EventBingoProgressTaskData taskData)
|
||||
{
|
||||
progressBar.fillAmount = taskData.Progress / (float)taskData.TargetProgress;
|
||||
reward.SetData(taskData.Reward);
|
||||
textProgress.text = taskData.Progress + "/" + taskData.TargetProgress;
|
||||
_taskId = taskData.TaskId;
|
||||
_reward = taskData.Reward;
|
||||
var bingoModel = GContext.container.Resolve<EventBingoModel>();
|
||||
var fr = bingoModel.Ctx.GetProgressTaskFinalReward();
|
||||
finalReward.SetData(fr);
|
||||
}
|
||||
|
||||
public async System.Threading.Tasks.Task UpdateProgress()
|
||||
{
|
||||
var newData = GContext.container.Resolve<EventBingoModel>().TaskData;
|
||||
if (newData.TaskId == _taskId)
|
||||
{
|
||||
var newProgress = newData.Progress / (float)newData.TargetProgress;
|
||||
progressBar.DOFillAmount(newProgress, _progressGrowthDuration);
|
||||
textProgress.text = newData.Progress + "/" + newData.TargetProgress;
|
||||
}
|
||||
else
|
||||
{
|
||||
var s = textProgress.text;
|
||||
var tokens = s.Split('/');
|
||||
textProgress.text = tokens[1] + "/" + tokens[1];
|
||||
await progressBar.DOFillAmount(1, _progressGrowthDuration).AsyncWaitForCompletion();
|
||||
GContext.Publish(new EventRewardFlyStashRequest(_reward, reward.icon.GetComponent<RectTransform>()));
|
||||
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(RewardFlyDuration));
|
||||
Init(newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user