功能批量实现 优化 服务端 新浮动小游戏框架 新界面UI
This commit is contained in:
@@ -44,6 +44,7 @@ public sealed class PlayerEconomyLedger : MonoBehaviour
|
||||
Instance = this;
|
||||
DontDestroyOnLoad(gameObject);
|
||||
InitializeIfNeeded();
|
||||
TryAttachDefaultPlayerData();
|
||||
}
|
||||
|
||||
private void OnApplicationPause(bool pauseStatus)
|
||||
@@ -87,6 +88,15 @@ public sealed class PlayerEconomyLedger : MonoBehaviour
|
||||
InitializeIfNeeded();
|
||||
boundPlayerData = playerData;
|
||||
|
||||
if (!loadedFromSave)
|
||||
{
|
||||
payload.coins = Mathf.Max(0, playerData.Coins);
|
||||
payload.material = Mathf.Max(0, playerData.Material);
|
||||
SaveNow();
|
||||
loadedFromSave = true;
|
||||
return;
|
||||
}
|
||||
|
||||
SyncToPlayerData();
|
||||
GlobalAchievementService.EnsureInstance().ReportCurrentCoins(payload.coins);
|
||||
NotifyEconomyChanged();
|
||||
@@ -257,4 +267,14 @@ public sealed class PlayerEconomyLedger : MonoBehaviour
|
||||
OnMaterialChanged(payload.material);
|
||||
}
|
||||
}
|
||||
|
||||
private void TryAttachDefaultPlayerData()
|
||||
{
|
||||
Player_SO player = RuntimeResourcesCache.LoadDefaultPlayerSo();
|
||||
|
||||
if (player != null)
|
||||
{
|
||||
AttachPlayerData(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user