129 lines
3.9 KiB
C#
129 lines
3.9 KiB
C#
using SepCore.CustomUtility;
|
|
using SepCore.Definition;
|
|
using UnityEngine;
|
|
|
|
namespace SepCore.UI
|
|
{
|
|
public class ItemBasicTooltipContext
|
|
{
|
|
public int Index;
|
|
public string IconAssetName;
|
|
public string Title;
|
|
public ItemType ItemType;
|
|
public string TypeName;
|
|
public Rarity Rarity;
|
|
public string Description;
|
|
public int Price;
|
|
public bool ShowRecycleButton;
|
|
|
|
public ItemBasicTooltipContext()
|
|
{
|
|
Index = -1;
|
|
IconAssetName = string.Empty;
|
|
Title = string.Empty;
|
|
TypeName = string.Empty;
|
|
ItemType = ItemType.None;
|
|
Rarity = Rarity.White;
|
|
Description = string.Empty;
|
|
Price = 0;
|
|
ShowRecycleButton = false;
|
|
}
|
|
|
|
public ItemBasicTooltipContext(ItemTooltipRawData rawData) : this()
|
|
{
|
|
if (rawData == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
Index = rawData.Index;
|
|
ItemType = rawData.ItemType;
|
|
Rarity = rawData.Rarity;
|
|
Price = rawData.Price;
|
|
ShowRecycleButton = rawData.OnRecycle != null;
|
|
|
|
if (ItemType == ItemType.Weapon && rawData.WeaponData != null)
|
|
{
|
|
var data = rawData.WeaponData;
|
|
IconAssetName = data.Sprite;
|
|
Title = data.Title;
|
|
TypeName = ItemDescUtility.FormatWeaponTags(data);
|
|
Description = ItemDescUtility.CreateWeaponDescription(data);
|
|
}
|
|
else if (ItemType == ItemType.Prop && rawData.PropData != null)
|
|
{
|
|
var data = rawData.PropData;
|
|
IconAssetName = data.IconAssetName;
|
|
Title = data.Title;
|
|
TypeName = "道具";
|
|
Description = ItemDescUtility.CreatePropDescription(data);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ItemDetailTooltipContext
|
|
{
|
|
public bool HasTagSynergy;
|
|
public string TagTitle;
|
|
public string TagTiersContent;
|
|
|
|
public bool HasLastWaveDamage;
|
|
public int LastWaveDamage;
|
|
|
|
public bool HasAnyContent => HasTagSynergy || HasLastWaveDamage;
|
|
|
|
public ItemDetailTooltipContext()
|
|
{
|
|
HasTagSynergy = false;
|
|
TagTitle = string.Empty;
|
|
TagTiersContent = string.Empty;
|
|
HasLastWaveDamage = false;
|
|
LastWaveDamage = 0;
|
|
}
|
|
|
|
public ItemDetailTooltipContext(ItemTooltipRawData rawData) : this()
|
|
{
|
|
if (rawData == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
HasLastWaveDamage = rawData.LastWaveDamage > 0;
|
|
LastWaveDamage = rawData.LastWaveDamage;
|
|
|
|
if (rawData.ItemType == ItemType.Weapon && rawData.WeaponData != null && rawData.WeaponData.Tags != null && rawData.WeaponData.Tags.Count > 0)
|
|
{
|
|
ItemDescUtility.BuildTagSynergyInfo(rawData.WeaponData, rawData.CurrentTagCounts,
|
|
out TagTitle, out TagTiersContent);
|
|
HasTagSynergy = !string.IsNullOrEmpty(TagTiersContent);
|
|
}
|
|
}
|
|
}
|
|
|
|
public class ItemTooltipContext : UIContext
|
|
{
|
|
public ItemBasicTooltipContext BasicContext { get; private set; }
|
|
public ItemDetailTooltipContext DetailContext { get; private set; }
|
|
public Vector3 TargetPos { get; set; }
|
|
|
|
public ItemTooltipContext()
|
|
{
|
|
TargetPos = Vector3.zero;
|
|
BasicContext = new ItemBasicTooltipContext();
|
|
DetailContext = new ItemDetailTooltipContext();
|
|
}
|
|
|
|
public ItemTooltipContext(ItemTooltipRawData rawData) : this()
|
|
{
|
|
if (rawData == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
TargetPos = rawData.TargetPos;
|
|
BasicContext = new ItemBasicTooltipContext(rawData);
|
|
DetailContext = new ItemDetailTooltipContext(rawData);
|
|
}
|
|
}
|
|
}
|