Exemplo n.º 1
0
    void UpdateText()
    {
        // Sort teams by score
        sortedTeams = scoringHelper.SortTeams(gamestateTracker);

        if (PhotonNetwork.IsMasterClient)
        {
            SpawnPlayerVehicles();
        }

        plinthTexts[0].text = GetTeamName(sortedTeams[0]);
        if (sortedTeams.Count > 1)
        {
            plinthTexts[1].text = GetTeamName(sortedTeams[1]);
        }
        if (sortedTeams.Count > 2)
        {
            plinthTexts[2].text = GetTeamName(sortedTeams[2]);
        }

        string newText = "";

        foreach (TeamEntry team in sortedTeams)
        {
            newText += $"{GetTeamName(team)} -- Score: {scoringHelper.CalcScore(team)} -- Kills: {team.kills} -- Deaths: {team.deaths} -- Gubbins: {team.checkpoint}\n";
        }
        scoreboardText.text = newText;
    }
    public void UpdateScores()
    {
        // Sort teams by score
        List <TeamEntry> sortedTeams = scoringHelper.SortTeams(gamestateTracker);

        // Display teams in order
        for (int i = 0; i < sortedTeams.Count; i++)
        {
            if (sortedTeams[i].name == null)
            {
                PlayerEntry driver = gamestateTracker.players.Get(sortedTeams[i].driverId);
                PlayerEntry gunner = gamestateTracker.players.Get(sortedTeams[i].gunnerId);
                teamPanels[i].TeamName.text = $"{driver.name} + {gunner.name}";
                driver.Release();
                gunner.Release();
            }
            else
            {
                teamPanels[i].TeamName.text = sortedTeams[i].name;
            }
            teamPanels[i].TeamScore.text       = $"Score: {scoringHelper.CalcScore(sortedTeams[i])}";
            teamPanels[i].TeamKDA.text         = $"Kills/Deaths: {sortedTeams[i].kills}/{sortedTeams[i].deaths}";
            teamPanels[i].TeamCheckpoints.text = $"Gubbins: {sortedTeams[i].checkpoint}";
            PlayerEntry player = gamestateTracker.players.Get((short)PhotonNetwork.LocalPlayer.ActorNumber);
            int         teamId = player.teamId;
            player.Release();
            if (teamId == sortedTeams[i].id)
            {
                teamPanels[i].UpdateTransform(true);
            }
            else
            {
                teamPanels[i].UpdateTransform(false);
            }
        }
    }