to new git
This commit is contained in:
51
Assets/Scripts/Statistics/StatisticManager.cs
Normal file
51
Assets/Scripts/Statistics/StatisticManager.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using UnityEngine;
|
||||
|
||||
internal class Log
|
||||
{
|
||||
public int damageTakenByDefs = 0;
|
||||
public int damageTakenByAtc = 0;
|
||||
|
||||
public int AtcWin = 0;
|
||||
public int DefWin = 0;
|
||||
|
||||
public int TimeOuts = 0;
|
||||
}
|
||||
|
||||
public class StatisticManager : MonoBehaviour
|
||||
{
|
||||
private Log log = new Log();
|
||||
private void Awake()
|
||||
{
|
||||
foreach (var npc in GameObject.FindObjectsOfType<NPC>())
|
||||
npc.OnDamageRecieved += RegisterDamage;
|
||||
|
||||
GlobalEventManager.onCaptureFlag += RegisterWin;
|
||||
GlobalEventManager.onTimeLeft += RegisterTimeOut;
|
||||
}
|
||||
|
||||
private void RegisterDamage(int damage, Team team)
|
||||
{
|
||||
if (team == Team.Attackers)
|
||||
log.damageTakenByAtc += damage;
|
||||
else
|
||||
log.damageTakenByDefs += damage;
|
||||
}
|
||||
|
||||
private void RegisterWin(Team team)
|
||||
{
|
||||
if (team == Team.Attackers)
|
||||
log.AtcWin += 1;
|
||||
else
|
||||
log.DefWin += 1;
|
||||
}
|
||||
|
||||
private void RegisterTimeOut()
|
||||
{
|
||||
log.TimeOuts += 1;
|
||||
}
|
||||
|
||||
private void OnApplicationQuit()
|
||||
{
|
||||
Logger.SaveLog<Log>(log);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user