8.30
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
using SepCore.Definition;
|
||||
using UnityEngine;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// 道具详情界面逻辑(手写 partial,与自动生成的 ItemDetailsForm.cs 合并)。
|
||||
/// 只提供详情显示能力,由调用方(WarehouseForm)传入物品 ID 后刷新。
|
||||
/// </summary>
|
||||
public partial class ItemDetailsForm : UGuiForm
|
||||
{
|
||||
/// <summary>
|
||||
/// 按物品 ID 刷新详情界面;配置不存在时清空显示。
|
||||
/// </summary>
|
||||
public void Refresh(int itemId)
|
||||
{
|
||||
ItemDetailsView view = View;
|
||||
if (view == null)
|
||||
{
|
||||
Log.Warning("ItemDetailsForm view is not configured.");
|
||||
return;
|
||||
}
|
||||
|
||||
ItemConfig config = GameEntry.Luban.Get<ItemConfig>(itemId);
|
||||
if (config == null)
|
||||
{
|
||||
Log.Warning("Can not find item config '{0}' for item details.", itemId);
|
||||
ClearDetails(view);
|
||||
return;
|
||||
}
|
||||
|
||||
if (view.itemDetailNameText != null)
|
||||
{
|
||||
view.itemDetailNameText.text = config.Name;
|
||||
}
|
||||
|
||||
if (view.itemDetailTypeText != null)
|
||||
{
|
||||
view.itemDetailTypeText.text = GetItemTypeName(config.ItemType) + " / " + GetRarityName(config.Rarity);
|
||||
}
|
||||
|
||||
if (view.hpFormatText != null)
|
||||
{
|
||||
view.hpFormatText.Set(config.MaxHpBonus);
|
||||
}
|
||||
|
||||
if (view.atkFormatText != null)
|
||||
{
|
||||
view.atkFormatText.Set(config.AtkBonus);
|
||||
}
|
||||
|
||||
if (view.mpFormatText != null)
|
||||
{
|
||||
view.mpFormatText.Set(config.MaxMpBonus);
|
||||
}
|
||||
|
||||
if (view.matFormatText != null)
|
||||
{
|
||||
view.matFormatText.Set(config.MatBonus);
|
||||
}
|
||||
|
||||
if (view.speedFormatText != null)
|
||||
{
|
||||
view.speedFormatText.Set(0);
|
||||
}
|
||||
|
||||
if (view.stackFormatText != null)
|
||||
{
|
||||
view.stackFormatText.Set(config.StackLimit);
|
||||
}
|
||||
|
||||
if (view.itemDetailDescriptionText != null)
|
||||
{
|
||||
view.itemDetailDescriptionText.text = string.Empty;
|
||||
}
|
||||
|
||||
if (view.itemDetailIcon != null)
|
||||
{
|
||||
view.itemDetailIcon.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ClearDetails(ItemDetailsView view)
|
||||
{
|
||||
if (view.itemDetailNameText != null)
|
||||
{
|
||||
view.itemDetailNameText.text = string.Empty;
|
||||
}
|
||||
|
||||
if (view.itemDetailTypeText != null)
|
||||
{
|
||||
view.itemDetailTypeText.text = string.Empty;
|
||||
}
|
||||
|
||||
if (view.itemDetailDescriptionText != null)
|
||||
{
|
||||
view.itemDetailDescriptionText.text = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetItemTypeName(ItemType itemType)
|
||||
{
|
||||
switch (itemType)
|
||||
{
|
||||
case ItemType.Loot:
|
||||
return "战利品";
|
||||
case ItemType.Equipment:
|
||||
return "装备";
|
||||
case ItemType.Consumable:
|
||||
return "消耗品";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetRarityName(Rarity rarity)
|
||||
{
|
||||
switch (rarity)
|
||||
{
|
||||
case Rarity.White:
|
||||
return "白";
|
||||
case Rarity.Green:
|
||||
return "绿";
|
||||
case Rarity.Blue:
|
||||
return "蓝";
|
||||
case Rarity.Gold:
|
||||
return "金";
|
||||
case Rarity.Red:
|
||||
return "红";
|
||||
default:
|
||||
return "无";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33d70aa8e73294a65b7b132a8a0619af
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -9,12 +9,12 @@ namespace SepCore.UI
|
||||
[SerializeField] public global::UnityEngine.UI.Image itemDetailIcon;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI itemDetailNameText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI itemDetailTypeText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI hpText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI atkText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI mpText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI matText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI speedText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI stackText;
|
||||
[SerializeField] public global::SepCore.UI.FormatTextUI hpFormatText;
|
||||
[SerializeField] public global::SepCore.UI.FormatTextUI atkFormatText;
|
||||
[SerializeField] public global::SepCore.UI.FormatTextUI mpFormatText;
|
||||
[SerializeField] public global::SepCore.UI.FormatTextUI matFormatText;
|
||||
[SerializeField] public global::SepCore.UI.FormatTextUI speedFormatText;
|
||||
[SerializeField] public global::SepCore.UI.FormatTextUI stackFormatText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI itemDetailDescriptionText;
|
||||
[SerializeField] public global::UnityEngine.UI.Button openLoadoutButton;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user