Esempio n. 1
0
    // Called when the player dies (game round ends), and adds a record to the player and enemy stats tables
    public void RecordStatsInDatabase()
    {
        DatabaseManager.AddPlayerStatsRecord(gameRoundId, playerDeathPos, playerSurvivalTime, shotsFired, totalScore);

        // If no enemies died in this game round, set these stats to -1
        float avgEnemySecondsSurvived = -1f;
        float avgEnemyKillDistance    = -1f;

        if (totalEnemiesKilled > 0)
        {
            avgEnemySecondsSurvived = enemySurvivalTimeSum / totalEnemiesKilled;
            avgEnemyKillDistance    = enemyKillDistanceSum / totalEnemiesKilled;
        }

        DatabaseManager.AddEnemyStatsRecord(gameRoundId, avgEnemySecondsSurvived, avgEnemyKillDistance, totalEnemiesKilled);
    }