养成基本完毕,新UI,修bug,装备初步,

This commit is contained in:
FloatGaming
2026-03-23 22:37:14 +08:00
parent 49e45ac464
commit dd205b6cb4
2349 changed files with 261722 additions and 283 deletions
@@ -3,6 +3,13 @@ using UnityEngine;
public static class StoreExpBottlePurchaseService
{
private enum ConsumableGrantType
{
None,
ExpBottle,
GrowthMaterial
}
public static bool TryPurchase(Player_SO playerData, storeItemSO itemSO, int packageCount, out string failureMessage, out int grantedCount)
{
failureMessage = string.Empty;
@@ -127,10 +134,12 @@ public static class StoreExpBottlePurchaseService
switch (itemSO.itemType)
{
case storeItemSO.ItemType.consumable:
ConsumableGrantType grantType;
ExpBottleKind bottleKind;
if (!StoreExpBottleGrantResolver.TryResolve(itemSO, out bottleKind))
DushMaterialKind materialKind;
if (!TryResolveConsumableGrant(itemSO, out grantType, out bottleKind, out materialKind))
{
failureMessage = "当前仅支持经验瓶发放";
failureMessage = "当前未配置发放逻辑";
return false;
}
return true;
@@ -158,16 +167,31 @@ public static class StoreExpBottlePurchaseService
switch (itemSO.itemType)
{
case storeItemSO.ItemType.consumable:
ConsumableGrantType grantType;
ExpBottleKind bottleKind;
if (!StoreExpBottleGrantResolver.TryResolve(itemSO, out bottleKind))
DushMaterialKind materialKind;
if (!TryResolveConsumableGrant(itemSO, out grantType, out bottleKind, out materialKind))
{
failureMessage = "当前仅支持经验瓶发放";
failureMessage = "当前未配置发放逻辑";
return false;
}
ExpBottleLedger.EnsureInstance().AttachPlayerData(playerData);
ExpBottleLedger.EnsureInstance().Add(bottleKind, grantedCount);
return true;
if (grantType == ConsumableGrantType.ExpBottle)
{
ExpBottleLedger.EnsureInstance().AttachPlayerData(playerData);
ExpBottleLedger.EnsureInstance().Add(bottleKind, grantedCount);
return true;
}
if (grantType == ConsumableGrantType.GrowthMaterial)
{
DushMaterialLedger.EnsureInstance().AttachPlayerData(playerData);
DushMaterialLedger.EnsureInstance().Add(materialKind, grantedCount);
return true;
}
failureMessage = "当前未配置发放逻辑";
return false;
case storeItemSO.ItemType.character:
case storeItemSO.ItemType.song:
@@ -197,6 +221,25 @@ public static class StoreExpBottlePurchaseService
return;
}
ConsumableGrantType grantType;
ExpBottleKind bottleKind;
DushMaterialKind materialKind;
if (!TryResolveConsumableGrant(itemSO, out grantType, out bottleKind, out materialKind))
{
Debug.Log(builder.ToString());
return;
}
if (grantType == ConsumableGrantType.GrowthMaterial)
{
builder.Append(" | 突破材料库存=");
builder.Append(DushMaterialCatalog.GetDisplayName(materialKind));
builder.Append(":");
builder.Append(DushMaterialLedger.EnsureInstance().GetCount(materialKind));
Debug.Log(builder.ToString());
return;
}
var snapshot = ExpBottleLedger.EnsureInstance().GetSnapshot();
builder.Append(" | 经验瓶库存:");
@@ -223,4 +266,38 @@ public static class StoreExpBottlePurchaseService
Debug.Log(builder.ToString());
}
private static bool TryResolveConsumableGrant(storeItemSO itemSO, out ConsumableGrantType grantType, out ExpBottleKind bottleKind, out DushMaterialKind materialKind)
{
grantType = ConsumableGrantType.None;
bottleKind = default(ExpBottleKind);
materialKind = default(DushMaterialKind);
if (itemSO == null)
{
return false;
}
if (itemSO.associatedExpBottle != null)
{
grantType = ConsumableGrantType.ExpBottle;
bottleKind = itemSO.associatedExpBottle.bottleKind;
return true;
}
if (itemSO.associatedGrowthMaterial != null)
{
grantType = ConsumableGrantType.GrowthMaterial;
materialKind = itemSO.associatedGrowthMaterial.materialKind;
return true;
}
if (StoreExpBottleGrantResolver.TryResolve(itemSO, out bottleKind))
{
grantType = ConsumableGrantType.ExpBottle;
return true;
}
return false;
}
}