diff --git a/Assets/_CompletedAssets/Scripts/Enemy/EnemyHealth.cs b/Assets/_CompletedAssets/Scripts/Enemy/EnemyHealth.cs index 6e3702fb03239f1778b6022e4263e0f88603216d..b80ffeee222383eed361eaa3361edd0b0d57409e 100644 --- a/Assets/_CompletedAssets/Scripts/Enemy/EnemyHealth.cs +++ b/Assets/_CompletedAssets/Scripts/Enemy/EnemyHealth.cs @@ -18,7 +18,7 @@ namespace CompleteProject CapsuleCollider capsuleCollider; // Reference to the capsule collider. bool isDead; // Whether the enemy is dead. bool isSinking; // Whether the enemy has started sinking through the floor. - public static int deathCount; // The amount of death count. + // public static int deathCount; // The amount of death count. void Awake() @@ -34,7 +34,7 @@ namespace CompleteProject currentHealth = startingHealth; // reset death count - deathCount = 0; + // deathCount = 0; } @@ -132,7 +132,9 @@ namespace CompleteProject public void deathCountIncrement() { - deathCount++; + int deathCount = PlayerPrefs.GetInt("DeathCount", 0); + PlayerPrefs.SetInt("DeathCount", deathCount + 1); + // deathCount++; Debug.Log("EnemyHealth::deathCountIncrement deathCount: " + deathCount); } } diff --git a/Assets/_CompletedAssets/Scripts/MainMenu/MainMenu.cs b/Assets/_CompletedAssets/Scripts/MainMenu/MainMenu.cs index f6fa7df1c099d770f84a78f316bbca88333f034d..16a2c8da948800f9870cfe90415aaaac426fadbc 100644 --- a/Assets/_CompletedAssets/Scripts/MainMenu/MainMenu.cs +++ b/Assets/_CompletedAssets/Scripts/MainMenu/MainMenu.cs @@ -21,6 +21,7 @@ public class MainMenu : MonoBehaviour PlayerPrefs.SetInt(Statistics.MoneyCollected, 0); PlayerPrefs.SetInt(Statistics.TotalScore, 0); PlayerPrefs.SetInt(Statistics.OrbCollected, 0); + PlayerPrefs.SetInt("DeathCount", 0); PlayerPrefs.Save(); } diff --git a/Assets/_CompletedAssets/Scripts/Managers/StatisticManager.cs b/Assets/_CompletedAssets/Scripts/Managers/StatisticManager.cs index cecfc90be0f8ea22de7541759c0c35335a6c4a36..3c7785b8179fdfe3852283e7719406b972e5dd5d 100644 --- a/Assets/_CompletedAssets/Scripts/Managers/StatisticManager.cs +++ b/Assets/_CompletedAssets/Scripts/Managers/StatisticManager.cs @@ -43,12 +43,12 @@ public class StatisticManager : MonoBehaviour shootAccuracy = (shootAccuracy + accuracy) / 2; distanceTravelled = distanceTravelled + playerMovement.GetDistanceTravelled(); playTime = playTime + sceneStopwatch.GetElapsedTime(); - enemiesKilled = enemiesKilled + EnemyHealth.deathCount; + enemiesKilled = enemiesKilled + PlayerPrefs.GetInt("DeathCount", 0); moneyCollected = moneyCollected + MoneyManager.money; totalScore = totalScore + ScoreManager.score; orbCollected = orbCollected + PlayerPrefs.GetInt("numDamageOrbPicked", 0) + PlayerPrefs.GetInt("numSpeedOrbPicked", 0) + PlayerPrefs.GetInt("numHealthOrbPicked", 0); - Debug.Log("StatisticManager::UpdateData() EnemyHealth.deathCount: " + EnemyHealth.deathCount); + Debug.Log("StatisticManager::UpdateData() EnemyHealth.deathCount: " + PlayerPrefs.GetInt("DeathCount", 0)); PlayerPrefs.SetFloat(Statistics.ShootAccuracy, shootAccuracy); PlayerPrefs.SetFloat(Statistics.DistanceTravelled, distanceTravelled);