42 lines
1.4 KiB
C#
42 lines
1.4 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class EventPartnerWheelPiece : MonoBehaviour
|
|
{
|
|
private Image _imgBg, _imgBgShow;
|
|
private TMP_Text _textScore, _textScoreShow;
|
|
[SerializeField] private Animation animationShow;
|
|
private void Awake()
|
|
{
|
|
_imgBg = transform.Find("bg").GetComponent<Image>();
|
|
_textScore = transform.Find("text_beilv").GetComponent<TMP_Text>();
|
|
_imgBgShow = animationShow.transform.Find("bg").GetComponent<Image>();
|
|
_textScoreShow = animationShow.transform.Find("text_beilv").GetComponent<TMP_Text>();
|
|
}
|
|
public void Init(string bgUrl, int score, EventPartnerAct.Context ctx)
|
|
{
|
|
// Debug.Log(bgUrl);
|
|
// Debug.Log(score);
|
|
// GContext.container.Resolve<IUIService>().SetImageSprite(_imgBg, bgUrl);
|
|
_imgBg.sprite = ctx.GetSprite(bgUrl);
|
|
_textScore.text = score.ToString();
|
|
_imgBgShow.sprite = ctx.GetSprite(bgUrl);
|
|
_textScoreShow.text = score.ToString();
|
|
animationShow.Rewind();
|
|
}
|
|
|
|
public void SetScore(int score)
|
|
{
|
|
_textScore.text = score.ToString();
|
|
_textScoreShow.text = score.ToString();
|
|
}
|
|
|
|
public async System.Threading.Tasks.Task PlayShow()
|
|
{
|
|
animationShow.Play("turntable_reward");
|
|
// float time = animationShow["turntable_reward"].length;
|
|
await System.Threading.Tasks.Task.Delay(System.TimeSpan.FromSeconds(48f / 60f));
|
|
}
|
|
}
|