替换玩家模型素材,添加 ChildrenMap 配置挂点
This commit is contained in:
+16
-1
@@ -27,6 +27,7 @@ namespace SepCore.UI
|
||||
View.infoText.text = _context.Description;
|
||||
View.textFormatText.Set(_context.Price);
|
||||
View.recycleButton.gameObject.SetActive(_context.ShowRecycleButton);
|
||||
View.combineButton.gameObject.SetActive(_context.ShowCombineButton);
|
||||
View.iconArea.SetRarity(_context.Rarity);
|
||||
|
||||
ResizeToFitContent();
|
||||
@@ -54,6 +55,14 @@ namespace SepCore.UI
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCombineButtonClick()
|
||||
{
|
||||
if (_context != null)
|
||||
{
|
||||
GameEntry.Event.Fire(this, ItemTooltipCombineEventArgs.Create(_context.Index));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnCancelButtonClick()
|
||||
{
|
||||
GameEntry.Event.Fire(this, ItemTooltipHideEventArgs.Create());
|
||||
@@ -68,6 +77,7 @@ namespace SepCore.UI
|
||||
|
||||
_listenersBound = true;
|
||||
View.recycleButton.onClick.AddListener(OnRecycleButtonClick);
|
||||
View.combineButton.onClick.AddListener(OnCombineButtonClick);
|
||||
View.cancelButton.onClick.AddListener(OnCancelButtonClick);
|
||||
}
|
||||
|
||||
@@ -83,7 +93,12 @@ namespace SepCore.UI
|
||||
descriptionSize.y = View.infoText.preferredHeight;
|
||||
View.infoText.rectTransform.sizeDelta = descriptionSize;
|
||||
float descriptionHeight = Mathf.Max(0f, View.infoText.preferredHeight);
|
||||
float targetHeight = _fixedTopHeight + descriptionHeight + _fixedBottomHeight;
|
||||
float bottomHeight = _fixedBottomHeight;
|
||||
if (_context != null && _context.ShowCombineButton)
|
||||
{
|
||||
bottomHeight += 100f;
|
||||
}
|
||||
float targetHeight = _fixedTopHeight + descriptionHeight + bottomHeight;
|
||||
|
||||
Vector2 size = new Vector2(_fixedWidth, targetHeight);
|
||||
View.contentRectTransform.sizeDelta = size;
|
||||
|
||||
@@ -12,6 +12,7 @@ namespace SepCore.UI
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI typeText;
|
||||
[SerializeField] public global::TMPro.TextMeshProUGUI infoText;
|
||||
[SerializeField] public global::SepCore.UI.CommonButton recycleButton;
|
||||
[SerializeField] public global::SepCore.UI.CommonButton combineButton;
|
||||
[SerializeField] public global::SepCore.UI.FormatTextUI textFormatText;
|
||||
[SerializeField] public global::SepCore.UI.CommonButton cancelButton;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace SepCore.UI
|
||||
GameEntry.Event.Subscribe(DisplayItemHoverEventArgs.EventId, DisplayItemHover);
|
||||
GameEntry.Event.Subscribe(DisplayItemLockEventArgs.EventId, DisplayItemLock);
|
||||
GameEntry.Event.Subscribe(DisplayItemHideEventArgs.EventId, DisplayItemHide);
|
||||
GameEntry.Event.Subscribe(ItemTooltipHideEventArgs.EventId, ItemTooltipHide);
|
||||
GameEntry.Event.Subscribe(PlayerCoinChangeEventArgs.EventId, PlayerCoinChange);
|
||||
GameEntry.Event.Subscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormComplete);
|
||||
}
|
||||
@@ -42,6 +43,7 @@ namespace SepCore.UI
|
||||
GameEntry.Event.Unsubscribe(DisplayItemHoverEventArgs.EventId, DisplayItemHover);
|
||||
GameEntry.Event.Unsubscribe(DisplayItemLockEventArgs.EventId, DisplayItemLock);
|
||||
GameEntry.Event.Unsubscribe(DisplayItemHideEventArgs.EventId, DisplayItemHide);
|
||||
GameEntry.Event.Unsubscribe(ItemTooltipHideEventArgs.EventId, ItemTooltipHide);
|
||||
GameEntry.Event.Unsubscribe(PlayerCoinChangeEventArgs.EventId, PlayerCoinChange);
|
||||
GameEntry.Event.Unsubscribe(OpenUIFormSuccessEventArgs.EventId, OpenUIFormComplete);
|
||||
}
|
||||
@@ -184,6 +186,7 @@ namespace SepCore.UI
|
||||
return false;
|
||||
}
|
||||
|
||||
bool canCombine = _useCase.CanCombineWeapon(index, out _, out _);
|
||||
rawData = new ItemTooltipRawData
|
||||
{
|
||||
TargetPos = targetPos,
|
||||
@@ -193,6 +196,8 @@ namespace SepCore.UI
|
||||
ItemType = ItemType.Weapon,
|
||||
Price = _useCase.CalculateRecyclePrice(weapon.WeaponData.Price),
|
||||
OnRecycle = RecycleWeapon,
|
||||
CanCombine = canCombine,
|
||||
OnCombine = CombineWeapon,
|
||||
LastWaveDamage = weapon.WeaponData.LastWaveDamage,
|
||||
CurrentTagCounts = GetEquippedTagCounts(),
|
||||
};
|
||||
@@ -272,13 +277,40 @@ namespace SepCore.UI
|
||||
return;
|
||||
}
|
||||
|
||||
int currentCount = Mathf.Max(0, Context.WeaponListContext.CurrentCount - 1);
|
||||
Context.WeaponListContext.CurrentCount = currentCount;
|
||||
|
||||
Context.WeaponListContext = BuildDisplayListContext(DisplayListAreaType.Weapon, _rawData.WeaponItems, _rawData.WeaponMaxCount);
|
||||
Context.NeedRefreshWeaponList = true;
|
||||
Context.StatContext = BuildStatContext(_useCase.CreateStatRawData());
|
||||
Context.NeedRefreshStat = true;
|
||||
RefreshUI(Form, Context);
|
||||
_tooltipLocked = false;
|
||||
GameEntry.UIRouter.CloseUIAsync(UIFormType.ItemTooltipForm).Forget();
|
||||
}
|
||||
|
||||
private void CombineWeapon(int index)
|
||||
{
|
||||
OnCombineWeaponAsync(index).Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid OnCombineWeaponAsync(int index)
|
||||
{
|
||||
if (_useCase == null || Context == null)
|
||||
{
|
||||
Log.Error("ShopController.OnCombineWeaponAsync() controller state is invalid.");
|
||||
return;
|
||||
}
|
||||
|
||||
bool success = await _useCase.TryCombineWeaponAsync(index);
|
||||
if (!success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Context.WeaponListContext = BuildDisplayListContext(DisplayListAreaType.Weapon, _rawData.WeaponItems, _rawData.WeaponMaxCount);
|
||||
Context.NeedRefreshWeaponList = true;
|
||||
Context.StatContext = BuildStatContext(_useCase.CreateStatRawData());
|
||||
Context.NeedRefreshStat = true;
|
||||
RefreshUI(Form, Context);
|
||||
_tooltipLocked = false;
|
||||
GameEntry.UIRouter.CloseUIAsync(UIFormType.ItemTooltipForm).Forget();
|
||||
}
|
||||
|
||||
@@ -394,6 +426,13 @@ namespace SepCore.UI
|
||||
RefreshUI(Form, Context);
|
||||
}
|
||||
|
||||
private void ItemTooltipHide(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not ItemTooltipHideEventArgs) return;
|
||||
|
||||
_tooltipLocked = false;
|
||||
}
|
||||
|
||||
private void OpenUIFormComplete(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not OpenUIFormSuccessEventArgs ne) return;
|
||||
|
||||
Reference in New Issue
Block a user