修改天梯UI数据,及任务的UI数据的初步同步

This commit is contained in:
YiHan0621
2025-09-04 18:04:09 +08:00
parent 9275b66383
commit 1f8e74b6c5
92 changed files with 6288 additions and 1393 deletions

View File

@@ -0,0 +1,111 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace TcgEngine
{
[CreateAssetMenu(fileName = "NewRankingData", menuName = "TcgEngine/Rank/RankingData", order = 5)]
public class RankingData :ScriptableObject
{
public string rankName = "青铜";
public PlayerRank rank;
public Sprite rankIcon;
public string rank_img_path;
public static List<RankingData> rank_lisk = new List<RankingData>();
public static void Load(string folder="")
{
if (rank_lisk.Count == 0)
{
rank_lisk.AddRange(Resources.LoadAll<RankingData>(folder));
}
rank_lisk.Sort((a, b) => a.rank.CompareTo(b.rank));
}
/// <summary>
/// 获取Rank图片优先使用动态路径
/// </summary>
public Sprite GetRankImage()
{
Sprite sprite = null;
if (!string.IsNullOrEmpty(rank_img_path))
{
sprite = SpriteLoader.Get()?.LoadSprite(rank_img_path);
if (sprite != null)
{
return sprite;
}
if (rankIcon != null)
{
Debug.LogWarning($"Rank {rankName} -- 动态加载失败使用静态Icon -- {rank_img_path}");
return rankIcon;
}
Debug.LogError($"Rank {rankName} -- 动态路径无效且没有静态Icon -- {rank_img_path}");
return null;
}
else
{
Debug.LogWarning($"Rank {rankName} 段位路径为空使用静态Icon");
return rankIcon;
}
}
public static RankingData Get(PlayerRank pRank)
{
foreach (RankingData item in GetAll())
{
if (item.rank == pRank)
{
return item;
}
}
return null;
}
public static List<RankingData> GetAllAvailable()
{
List<RankingData> validList = new List<RankingData>();
foreach (RankingData item in GetAll())
{
if (!string.IsNullOrEmpty(item.rank_img_path) || item.rankIcon != null)
{
validList.Add(item);
}
}
return validList;
}
public static List<RankingData> GetAll()
{
return rank_lisk;
}
// 当 Inspector 值发生改变时自动调用
private void OnValidate()
{
Dictionary<PlayerRank, string> rankNames = new Dictionary<PlayerRank, string>()
{
{ PlayerRank.Bronze, "青铜" },
{ PlayerRank.Silver, "白银" },
{ PlayerRank.Gold, "黄金" },
{ PlayerRank.Platinum, "铂金" },
{ PlayerRank.Diamond, "钻石" },
{ PlayerRank.King, "王者" }
};
if(rankNames.ContainsKey(rank))
rankName = rankNames[rank];
}
}
}