调整部分数据表配置,优化 SpriteCache 功能
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.Event;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -68,7 +69,7 @@ namespace SepCore.UI
|
||||
if (_iconArea != null && !string.IsNullOrEmpty(_context.IconAssetName))
|
||||
{
|
||||
string iconAssetName = _context.IconAssetName;
|
||||
var sprite = await GameEntry.SpriteCache.GetSprite(iconAssetName);
|
||||
var sprite = await SpriteLoader.LoadSpriteByKeyAsync(iconAssetName);
|
||||
if (_context != null && _context.IconAssetName == iconAssetName)
|
||||
{
|
||||
_iconArea.OnInit(sprite, context.Rarity);
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace SepCore.UI
|
||||
Icon = null,
|
||||
Rarity = reward.Rarity,
|
||||
Description = ItemDescUtility.CreatePropDescription(reward.Modifiers),
|
||||
IconAssetName = reward.IconAssetName
|
||||
IconAssetName = reward.Sprite
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.AsyncTask;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -42,7 +43,7 @@ namespace SepCore.UI
|
||||
|
||||
if (string.IsNullOrEmpty(iconAssetName)) return;
|
||||
|
||||
var sprite = await GameEntry.SpriteCache.GetSprite(iconAssetName);
|
||||
var sprite = await SpriteLoader.LoadSpriteByKeyAsync(iconAssetName);
|
||||
_iconArea.SetIcon(sprite);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.Event;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -29,7 +30,7 @@ namespace SepCore.UI
|
||||
|
||||
if (_iconArea != null)
|
||||
{
|
||||
var sprite = await GameEntry.SpriteCache.GetSprite(_context.IconAssetName);
|
||||
var sprite = await SpriteLoader.LoadSpriteByKeyAsync(_context.IconAssetName);
|
||||
_iconArea.OnInit(sprite, context.Rarity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace SepCore.UI
|
||||
{
|
||||
public class GoodsItemContext : UIContext
|
||||
{
|
||||
public string Title;
|
||||
public string Name;
|
||||
public Rarity Rarity;
|
||||
public Sprite Icon;
|
||||
public ItemType ItemType;
|
||||
@@ -17,7 +17,7 @@ namespace SepCore.UI
|
||||
|
||||
public GoodsItemContext()
|
||||
{
|
||||
Title = string.Empty;
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
Rarity = Rarity.White;
|
||||
Price = 0;
|
||||
@@ -29,7 +29,7 @@ namespace SepCore.UI
|
||||
{
|
||||
if (rawData == null)
|
||||
{
|
||||
Title = string.Empty;
|
||||
Name = string.Empty;
|
||||
Description = string.Empty;
|
||||
Rarity = Rarity.White;
|
||||
Price = 0;
|
||||
@@ -45,25 +45,25 @@ namespace SepCore.UI
|
||||
if (rawData.DataRow == null)
|
||||
{
|
||||
Icon = null;
|
||||
Title = string.Empty;
|
||||
Name = string.Empty;
|
||||
}
|
||||
else if (ItemType == ItemType.Weapon)
|
||||
{
|
||||
if (rawData.DataRow is WeaponConfig weaponConfig)
|
||||
{
|
||||
Title = weaponConfig.Name;
|
||||
Name = weaponConfig.WeaponType.ToString();
|
||||
Description = ItemDescUtility.CreateWeaponDescription(weaponConfig);
|
||||
}
|
||||
else if (rawData.DataRow is WeaponData weaponData)
|
||||
{
|
||||
Title = weaponData.Title;
|
||||
Name = weaponData.Title;
|
||||
Description = ItemDescUtility.CreateWeaponDescription(weaponData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var prop = (PropConfig)rawData.DataRow;
|
||||
Title = prop.Title;
|
||||
Name = prop.Name;
|
||||
Description = ItemDescUtility.CreatePropDescription(prop.Modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
using System.Collections.Generic;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.Entity.Weapon;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
@@ -164,13 +164,13 @@ namespace SepCore.UI
|
||||
var context = new GoodsItemContext(rawData);
|
||||
context.Icon = context.ItemType switch
|
||||
{
|
||||
ItemType.Weapon => await GameEntry.SpriteCache.GetSprite(rawData.DataRow switch
|
||||
ItemType.Weapon => await SpriteLoader.LoadSpriteByKeyAsync(rawData.DataRow switch
|
||||
{
|
||||
WeaponConfig weaponConfig => weaponConfig.IconAssetName,
|
||||
WeaponConfig weaponConfig => weaponConfig.Sprite,
|
||||
WeaponData weaponData => weaponData.IconAssetName,
|
||||
_ => string.Empty
|
||||
}),
|
||||
ItemType.Prop => await GameEntry.SpriteCache.GetSprite(((PropConfig)rawData.DataRow).IconAssetName),
|
||||
ItemType.Prop => await SpriteLoader.LoadSpriteByKeyAsync(((PropConfig)rawData.DataRow).Sprite),
|
||||
_ => null
|
||||
};
|
||||
return context;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.Event;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity.Weapon;
|
||||
using SepCore.Entity;
|
||||
using GameFramework.Event;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace SepCore.UI
|
||||
public void Init(GoodsItemContext data)
|
||||
{
|
||||
_iconArea.OnInit(data.Icon, data.Rarity);
|
||||
_titleText.text = data.Title;
|
||||
_titleText.text = data.Name;
|
||||
_typeText.text = data.ItemType switch
|
||||
{
|
||||
ItemType.None => "error",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using SepCore.AsyncTask;
|
||||
using SepCore.Event;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -19,7 +20,7 @@ namespace SepCore.UI
|
||||
return;
|
||||
}
|
||||
|
||||
_roleImage.sprite = await GameEntry.SpriteCache.GetSprite(_context.IconName);
|
||||
_roleImage.sprite = await SpriteLoader.LoadSpriteByKeyAsync(_context.IconName);
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
@@ -34,7 +35,7 @@ namespace SepCore.UI
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Fire(this, SelectRoleHoverEventArgs.Create(_context.RoleId));
|
||||
GameEntry.Event.Fire(this, SelectRoleHoverEventArgs.Create(_context.RoleName));
|
||||
}
|
||||
|
||||
public void OnConfirmRoleClick()
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace SepCore.UI
|
||||
{
|
||||
public class RoleItemContext : UIContext
|
||||
{
|
||||
public int RoleId;
|
||||
public string RoleName;
|
||||
public string IconName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace SepCore.UI
|
||||
RoleItemRawData itemRawData = rawData.RoleItems[i];
|
||||
roleItems[i] = new RoleItemContext
|
||||
{
|
||||
RoleId = itemRawData.RoleId,
|
||||
RoleName = itemRawData.RoleName,
|
||||
IconName = itemRawData.IconName
|
||||
};
|
||||
}
|
||||
@@ -60,7 +60,7 @@ namespace SepCore.UI
|
||||
{
|
||||
propertyContext = new RolePropertyAreaContext
|
||||
{
|
||||
RoleName = rawData.SelectedRole.RoleName,
|
||||
RoleName = rawData.SelectedRole.Name,
|
||||
InitialPropertyText = ItemDescUtility.CreatePropDescription(rawData.SelectedRole.InitialProperties)
|
||||
?? string.Empty
|
||||
};
|
||||
@@ -168,7 +168,7 @@ namespace SepCore.UI
|
||||
return;
|
||||
}
|
||||
|
||||
SelectRoleRawData rawData = _useCase.SelectRole(args.RoleId);
|
||||
SelectRoleRawData rawData = _useCase.SelectRole(args.RoleName);
|
||||
await OpenUIAsync(rawData);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.Entity.Weapon;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.CustomUtility
|
||||
|
||||
Reference in New Issue
Block a user