加入武器 tag 的羁绊效果
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
public partial class ItemDetailTooltipForm
|
||||
{
|
||||
[SerializeField] private float _fixedWidth = 420f;
|
||||
[SerializeField] private float _tagCardPadding = 30f;
|
||||
[SerializeField] private float _damageCardPadding = 30f;
|
||||
[SerializeField] private float _cardSpacing = 16f;
|
||||
|
||||
public RectTransform RectTransform => View.contentRectTransform;
|
||||
|
||||
public void RefreshUI(ItemDetailTooltipContext context)
|
||||
{
|
||||
if (context == null || !context.HasAnyContent)
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
gameObject.SetActive(true);
|
||||
|
||||
// 1. Tag 属性卡片
|
||||
View.tagSynergyRoot.gameObject.SetActive(context.HasTagSynergy);
|
||||
if (context.HasTagSynergy)
|
||||
{
|
||||
bool hasTitle = !string.IsNullOrEmpty(context.TagTitle);
|
||||
View.tagTitleText.gameObject.SetActive(hasTitle);
|
||||
if (hasTitle)
|
||||
{
|
||||
View.tagTitleText.text = context.TagTitle;
|
||||
}
|
||||
View.tagTiersText.text = context.TagTiersContent;
|
||||
}
|
||||
|
||||
// 2. 上一轮造成伤害卡片
|
||||
View.lastWaveDamageRoot.gameObject.SetActive(context.HasLastWaveDamage);
|
||||
if (context.HasLastWaveDamage)
|
||||
{
|
||||
View.lastWaveDamageText.text = $"这个武器在上一波敌袭中造成了 <color=#38E038>{context.LastWaveDamage}</color> 伤害";
|
||||
}
|
||||
|
||||
// 3. 强制重算尺寸
|
||||
ResizeToFitContent();
|
||||
}
|
||||
|
||||
public void ResizeToFitContent()
|
||||
{
|
||||
float totalHeight = 0f;
|
||||
int visibleCards = 0;
|
||||
|
||||
if (View.tagSynergyRoot.gameObject.activeSelf)
|
||||
{
|
||||
float titleHeight = 0f;
|
||||
if (View.tagTitleText.gameObject.activeSelf)
|
||||
{
|
||||
View.tagTitleText.ForceMeshUpdate();
|
||||
titleHeight = View.tagTitleText.preferredHeight + 8f;
|
||||
}
|
||||
|
||||
View.tagTiersText.ForceMeshUpdate();
|
||||
float tagTiersHeight = View.tagTiersText.preferredHeight;
|
||||
float tagCardHeight = titleHeight + tagTiersHeight + _tagCardPadding;
|
||||
totalHeight += tagCardHeight;
|
||||
visibleCards++;
|
||||
}
|
||||
|
||||
if (View.lastWaveDamageRoot.gameObject.activeSelf)
|
||||
{
|
||||
View.lastWaveDamageText.ForceMeshUpdate();
|
||||
float damageTextHeight = View.lastWaveDamageText.preferredHeight;
|
||||
float damageCardHeight = damageTextHeight + _damageCardPadding;
|
||||
if (visibleCards > 0)
|
||||
{
|
||||
totalHeight += _cardSpacing;
|
||||
}
|
||||
totalHeight += damageCardHeight;
|
||||
visibleCards++;
|
||||
}
|
||||
|
||||
View.contentRectTransform.sizeDelta = new Vector2(_fixedWidth, Mathf.Max(80f, totalHeight));
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(View.contentRectTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cf21d1b61ba4ee648b4676f28e8167e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,13 @@
|
||||
// <auto-generated />
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public partial class ItemDetailTooltipForm : UGuiForm
|
||||
{
|
||||
[SerializeField] private ItemDetailTooltipView _view = null;
|
||||
|
||||
public ItemDetailTooltipView View => _view;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b50c309a8e2b95b4e8d205dd9a4d9760
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,16 @@
|
||||
// <auto-generated />
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.UI
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
public partial class ItemDetailTooltipView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public global::UnityEngine.RectTransform contentRectTransform;
|
||||
[SerializeField] public global::UnityEngine.RectTransform tagSynergyRoot;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI tagTitleText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI tagTiersText;
|
||||
[SerializeField] public global::UnityEngine.RectTransform lastWaveDamageRoot;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI lastWaveDamageText;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb1d34a67bf82f94db0396a32459f1f7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user