using System.Drawing;
using UnityEngine;
using UnityEngine.UI;
using EnhancedUI.EnhancedScroller;
using TMPro;
using DG.Tweening;
public class FinalPanelItem : EnhancedScrollerCellView
{
public Text playerNameTxt;
public TextMeshProUGUI playerScoreTxt;
public TextMeshProUGUI indexTxt;
public Image icon;
public Image backGround;
private RectTransform rt;
///
/// Start is called on the frame when a script is enabled just before
/// any of the Update methods is called the first time.
///
void Awake()
{
offect = Vector3.zero;
rt = transform.GetComponent();
}
Vector3 offect;
public void SetData(FinalPanelItemData data)
{
playerNameTxt.text = data.playerName;
playerScoreTxt.text = data.score.ToString();
if (data.spriteIcon != null)
{
if (!icon.gameObject.activeSelf) icon.gameObject.SetActive(true);
icon.sprite = data.spriteIcon;
indexTxt.text = "";
}
else
{
icon.gameObject.SetActive(false);
indexTxt.text = data.index.ToString();
}
backGround.sprite = data.spriteBackGround;
if (rt != null)
{
offect.x = rt.anchoredPosition3D.x;
offect.y = rt.anchoredPosition3D.y;
rt.anchoredPosition3D = offect;
}
}
public void SetPos()
{
backGround.rectTransform.anchoredPosition = new UnityEngine.Vector2(720, 0);
}
public void PlayDoTween(float duration)
{
//Sequence agentTweenSeq = DOTween.Sequence();
//agentTweenSeq.Join(backGround.rectTransform.DOAnchorPosX(0, duration));
backGround.rectTransform.DOAnchorPosX(0, duration);
}
}