35 lines
1.1 KiB
C#
35 lines
1.1 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using System.Threading.Tasks;
|
|
using DG.Tweening;
|
|
using asap.core;
|
|
|
|
public class EventPartnerStatueBuildScoreView : MonoBehaviour
|
|
{
|
|
[SerializeField] private Head head;
|
|
[SerializeField] private TMP_Text textScore, textName, textScoreAdd;
|
|
[SerializeField] private Animation anim;
|
|
private int _score;
|
|
|
|
public void Init(string avatarUrl, string name, int score)
|
|
{
|
|
head.SetData(avatarUrl);
|
|
textName.text = name;
|
|
textScore.text = score.ToString();
|
|
_score = score;
|
|
}
|
|
|
|
public async Task AddScores(int score2Add, int newScore, float duration)
|
|
{
|
|
var arc = GContext.container.Resolve<EventPartnerStatueArc>();
|
|
textScoreAdd.text = "+" + score2Add;
|
|
textScoreAdd.gameObject.SetActive(true);
|
|
anim.Play();
|
|
await Task.Delay(500);
|
|
await DOTween.To(() => _score, v => _score = v, newScore, duration)
|
|
.OnUpdate(() => textScore.text = _score.ToString()).AsyncWaitForCompletion();
|
|
textScoreAdd.gameObject.SetActive(false);
|
|
}
|
|
|
|
}
|