Skip to content

Commit

Permalink
1.2.1 build. Fixes #2 and several other bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Exenifix committed Jan 31, 2022
1 parent 7c88a73 commit 341f16e
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
8 changes: 4 additions & 4 deletions Assets/Scenes/StartScreen.unity
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 100, y: 100}
m_SizeDelta: {x: 1096.5, y: 1950.2}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &1045523108
GameObject:
Expand Down Expand Up @@ -1546,9 +1546,9 @@ RectTransform:
m_Father: {fileID: 1017433380}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -431, y: 722.33}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 100.35, y: -252.77}
m_SizeDelta: {x: 187.77, y: 187.77}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1452896264
Expand Down
6 changes: 3 additions & 3 deletions Assets/Scripts/StartScreen/StartManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ public void QuitGame()
}

public void ShowStats() {
Dictionary<string, int> stats = GameDataManager.GetLeaderboard();
Dictionary<int, string> stats = GameDataManager.GetLeaderboard();
mainMenu.SetActive(false);
statsMenu.SetActive(true);
string text = "";
if (stats.Count > 0) {
foreach (KeyValuePair<string, int> kvp in stats) {
text += kvp.Key + " -- " + kvp.Value + "\n";
foreach (KeyValuePair<int, string> kvp in stats) {
text += kvp.Value + " -- " + kvp.Key + "\n";
}
} else {
text = "No players lmao";
Expand Down
10 changes: 7 additions & 3 deletions Assets/Scripts/Utility/GameData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,20 @@

[Serializable]
public class GameData {
public Dictionary<string, int> leaderboard;
private static int version = 1;
public Dictionary<int, string> leaderboard;
public int money;
private static readonly string dataPath = Application.persistentDataPath + "/GameData.dat";
private static readonly string dataPath = Application.persistentDataPath + "/GameData1.dat";

private GameData() {
this.money = 0;
this.leaderboard = new Dictionary<string, int>();
this.leaderboard = new Dictionary<int, string>();
}

public static GameData GetFromFile() {
if (File.Exists(Application.persistentDataPath + "/GameData.dat")) {
File.Delete(Application.persistentDataPath + "/GameData.dat");
}
BinaryFormatter bf = new BinaryFormatter();
if (!File.Exists(dataPath)) {
GameData gameData = new GameData();
Expand Down
30 changes: 20 additions & 10 deletions Assets/Scripts/Utility/GameDataManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,18 @@

public static class GameDataManager {
private static GameData gameData = GameData.GetFromFile();
public static Dictionary<string, int> GetLeaderboard() {
return gameData.leaderboard;
public static Dictionary<int, string> GetLeaderboard() {
Dictionary<int, string> dictLeaderboard = new Dictionary<int, string>();
List<KeyValuePair<int, string>> leaderboard = gameData.leaderboard.ToList();
leaderboard.Sort(
delegate(KeyValuePair<int, string> pair1, KeyValuePair<int, string> pair2) {
return pair1.Key.CompareTo(pair2.Key);
}
);
foreach (KeyValuePair<int, string> kvp in leaderboard) {
dictLeaderboard[kvp.Key] = kvp.Value;
}
return dictLeaderboard;
}

public static int GetMoney() {
Expand All @@ -26,16 +36,16 @@ public static void RemoveMoney(int amount) {
}

public static bool IsRecord(int score) {
return GetLowestScore().Value < score || gameData.leaderboard.Count < 10;
return GetLowestScore().Key < score || gameData.leaderboard.Count < 10;
}

public static void AddScore(string name, int score) {
if (gameData.leaderboard.Count > 10) {
KeyValuePair<string, int> lowest = GetLowestScore();
KeyValuePair<int, string> lowest = GetLowestScore();
gameData.leaderboard.Remove(lowest.Key);
}

gameData.leaderboard[name] = score;
gameData.leaderboard[score] = name;
gameData.Save();
}

Expand All @@ -44,13 +54,13 @@ public static void ResetScores() {
gameData.Save();
}

private static KeyValuePair<string, int> GetLowestScore() {
private static KeyValuePair<int, string> GetLowestScore() {
if (gameData.leaderboard.Count == 0) {
return new KeyValuePair<string, int>(null, 0);
return new KeyValuePair<int, string>(0, null);
}
KeyValuePair<string, int> minimum = gameData.leaderboard.First();
foreach (KeyValuePair<string, int> kvp in gameData.leaderboard) {
if (kvp.Value < minimum.Value) {
KeyValuePair<int, string> minimum = gameData.leaderboard.First();
foreach (KeyValuePair<int, string> kvp in gameData.leaderboard) {
if (kvp.Key < minimum.Key) {
minimum = kvp;
}
}
Expand Down
Binary file added Builds/Android/com.exenifix.fnaf69-1.2.1.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 1
bundleVersion: 1.2
bundleVersion: 1.2.1
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0
Expand Down

0 comments on commit 341f16e

Please sign in to comment.