Exemple #1
0
    /// <summary>
    /// Displays all stats.
    /// </summary>
    /// <param name="name">The name of the player.</param>
    /// <param name="type">The type of character the player played.</param>
    /// <param name="stats">All stats of the player.</param>
    public void Set(string name, CharacterType type, string[] stats)
    {
        nameDisplay.text = name;

        playerIcon.sprite = CharacterDict.Instance.GetSpriteForType(type);

        foreach (string stat in stats)
        {
            GameOverStat gos = Instantiate(GameOverScreen.Instance.statPrefab, contentTrans);
            gos.Set(stat);
        }
    }
Exemple #2
0
    public int RemovePlayer(GamePlayerController playerController)
    {
        var stat = new GameOverStat();

        stat.playerName = playerController.GetPlayerName();
        stat.size       = playerController.GetPlayerSize();
        stat.place      = playerList.Count;
        stats.Add(stat);
        playerList.Remove(playerController);
        // Since the leaderboard is only updated when a player is removed
        // detect when the last player is standing and add to the leaderboard
        if (playerList.Count == 1)
        {
            var winner = playerList[0];
            stat            = new GameOverStat();
            stat.playerName = winner.GetPlayerName();
            stat.size       = winner.GetPlayerSize();
            stat.place      = 1;
            stats.Add(stat);
            // last player standing means the game is won and the session should terminate
            networkManager.TerminateSession();
        }
        return(playerList.Count);
    }