修改天梯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,13 @@
namespace TcgEngine
{
public enum PlayerRank
{
Bronze = 1, // 青铜
Silver, // 白银
Gold, // 黄金
Platinum, // 铂金
Diamond, // 钻石
King // 王者
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: d4d1858a3e374fad88a50b93ce108699
timeCreated: 1756956870

View File

@@ -0,0 +1,80 @@
using System.Collections.Generic;
using UnityEngine;
namespace TcgEngine
{
[CreateAssetMenu(fileName = "NewRankMedalData", menuName = "TcgEngine/Rank/RankMedalData", order = 5)]
public class RankMedalData : ScriptableObject
{
public string medalName;
public Sprite sprite;
public string icon_url;
private static List<RankMedalData> medalList = new List<RankMedalData>();
/// <summary>
/// 从 Resources 目录加载所有 RankIconData
/// </summary>
public static void Load(string folder = "")
{
if (medalList.Count == 0)
{
medalList.AddRange(Resources.LoadAll<RankMedalData>(folder));
}
}
/// <summary>
/// 获取所有奖牌配置
/// </summary>
public static List<RankMedalData> GetAll()
{
return medalList;
}
/// <summary>
/// 根据奖牌名称查找
/// </summary>
public static RankMedalData Get(string name)
{
foreach (RankMedalData item in medalList)
{
if (item.medalName == name)
return item;
}
return null;
}
/// <summary>
/// 获取奖牌 Sprite优先走网络路径需要配合 SpriteLoader
/// </summary>
public Sprite GetIcon()
{
Sprite result = null;
if (!string.IsNullOrEmpty(icon_url))
{
result = SpriteLoader.Get()?.LoadSprite(icon_url);
if (result != null)
{
return result;
}
if (sprite != null)
{
Debug.LogWarning($"奖牌 {medalName} -- 动态加载失败使用静态Sprite -- {icon_url}");
return sprite;
}
Debug.LogError($"奖牌 {medalName} -- 动态路径无效且没有静态Sprite -- {icon_url}");
return null;
}
else
{
Debug.LogWarning($"奖牌 {medalName} 未配置网络路径使用静态Sprite");
return sprite;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1c608c7081254d72a729e959fb60231a
timeCreated: 1756975648

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];
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5802a2b802f84bc1978f57cf18eb6f1f
timeCreated: 1756956121