_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/Battle_Royale/ListItem.cs
2024-12-11 16:57:42 +08:00

68 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ListItem : MonoBehaviour
{
public int list;
public int UserId;//用户id
public TextMeshProUGUI listText;//排名
public Image listImage;//排名徽章图片
public Image headImage;//头像
public TextMeshProUGUI nameText;//名字
public TextMeshProUGUI numText;//蜗牛蛋数量
public Image Bg;//背景图片
public string headPath;//头像路径
[Header("蜗牛壳或蜗牛蛋图片")]
//[HideInInspector]
public Image snailCoinImage;//蜗牛壳或蜗牛蛋图片
[Header("蜗牛壳精灵图片资源")]
public Sprite woke;
void Start()
{
SetListImage();
ListBgImage();
}
public void SetListImage()//设排名徽章背景颜色
{
if (list == 1)
{
listImage.sprite = Resources.Load<Sprite>("bgYello");
nameText.color = new UnityEngine.Color(246/255f, 194/255f, 146 / 255f);
}
else if (list == 2)
{
listImage.sprite = Resources.Load<Sprite>("bgGreen");
nameText.color = new UnityEngine.Color(201 / 255f, 208/255f, 144 / 255f);
}
else if (list == 3)
{
listImage.sprite = Resources.Load<Sprite>("bgBlue");
nameText.color = new UnityEngine.Color(144/255f, 206 / 255f, 208/255f);
}
else
{
listImage.sprite = Resources.Load<Sprite>("bgred");
}
}
public void ListBgImage()//设排名徽章背景颜色
{
if (list!=1&&list%2==0)//偶数排名
{
Bg.sprite = Resources.Load<Sprite>("bgbuleT");
}
else
{
Bg.sprite = Resources.Load<Sprite>("bgWhite");
}
}
}