Exemplo n.º 1
0
    void WinsInARow(WhichPlayer whichPlayerWon)
    {
        if (whichPlayerWon == WhichPlayer.Draw || whichPlayerWon == WhichPlayer.None)
        {
            previousWinner = WhichPlayer.None;

            foreach (KeyValuePair <string, PlayerStats> p in playersStats)
            {
                p.Value.playersStats[WhichStat.WinsInARow.ToString()] = 0;
            }

            mostWinsInARowPlayer = whichPlayerWon;
            winsInARowNumber     = 0;
        }
        else
        {
            if (previousWinner == WhichPlayer.None)
            {
                previousWinner = whichPlayerWon;

                playersStats[whichPlayerWon.ToString()].playersStats[WhichStat.WinsInARow.ToString()] = 1;
            }
            else if (previousWinner == whichPlayerWon)
            {
                foreach (KeyValuePair <string, PlayerStats> p in playersStats)
                {
                    if (p.Key != whichPlayerWon.ToString())
                    {
                        p.Value.playersStats["WinsInARow"] = 0;
                    }
                }

                if (playersStats[whichPlayerWon.ToString()].playersStats["WinsInARow"] == 0)
                {
                    playersStats[whichPlayerWon.ToString()].playersStats["WinsInARow"] = 2;
                }
                else
                {
                    playersStats[whichPlayerWon.ToString()].playersStats["WinsInARow"]++;
                }
            }
            else if (previousWinner != whichPlayerWon)
            {
                previousWinner = whichPlayerWon;

                foreach (KeyValuePair <string, PlayerStats> p in playersStats)
                {
                    if (p.Key != whichPlayerWon.ToString())
                    {
                        p.Value.playersStats["WinsInARow"] = 0;
                    }
                }

                playersStats[whichPlayerWon.ToString()].playersStats["WinsInARow"]++;
            }

            mostWinsInARowPlayer = whichPlayerWon;
            winsInARowNumber     = playersStats[whichPlayerWon.ToString()].playersStats[WhichStat.WinsInARow.ToString()];
        }
    }
Exemplo n.º 2
0
    void PlayerStats()
    {
        if (StatsManager.Instance.playersStats.Count == 0 || !StatsManager.Instance.playersStats.ContainsKey(whichPlayer.ToString()) || StatsManager.Instance.playersStats[whichPlayer.ToString()].playersStats.Count == 0)
        {
            return;
        }

        var statsDictionnary = StatsManager.Instance.overallStats ? StatsManager.Instance.playersTotalStats : StatsManager.Instance.playersStats;

        if (changeColor)
        {
            textComponent.color = GlobalVariables.Instance.playersColors[(int)whichPlayer];
        }

        if (whichStat != WhichStat.LifeDuration)
        {
            string text = StatsManager.Instance.statsText.FirstOrDefault(x => x.Value == whichStat).Key;
            textComponent.text = text;

            GlobalMethods.Instance.ReplaceInText(textComponent,
                                                 statsDictionnary[((WhichPlayer)whichPlayer).ToString()].playersStats[whichStat.ToString()].ToString());
        }
        else
        {
            LifeDuration();
        }
    }
Exemplo n.º 3
0
    public void Winner(WhichPlayer whichPlayerWon)
    {
        winnerName = whichPlayerWon;
        WinsInARow(whichPlayerWon);

        playersStats[whichPlayerWon.ToString()].playersStats[WhichStat.Wins.ToString()]++;

        SetAllRoundsDuration();
        PlayersLifeDuration();

        UpdateStats();

        switch (whichPlayerWon)
        {
        case WhichPlayer.Player1:
            winner = "Player 1";
            break;

        case WhichPlayer.Player2:
            winner = "Player 2";
            break;

        case WhichPlayer.Player3:
            winner = "Player 3";
            break;

        case WhichPlayer.Player4:
            winner = "Player 4";
            break;

        case WhichPlayer.Draw:
            winner = "Draw";
            break;

        case WhichPlayer.None:
            winner = "None";
            break;
        }

        StopAllCoroutines();
    }