增加收获属性逻辑,优化掉落物表现效果
This commit is contained in:
@@ -16,6 +16,7 @@ namespace SepCore.UI
|
||||
public string TypeName;
|
||||
public string Description;
|
||||
public int Price;
|
||||
public bool IsLocked;
|
||||
|
||||
public GoodsItemContext()
|
||||
{
|
||||
@@ -26,6 +27,7 @@ namespace SepCore.UI
|
||||
Price = 0;
|
||||
Icon = null;
|
||||
ItemType = ItemType.Weapon;
|
||||
IsLocked = false;
|
||||
}
|
||||
|
||||
public GoodsItemContext(GoodsItemRawData rawData) : this()
|
||||
@@ -33,6 +35,7 @@ namespace SepCore.UI
|
||||
Price = rawData.Price;
|
||||
Rarity = rawData.Rarity;
|
||||
ItemType = rawData.ItemType;
|
||||
IsLocked = rawData.IsLocked;
|
||||
|
||||
if (ItemType == ItemType.Weapon)
|
||||
{
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace SepCore.UI
|
||||
protected override void SubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Subscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
|
||||
GameEntry.Event.Subscribe(ShopGoodsLockEventArgs.EventId, ShopGoodsLock);
|
||||
GameEntry.Event.Subscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
|
||||
GameEntry.Event.Subscribe(ShopContinueEventArgs.EventId, ShopContinue);
|
||||
GameEntry.Event.Subscribe(DisplayItemHoverEventArgs.EventId, DisplayItemHover);
|
||||
@@ -38,6 +39,7 @@ namespace SepCore.UI
|
||||
protected override void UnsubscribeCustomEvents()
|
||||
{
|
||||
GameEntry.Event.Unsubscribe(ShopRefreshEventArgs.EventId, ShopRefresh);
|
||||
GameEntry.Event.Unsubscribe(ShopGoodsLockEventArgs.EventId, ShopGoodsLock);
|
||||
GameEntry.Event.Unsubscribe(ShopPurchaseEventArgs.EventId, ShopPurchase);
|
||||
GameEntry.Event.Unsubscribe(ShopContinueEventArgs.EventId, ShopContinue);
|
||||
GameEntry.Event.Unsubscribe(DisplayItemHoverEventArgs.EventId, DisplayItemHover);
|
||||
@@ -355,6 +357,27 @@ namespace SepCore.UI
|
||||
ApplyGoodsPurchased(result);
|
||||
}
|
||||
|
||||
private void ShopGoodsLock(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not ShopGoodsLockEventArgs args)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_useCase == null || Context == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
bool isLocked = _useCase.ToggleLock(args.GoodsIndex);
|
||||
if (args.GoodsIndex >= 0 && args.GoodsIndex < Context.GoodsItems.Count && Context.GoodsItems[args.GoodsIndex] != null)
|
||||
{
|
||||
Context.GoodsItems[args.GoodsIndex].IsLocked = isLocked;
|
||||
Context.NeedRefreshGoodsItems = true;
|
||||
RefreshUI(Form, Context);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShopContinue(object sender, GameEventArgs e)
|
||||
{
|
||||
if (e is not ShopContinueEventArgs)
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace SepCore.UI
|
||||
[SerializeField] private TMP_Text _costText;
|
||||
[SerializeField] private CommonButton _purchaseButton = null;
|
||||
[SerializeField] private TMP_Text _purchaseLabel = null;
|
||||
[SerializeField] private CommonButton _lockButton = null;
|
||||
[SerializeField] private TMP_Text _lockLabel = null;
|
||||
[SerializeField] private CanvasGroup _canvasGroup = null;
|
||||
[SerializeField] private RarityPalette _rarityPalette = null;
|
||||
[SerializeField] private Image _rarityBackground = null;
|
||||
@@ -46,6 +48,12 @@ namespace SepCore.UI
|
||||
_typeText.text = data.TypeName;
|
||||
_descriptionText.text = data.Description;
|
||||
_costText.text = $"{data.Price} <sprite name=\"coin\" index=0>";
|
||||
UpdateLockDisplay(data.IsLocked);
|
||||
}
|
||||
|
||||
public void UpdateLockDisplay(bool isLocked)
|
||||
{
|
||||
_lockLabel.text = isLocked ? "已锁定" : "锁定";
|
||||
}
|
||||
|
||||
public void OnReset()
|
||||
@@ -54,6 +62,8 @@ namespace SepCore.UI
|
||||
_data = null;
|
||||
_iconArea.OnReset();
|
||||
SetRarity(Rarity.None);
|
||||
_lockButton.interactable = true;
|
||||
_lockLabel.text = "锁定";
|
||||
}
|
||||
|
||||
public void MarkPurchased()
|
||||
@@ -63,6 +73,8 @@ namespace SepCore.UI
|
||||
_canvasGroup.alpha = 0.5f;
|
||||
_purchaseButton.interactable = false;
|
||||
_purchaseLabel.text = "已购买";
|
||||
_lockButton.interactable = false;
|
||||
_lockLabel.text = "锁定";
|
||||
}
|
||||
|
||||
private void SetRarity(Rarity rarity)
|
||||
@@ -95,6 +107,7 @@ namespace SepCore.UI
|
||||
_listenersBound = true;
|
||||
|
||||
_purchaseButton.onClick.AddListener(OnPurchaseClick);
|
||||
_lockButton.onClick.AddListener(OnLockClick);
|
||||
}
|
||||
|
||||
private void OnPurchaseClick()
|
||||
@@ -106,5 +119,15 @@ namespace SepCore.UI
|
||||
|
||||
GameEntry.Event.Fire(this, ShopPurchaseEventArgs.Create(_index));
|
||||
}
|
||||
|
||||
private void OnLockClick()
|
||||
{
|
||||
if (_index < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
GameEntry.Event.Fire(this, ShopGoodsLockEventArgs.Create(_index));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user