68 lines
1.7 KiB
C#
68 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine.U2D;
|
|
using UnityEngine.UI;
|
|
|
|
public class RankItem1 : MonoBehaviour
|
|
{
|
|
//用户头像
|
|
public Image imgUserPic;
|
|
//名次图片
|
|
public Image imgRanking;
|
|
//名次底图
|
|
public Image imgItem;
|
|
|
|
|
|
//播放按钮
|
|
public Button btnPlaying;
|
|
|
|
//昵称
|
|
public Text txtName;
|
|
|
|
//分数
|
|
public Text txtScore;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
//点击播放按钮做什么
|
|
btnPlaying.onClick.AddListener(() => { });
|
|
}
|
|
|
|
public void InitInfo(PlayerData info,int i)
|
|
{
|
|
//更新按钮上的信息
|
|
txtName.text = "昵称:"+info.username;
|
|
txtScore.text = info.weekScore.ToString();
|
|
//加载图集
|
|
SpriteAtlas sa = Resources.Load<SpriteAtlas>("Atlas/RankPanel");
|
|
|
|
switch (i)
|
|
{
|
|
case 1://第一名
|
|
imgRanking.sprite = sa.GetSprite("icn_rank1");
|
|
imgItem.sprite= sa.GetSprite("img_listrank1");
|
|
ChangePic(info,sa);
|
|
break;
|
|
case 2://第二名
|
|
imgRanking.sprite = sa.GetSprite("icn_rank2");
|
|
imgItem.sprite = sa.GetSprite("img_listrank2");
|
|
ChangePic(info, sa);
|
|
break;
|
|
case 3://第三名
|
|
imgRanking.sprite = sa.GetSprite("icn_rank3");
|
|
imgItem.sprite = sa.GetSprite("img_listrank3");
|
|
ChangePic(info, sa);
|
|
break;
|
|
}
|
|
}
|
|
|
|
private void ChangePic(PlayerData info, SpriteAtlas sa)
|
|
{
|
|
//默认头像
|
|
imgUserPic.sprite = sa.GetSprite("frame_head");
|
|
}
|
|
}
|