加入用户最近100场战绩记录并实现展示

This commit is contained in:
FloatGaming
2026-03-16 23:18:58 +08:00
parent ec42f2e34b
commit f5c6f143c0
106 changed files with 12120 additions and 642 deletions
+2 -2
View File
@@ -5925,7 +5925,7 @@ MonoBehaviour:
m_HandleRect: {fileID: 946030816342223727}
m_Direction: 0
m_Value: 0
m_Size: 0.99999994
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
m_PersistentCalls:
@@ -6659,7 +6659,7 @@ MonoBehaviour:
m_Direction: 2
m_Value: 0
m_Size: 1
m_NumberOfSteps: 11
m_NumberOfSteps: 1
m_OnValueChanged:
m_PersistentCalls:
m_Calls: []
+19 -8
View File
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
[CreateAssetMenu(fileName = "77xxx_storeItem", menuName = "Store/StoreItem")]
public class storeItemSO : ScriptableObject
@@ -8,20 +9,23 @@ public class storeItemSO : ScriptableObject
public string itemName;
public Sprite itemIcon;
public int itemID; // Unique identifier for the item
public int itemSinglePurchaseQty; // 物品单次购买数量
public int itemPurchaseQuota; // 物品限购配额,-1为不限购
public int itemSinglePurchaseQty; // 物品单次购买数量
public int itemPurchaseQuota; // 物品限购配额,-1为不限购
[TextArea(3, 3)] public string itemDescription;
[TextArea(3, 10)] public string itemDetailedDescription; // 这个是用来在物品详情界面显示的更详细的描述文本的
[TextArea(3, 10)] public string itemDetailedDescription; // 这个是用来在物品详情界面显示的更详细的描述文本的
[Header("Item Type")]
public bool isOnShelf = true; // Indicates if the item is currently available for purchase
public bool canbepurchased = true; // Indicates if the item can be purchased with coins
public bool isHot = false; // Indicates if the item is a hot item (for promotional purposes)
public bool user_has_read = false; // 用户是否已经查看过这个物品
public bool user_has_read = false; // 用户是否已经查看过这个物品
public ItemType itemType;
public Player_SO associatedPlayer; // Only used if itemType is character
[FormerlySerializedAs("associatedPlayer")]
public AllyHero_SO associatedAllyHero; // Only used if itemType is character
public SongData associatedSong; // Only used if itemType is song
public notebook_faterType associatedStoryPassage; // Only used if itemType is storyPassage
public StoryPassageGrantMode storyPassageGrantMode = StoryPassageGrantMode.fatherOnly;
public int associatedStorySonId = -1;
[Header("Purchase Cost")]
public List<CostRequirement> costRequirements = new List<CostRequirement>();
@@ -30,7 +34,7 @@ public class storeItemSO : ScriptableObject
public List<UnlockRequirement> unlockRequirements = new List<UnlockRequirement>();
[Header("Runtime Save Data")]
public int purchasedCount; // 已购数量,会参与持久化
public int purchasedCount; // 已购数量,会参与持久化
public enum ItemType
{
@@ -46,6 +50,14 @@ public class storeItemSO : ScriptableObject
coins,
}
public enum StoryPassageGrantMode
{
fatherOnly,
specificSonOnly,
fatherAndSpecificSon,
allSons
}
public enum RequirementType
{
none,
@@ -68,4 +80,3 @@ public class storeItemSO : ScriptableObject
public int value;
}
}
+26 -14
View File
@@ -9,6 +9,8 @@ public class storeSystem : MonoBehaviour
{
private const string ShowOnlyPurchasablePrefKey = "store.show_only_can_purchase";
private const string SortDropdownPrefKey = "store.sort_dropdown_value";
private const string StoreStateSaveCategory = "store_state";
private const string StoreStateSaveKey = "runtime";
[Header("Player Data")]
[SerializeField] private Player_SO playerData;
@@ -66,7 +68,7 @@ public class storeSystem : MonoBehaviour
private bool suppressAmountInputCallback;
private Color defaultSumCostColor = Color.white;
private string SaveFilePath
private string LegacySaveFilePath
{
get { return Path.Combine(Application.persistentDataPath, "storeSystem_state.json"); }
}
@@ -88,6 +90,7 @@ public class storeSystem : MonoBehaviour
{
PlayerEconomyLedger.EnsureInstance().AttachPlayerData(playerData);
ExpBottleLedger.EnsureInstance().AttachPlayerData(playerData);
StoreOwnershipLedger.EnsureInstance().InitializeIfNeeded();
ResetPriceImageObjects();
LoadFilterPreferences();
SetDefaultToggleState();
@@ -619,6 +622,7 @@ public class storeSystem : MonoBehaviour
{
return itemSO != null
&& itemSO.canbepurchased
&& !IsAssociatedContentUnlocked(itemSO)
&& !IsSoldOut(itemSO)
&& HasCoinRequirement(itemSO);
}
@@ -1019,7 +1023,7 @@ public class storeSystem : MonoBehaviour
}
RegisterPurchasedCount(currentSelectedItem.itemID, grantedCount);
RefreshPurchaseSummary();
RefreshCurrentView();
}
private string GetAmountAndQuotaText(storeItemSO itemSO)
@@ -1060,7 +1064,7 @@ public class storeSystem : MonoBehaviour
private string GetPriceAmountText(storeItemSO itemSO)
{
if (itemSO == null || !itemSO.canbepurchased || !HasCoinRequirement(itemSO))
if (itemSO == null || !itemSO.canbepurchased || IsAssociatedContentUnlocked(itemSO) || !HasCoinRequirement(itemSO))
{
return "不可购买";
}
@@ -1070,7 +1074,7 @@ public class storeSystem : MonoBehaviour
private bool ShouldShowPriceIcon(storeItemSO itemSO)
{
return itemSO != null && itemSO.canbepurchased && HasCoinRequirement(itemSO);
return itemSO != null && itemSO.canbepurchased && !IsAssociatedContentUnlocked(itemSO) && HasCoinRequirement(itemSO);
}
private bool CanPurchaseCurrentSelection(storeItemSO itemSO)
@@ -1091,6 +1095,7 @@ public class storeSystem : MonoBehaviour
private void SetupAvailabilityState(storeItemPrefab itemView, storeItemSO itemSO)
{
bool isSoldOut = IsSoldOut(itemSO);
bool alreadyUnlocked = IsAssociatedContentUnlocked(itemSO);
bool cannotPurchase = !itemSO.canbepurchased;
if (itemView.leftCorner_statusImage != null)
@@ -1100,7 +1105,7 @@ public class storeSystem : MonoBehaviour
if (itemView.lock_cannotClickImage != null)
{
itemView.lock_cannotClickImage.SetActive(isSoldOut || cannotPurchase);
itemView.lock_cannotClickImage.SetActive(isSoldOut || cannotPurchase || alreadyUnlocked);
}
if (itemView.why_cannot_buy != null)
@@ -1109,6 +1114,10 @@ public class storeSystem : MonoBehaviour
{
itemView.why_cannot_buy.text = "已售罄";
}
else if (alreadyUnlocked)
{
itemView.why_cannot_buy.text = "已解锁";
}
else if (cannotPurchase)
{
itemView.why_cannot_buy.text = "物品未上架";
@@ -1138,6 +1147,11 @@ public class storeSystem : MonoBehaviour
return itemSO.purchasedCount >= itemSO.itemPurchaseQuota;
}
private bool IsAssociatedContentUnlocked(storeItemSO itemSO)
{
return StoreOwnershipLedger.EnsureInstance().IsOwned(itemSO);
}
private void HandleItemClicked(storeItemPrefab itemView)
{
if (itemView == null || itemView.thisItemSO == null)
@@ -1232,15 +1246,14 @@ public class storeSystem : MonoBehaviour
{
persistedState = new StoreRuntimeSaveData();
if (!File.Exists(SaveFilePath))
{
return;
}
try
{
var json = File.ReadAllText(SaveFilePath);
var loadedData = JsonUtility.FromJson<StoreRuntimeSaveData>(json);
StoreRuntimeSaveData loadedData;
if (!SecureSaveVault.TryLoadJson(StoreStateSaveCategory, StoreStateSaveKey, out loadedData, LegacySaveFilePath))
{
return;
}
if (loadedData != null && loadedData.entries != null)
{
persistedState = loadedData;
@@ -1307,8 +1320,7 @@ public class storeSystem : MonoBehaviour
try
{
NormalizePersistedEntries();
var json = JsonUtility.ToJson(persistedState, true);
File.WriteAllText(SaveFilePath, json);
SecureSaveVault.SaveJson(StoreStateSaveCategory, StoreStateSaveKey, persistedState, LegacySaveFilePath);
#if UNITY_EDITOR
PersistStateBackToEditorAssets();
#endif