Skip to content
Snippets Groups Projects
Commit 5d2cd25b authored by Zidane Firzatullah's avatar Zidane Firzatullah
Browse files

add final touch for stats

parent 8b7f796d
No related merge requests found
...@@ -88,7 +88,7 @@ public class Gun : MonoBehaviour ...@@ -88,7 +88,7 @@ public class Gun : MonoBehaviour
EnemyManager enemyHealth = hit.collider.GetComponent<EnemyManager>(); EnemyManager enemyHealth = hit.collider.GetComponent<EnemyManager>();
if (enemyHealth != null) if (enemyHealth != null)
{ {
GeneralStatistics.Instance.Kill += 1; GeneralStatistics.Instance.totalHitCount += 1;
enemyHealth.TakeDamage(damage*PlayerManager.PlayerDamageMultiplier, hit.point); enemyHealth.TakeDamage(damage*PlayerManager.PlayerDamageMultiplier, hit.point);
} }
......
...@@ -125,4 +125,9 @@ public class GeneralStatistics : MonoBehaviour ...@@ -125,4 +125,9 @@ public class GeneralStatistics : MonoBehaviour
return (float) totalKillCount / totalDeathCount; return (float) totalKillCount / totalDeathCount;
} }
public float GetAccuracy()
{
return (float) totalHitCount / totalBulletCount;
}
} }
\ No newline at end of file
...@@ -30,7 +30,7 @@ public class StatisticsPage : MonoBehaviour ...@@ -30,7 +30,7 @@ public class StatisticsPage : MonoBehaviour
int seconds = Mathf.FloorToInt(generalStatistics.ElapsedTime % 60); // calculate seconds int seconds = Mathf.FloorToInt(generalStatistics.ElapsedTime % 60); // calculate seconds
time.text = string.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds); time.text = string.Format("{0:00}:{1:00}:{2:00}", hours, minutes, seconds);
travelDistance.text = generalStatistics.TravelDistance.ToString(); travelDistance.text = generalStatistics.TravelDistance.ToString();
accuracy.text = generalStatistics.Accuracy.ToString(); accuracy.text = generalStatistics.GetAccuracy().ToString();
kdr.text = generalStatistics.KillDeathRatio().ToString(); kdr.text = generalStatistics.KillDeathRatio().ToString();
death.text = generalStatistics.Death.ToString(); death.text = generalStatistics.Death.ToString();
kill.text = generalStatistics.Kill.ToString(); kill.text = generalStatistics.Kill.ToString();
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment