Exemplo n.º 1
0
    void InitializeStats()
    {
        //if (playerServerStats == null)
        //{
        playerServerStats = new List <PlayerServerStats>();
        //}

        foreach (PlayerSoul p in playerSouls)
        {
            if (p != null)
            {
                PlayerServerStats s = new PlayerServerStats(p.gameObject);
                playerServerStats.Add(s);
                p.GetComponent <PlayerSoul>().stats = s;
            }
        }

        foreach (PlayerSoul p in playerSouls)
        {
            if (p != null)
            {
                NetworkInstanceId[] playerIds = new NetworkInstanceId[playerServerStats.Count];
                int[] scores = new int[playerServerStats.Count];

                for (int i = 0; i < playerServerStats.Count; i++)
                {
                    playerIds[i] = playerServerStats[i].playerId;
                    scores[i]    = playerServerStats[i].score;
                }

                RpcInitLocalStats(playerIds, scores);
            }
        }
    }
Exemplo n.º 2
0
        public PlayerStats GetPlayerStats(Player player)
        {
            var playerStats = new PlayerStats();
            var statistics  = player.Statistics;

            playerStats.TotalMatchesPlayed = statistics.TotalMatchesPlayed;
            playerStats.TotalMatchesWon    = statistics.TotalMatchesWon;

            playerStats.FavoriteServer = PlayerServerStats.GetFavoriteServerForPlayer(player).Endpoint;
            playerStats.UniqueServers  = statistics.ServersStats.Count;

            playerStats.FavoriteGameMode = PlayerGameModeStats.GetFavoriteGameModeForPlayer(player).Name;

            playerStats.AverageScoreboardPercent = statistics.SumOfScoreboardPercents / playerStats.TotalMatchesPlayed;

            playerStats.MaximumMatchesPerDay = DatePlayerStats.GetMostPopularDayForPlayer(player).MatchesPlayed;

            var totalDays = TimeHelper.GetUtcNumberOfDaysBetween(statistics.FirstMatchTimestamp,
                                                                 Matches.GetLastMatchTimestampAmongAllServers());

            playerStats.AverageMatchesPerDay = (double)playerStats.TotalMatchesPlayed / totalDays;

            playerStats.LastMatchPlayed = statistics.LastMatchTimestamp.ToUniversalTime();

            playerStats.KillToDeathRatio = statistics.KillToDeathRatio;

            return(playerStats);
        }
Exemplo n.º 3
0
    public void CmdPlayerKilled(NetworkInstanceId deadPlayer, NetworkInstanceId killer)
    {
        PlayerServerStats k = FindStatsByID(killer);
        PlayerServerStats d = FindStatsByID(deadPlayer);

        k.score += 1;
        RpcUpdateScore(k.playerId, k.score);

        d.respawnTimer = GetRespawnTime();
    }
Exemplo n.º 4
0
    void CheckForWinner()
    {
        PlayerServerStats winner = null;

        foreach (PlayerServerStats p in playerServerStats)
        {
            if (p.score >= GetKillsToWin())
            {
                winner = p;
            }
        }
        if (winner == null)
        {
            return;
        }
        else
        {
            EndRound(true, winner);
        }
    }
Exemplo n.º 5
0
    void EndRound(bool roundWon, PlayerServerStats winningPlayer)
    {
        Debug.Log("Ending game");
        //gameRunning = false;
        roundStatus    = RoundStatus.PostRound;
        PostRoundTimer = PostRoundScoreboardTime;
        if (roundWon)
        {
            RpcDisplayWinner(winningPlayer);
        }
        else
        {
            RpcDisplayNoWinner();
        }
        foreach (PlayerSoul p in playerSouls)
        {
            if (p != null)
            {
                p.CmdDestroyCharacterObject();
            }
        }

        RpcEndRound();
    }
Exemplo n.º 6
0
 public void RpcDisplayWinner(PlayerServerStats winner)
 {
     winnerText.GetComponent <Text>().text = winner.playerId + " won!";
 }