Files
5.24BuYu/Assets/MyGame/aa/UI/Home/Sub/BackPack/BackPackPropItem.cs
T
2026-07-09 19:35:25 +08:00

95 lines
2.4 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using Assets.Framework.Tool;
using Assets.MyGame.Scripts.Net;
using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;
[Serializable]
public enum PropEnum
{
none=0,
炮台 = 1,
翅膀 = 2,
炮塔碎片 = 3,
翅膀碎片 = 4,
战神 = 5,
战神碎片 = 6,
刮刮卡 = 7,
改名卡 = 8,
大喇叭 = 9,
技能 = 10,
召唤卡 = 11,
}
/// <summary>
/// BackPackPropItem 初始化数据
/// </summary>
[Serializable]
public class BackPackPropItemData
{
/// <summary>道具图标地址(完整 URL,含 baseURL)</summary>
public string url;
/// <summary>道具数量</summary>
public int count;
/// <summary>道具类型</summary>
public PropEnum propEnum = PropEnum.none;
}
public class BackPackPropItem : MonoBehaviour
{
public List<Image> item_Bg;
public Dictionary<PropEnum, Image> item_Type=new Dictionary<PropEnum, Image>();
public Image img_Prop;
public TextMeshProUGUI propCount;
public void Init(BackPackPropItemData data)
{
if (data == null) return;
PropEnum propEnum = data.propEnum;
switch (propEnum)
{
case PropEnum.none:
break;
default:
break;
}
switch (propEnum)
{
case PropEnum.none:
break;
case PropEnum.炮塔碎片:
case PropEnum.翅膀碎片:
item_Bg[1].gameObject.SetActive(true);
break;
case PropEnum.战神碎片:
item_Bg[0].gameObject.SetActive(true);
break;
case PropEnum.刮刮卡:
case PropEnum.召唤卡:
case PropEnum.技能:
item_Bg[2].gameObject.SetActive(true);
break;
case PropEnum.改名卡:
case PropEnum.大喇叭:
item_Bg[3].gameObject.SetActive(true);
break;
default:
break;
}
WebTool.DownImage(data.url, (texture) =>
{
if (texture!=null)
{
img_Prop.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.one * 0.5f);
}
});
this.propCount.text = data.count.ToString();
}
}