装备系统完结,修复并加入很多
This commit is contained in:
@@ -53,7 +53,13 @@ public static class StoreExpBottlePurchaseService
|
||||
}
|
||||
|
||||
var primaryCost = itemSO.costRequirements[0];
|
||||
if (primaryCost.currencyType != storeItemSO.CurrencyType.coins)
|
||||
if (itemSO.associatedSelectableEquipmentRewardSource != null)
|
||||
{
|
||||
failureMessage = "该物品需要通过选择器购买";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!IsSupportedCurrency(primaryCost.currencyType))
|
||||
{
|
||||
failureMessage = "不可购买";
|
||||
return false;
|
||||
@@ -89,13 +95,13 @@ public static class StoreExpBottlePurchaseService
|
||||
PlayerEconomyLedger.EnsureInstance().AttachPlayerData(playerData);
|
||||
StoreOwnershipLedger.EnsureInstance().InitializeIfNeeded();
|
||||
|
||||
if (!PlayerEconomyLedger.EnsureInstance().HasEnoughCoins(totalCost))
|
||||
if (!HasEnoughCurrency(primaryCost.currencyType, totalCost))
|
||||
{
|
||||
failureMessage = "货币不足";
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!PlayerEconomyLedger.EnsureInstance().TrySpendCoins(totalCost))
|
||||
if (!TrySpendCurrency(primaryCost.currencyType, totalCost))
|
||||
{
|
||||
failureMessage = "货币不足";
|
||||
return false;
|
||||
@@ -103,7 +109,7 @@ public static class StoreExpBottlePurchaseService
|
||||
|
||||
if (!GrantPurchasedItem(playerData, itemSO, grantedCount, out failureMessage))
|
||||
{
|
||||
PlayerEconomyLedger.EnsureInstance().AddCoins(totalCost);
|
||||
RefundCurrency(primaryCost.currencyType, totalCost);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -328,4 +334,49 @@ public static class StoreExpBottlePurchaseService
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool IsSupportedCurrency(storeItemSO.CurrencyType currencyType)
|
||||
{
|
||||
return currencyType == storeItemSO.CurrencyType.coins
|
||||
|| currencyType == storeItemSO.CurrencyType.material;
|
||||
}
|
||||
|
||||
private static bool HasEnoughCurrency(storeItemSO.CurrencyType currencyType, int amount)
|
||||
{
|
||||
switch (currencyType)
|
||||
{
|
||||
case storeItemSO.CurrencyType.coins:
|
||||
return PlayerEconomyLedger.EnsureInstance().HasEnoughCoins(amount);
|
||||
case storeItemSO.CurrencyType.material:
|
||||
return PlayerEconomyLedger.EnsureInstance().HasEnoughMaterial(amount);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool TrySpendCurrency(storeItemSO.CurrencyType currencyType, int amount)
|
||||
{
|
||||
switch (currencyType)
|
||||
{
|
||||
case storeItemSO.CurrencyType.coins:
|
||||
return PlayerEconomyLedger.EnsureInstance().TrySpendCoins(amount);
|
||||
case storeItemSO.CurrencyType.material:
|
||||
return PlayerEconomyLedger.EnsureInstance().TrySpendMaterial(amount);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static void RefundCurrency(storeItemSO.CurrencyType currencyType, int amount)
|
||||
{
|
||||
switch (currencyType)
|
||||
{
|
||||
case storeItemSO.CurrencyType.coins:
|
||||
PlayerEconomyLedger.EnsureInstance().AddCoins(amount);
|
||||
break;
|
||||
case storeItemSO.CurrencyType.material:
|
||||
PlayerEconomyLedger.EnsureInstance().AddMaterial(amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user