Skip to content

Commit 51006da

Browse files
committed
add: test datas
1 parent 6ad2f49 commit 51006da

File tree

2 files changed

+60
-11
lines changed

2 files changed

+60
-11
lines changed
Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,69 @@
11
using System;
2-
using JetBrains.Annotations;
2+
using UnityEngine;
33

44
namespace Code.Infrastructure.Services.PersistenceProgress.Player
55
{
66
[Serializable]
77
public class PlayerData
88
{
9+
public string PlayerName = "TestPlayer";
10+
public int Level = 5;
11+
public float Health = 82.3f;
12+
public bool HasPremium = true;
13+
public DateTime LastLoginTime = DateTime.Now;
14+
public Vector3 Position = new Vector3(2.5f, 0, -4.3f);
915

10-
[UsedImplicitly]
11-
public PlayerData()
16+
public GameSettings Settings = new GameSettings();
17+
public InventoryData Inventory = new InventoryData();
18+
public QuestProgress[] Quests = new[]
1219
{
13-
14-
}
20+
new QuestProgress { QuestId = "quest_001", IsCompleted = true, Progress = 1.0f },
21+
new QuestProgress { QuestId = "quest_002", IsCompleted = false, Progress = 0.4f }
22+
};
23+
}
24+
25+
[Serializable]
26+
public class GameSettings
27+
{
28+
public float MusicVolume = 0.8f;
29+
public float SfxVolume = 0.5f;
30+
public bool IsVibrationEnabled = true;
31+
public ResolutionSettings Resolution = new ResolutionSettings();
32+
}
33+
34+
[Serializable]
35+
public class ResolutionSettings
36+
{
37+
public int Width = 1920;
38+
public int Height = 1080;
39+
public bool Fullscreen = true;
40+
}
41+
42+
[Serializable]
43+
public class InventoryData
44+
{
45+
public int Coins = 999;
46+
public int Gems = 30;
47+
public InventoryItem[] Items = new[]
48+
{
49+
new InventoryItem { Id = "sword_01", Count = 1 },
50+
new InventoryItem { Id = "shield_02", Count = 1 },
51+
new InventoryItem { Id = "potion_hp", Count = 5 }
52+
};
53+
}
54+
55+
[Serializable]
56+
public class InventoryItem
57+
{
58+
public string Id;
59+
public int Count;
60+
}
61+
62+
[Serializable]
63+
public class QuestProgress
64+
{
65+
public string QuestId;
66+
public bool IsCompleted;
67+
public float Progress;
1568
}
1669
}

Assets/Code/Infrastructure/Services/SaveLoad/SaveLoadService.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using Code.Infrastructure.Services.PersistenceProgress;
33
using Code.Infrastructure.Services.PersistenceProgress.Player;
4-
using Sirenix.OdinInspector;
54
using Sirenix.Serialization;
65
using UnityEngine;
76

@@ -17,11 +16,9 @@ public SaveLoadService(IPersistenceProgressService progressService)
1716
{
1817
_progressService = progressService;
1918
}
20-
21-
[Button]
19+
2220
public void SaveProgress() => Save(_progressService.PlayerData);
23-
24-
[Button]
21+
2522
public void Save(PlayerData playerData)
2623
{
2724
byte[] serializedValue = SerializationUtility.SerializeValue(playerData, DataFormat.JSON);
@@ -30,7 +27,6 @@ public void Save(PlayerData playerData)
3027
PlayerPrefs.Save();
3128
}
3229

33-
[Button]
3430
public PlayerData Load()
3531
{
3632
string base64String = PlayerPrefs.GetString(key: PlayerDataKey, string.Empty);

0 commit comments

Comments
 (0)