替换玩家模型素材,添加 ChildrenMap 配置挂点
This commit is contained in:
@@ -15,6 +15,7 @@ namespace SepCore.UI
|
||||
public string Description;
|
||||
public int Price;
|
||||
public bool ShowRecycleButton;
|
||||
public bool ShowCombineButton;
|
||||
|
||||
public ItemBasicTooltipContext()
|
||||
{
|
||||
@@ -27,6 +28,7 @@ namespace SepCore.UI
|
||||
Description = string.Empty;
|
||||
Price = 0;
|
||||
ShowRecycleButton = false;
|
||||
ShowCombineButton = false;
|
||||
}
|
||||
|
||||
public ItemBasicTooltipContext(ItemTooltipRawData rawData) : this()
|
||||
@@ -41,6 +43,7 @@ namespace SepCore.UI
|
||||
Rarity = rawData.Rarity;
|
||||
Price = rawData.Price;
|
||||
ShowRecycleButton = rawData.OnRecycle != null;
|
||||
ShowCombineButton = rawData.CanCombine;
|
||||
|
||||
if (ItemType == ItemType.Weapon && rawData.WeaponData != null)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace SepCore.UI
|
||||
protected override UIFormType UIFormType => UIFormType.ItemTooltipForm;
|
||||
|
||||
private Action<int, int> _onRecycle;
|
||||
private Action<int> _onCombine;
|
||||
|
||||
private bool _subscribed = false;
|
||||
|
||||
@@ -19,7 +20,9 @@ namespace SepCore.UI
|
||||
{
|
||||
if (_subscribed) return;
|
||||
GameEntry.Event.Subscribe(ItemTooltipRecycleEventArgs.EventId, ItemTooltipRecycle);
|
||||
GameEntry.Event.Subscribe(ItemTooltipCombineEventArgs.EventId, ItemTooltipCombine);
|
||||
GameEntry.Event.Subscribe(ItemTooltipHideEventArgs.EventId, ItemTooltipHide);
|
||||
GameEntry.Event.Subscribe(DisplayItemLockEventArgs.EventId, DisplayItemLock);
|
||||
_subscribed = true;
|
||||
}
|
||||
|
||||
@@ -27,7 +30,9 @@ namespace SepCore.UI
|
||||
{
|
||||
if (!_subscribed) return;
|
||||
GameEntry.Event.Unsubscribe(ItemTooltipRecycleEventArgs.EventId, ItemTooltipRecycle);
|
||||
GameEntry.Event.Unsubscribe(ItemTooltipCombineEventArgs.EventId, ItemTooltipCombine);
|
||||
GameEntry.Event.Unsubscribe(ItemTooltipHideEventArgs.EventId, ItemTooltipHide);
|
||||
GameEntry.Event.Unsubscribe(DisplayItemLockEventArgs.EventId, DisplayItemLock);
|
||||
_subscribed = false;
|
||||
}
|
||||
|
||||
@@ -75,12 +80,14 @@ namespace SepCore.UI
|
||||
}
|
||||
|
||||
_onRecycle = rawData.OnRecycle;
|
||||
_onCombine = rawData.OnCombine;
|
||||
await OpenFormAsync(context, timeout);
|
||||
}
|
||||
|
||||
public override async UniTask CloseUIAsync(object userData = null, float timeout = 30f)
|
||||
{
|
||||
_onRecycle = null;
|
||||
_onCombine = null;
|
||||
await base.CloseUIAsync(userData, timeout);
|
||||
}
|
||||
|
||||
@@ -94,6 +101,19 @@ namespace SepCore.UI
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
private void DisplayItemLock(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not DisplayItemLockEventArgs)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (Form != null && Form.Visible)
|
||||
{
|
||||
Form.SetMaskEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ItemTooltipRecycle(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not ItemTooltipRecycleEventArgs args)
|
||||
@@ -104,6 +124,16 @@ namespace SepCore.UI
|
||||
_onRecycle?.Invoke(args.Index, args.Price);
|
||||
}
|
||||
|
||||
private void ItemTooltipCombine(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not ItemTooltipCombineEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_onCombine?.Invoke(args.Index);
|
||||
}
|
||||
|
||||
private void ItemTooltipHide(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not ItemTooltipHideEventArgs args) return;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using SepCore.Event;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.UI
|
||||
@@ -14,10 +15,16 @@ namespace SepCore.UI
|
||||
private ItemTooltipContext _context;
|
||||
private Vector3 _targetPos;
|
||||
|
||||
public void SetMaskEnabled(bool enabled)
|
||||
{
|
||||
View.maskImage.enabled = enabled;
|
||||
}
|
||||
|
||||
public void RefreshUI(ItemTooltipContext context)
|
||||
{
|
||||
_context = context;
|
||||
_targetPos = ConvertWorldToAnchored(_context.TargetPos);
|
||||
View.maskImage.enabled = false;
|
||||
|
||||
foreach (RarityPanel panel in _rarityPanels)
|
||||
{
|
||||
@@ -54,6 +61,7 @@ namespace SepCore.UI
|
||||
|
||||
protected override void OnClose(bool isShutdown, object userData)
|
||||
{
|
||||
View.maskImage.enabled = false;
|
||||
_context = null;
|
||||
base.OnClose(isShutdown, userData);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace SepCore.UI
|
||||
public partial class ItemTooltipView : MonoBehaviour
|
||||
{
|
||||
[SerializeField] public global::UnityEngine.RectTransform contentRectTransform;
|
||||
[SerializeField] public global::UnityEngine.UI.Image maskImage;
|
||||
[SerializeField] public global::SepCore.UI.ItemBasicTooltipForm basicForm;
|
||||
[SerializeField] public global::SepCore.UI.ItemDetailTooltipForm detailForm;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user