Example #1
0
 // Use this for initialization
 override public void Show()
 {
     round.guesses.Clear();
     characterImage.sprite = players.CurrentPlayer().character.charSprite;
     nameField.text        = players.CurrentPlayer().name;
     base.Show();
     Restart();
     StartCountdown();
 }
Example #2
0
 // Update is called once per frame
 public void OnEnable()
 {
     if (players.CurrentPlayer() == null)
     {
         return;
     }
     roundText.text        = string.Format(formatStr, round.roundNum);
     characterImage.sprite = players.CurrentPlayer().character.charSprite;
     playerNameField.text  = players.CurrentPlayer().name;
 }
Example #3
0
 override public void Show()
 {
     waveform.gameObject.SetActive(true);
     if (players.NumPlayers() > 1 && iterator.CurrentPlayer() == players.CurrentPlayer())
     {
         iterator.NextPlayer();
     }
     base.Show();
     playerNameField.text  = iterator.CurrentPlayer().name;
     characterImage.sprite = iterator.CurrentPlayer().character.charSprite;
     phraseInput.text      = "";
 }
Example #4
0
        public void CalculateScores()
        {
            string answer      = gameState.currentQuestions.CurrentQuestion().answer;
            int    maxDistance = answer.Length;

            int numPlayers = players.NumPlayers();

            int        j = 0;
            Player     speakingPlayer     = players.CurrentPlayer();
            ScorePanel speakingScorePanel = null;

            int pointsForSpeaker = 0;

            for (int i = 0; i < numPlayers; i++)
            {
                Player player = players.GetPlayerAt(i);
                int    score  = 0;

                ScorePanel newPanel = Instantiate <ScorePanel>(scorePanel, scoreBoardContainer);

                if (player == speakingPlayer && numPlayers > 1)
                {
                    speakingScorePanel = newPanel;
                }
                else
                {
                    int playerDistance = round.guesses[j].LevenshteinDistance(answer);

                    float percent = Mathf.Clamp01((1f - (1f * playerDistance / maxDistance)));

                    score         = Mathf.RoundToInt(percent * 100);
                    player.score += score;

                    if (score >= 50)
                    {
                        pointsForSpeaker += settings.speakerPointBonus;
                    }

                    j += 1;
                }

                newPanel.charImg.sprite      = player.character.charSprite;
                newPanel.playerName.text     = player.name;
                newPanel.scoreThisRound.text = score.ToString();
                newPanel.totalScore.text     = player.score.ToString();
            }

            if (speakingScorePanel != null)
            {
                speakingPlayer.score += pointsForSpeaker;

                speakingScorePanel.background.color    = settings.speakerPanelColor;
                speakingScorePanel.scoreThisRound.text = pointsForSpeaker.ToString();
                speakingScorePanel.totalScore.text     = speakingPlayer.score.ToString();
            }
        }
Example #5
0
        public void GetWinner()
        {
            players.FirstPlayer();

            Player maxScorePlayer = players.CurrentPlayer();

            for (int i = 0; i < players.NumPlayers(); i++)
            {
                Player player = players.GetPlayerAt(i);

                if (maxScorePlayer.score < player.score)
                {
                    maxScorePlayer = player;
                }
            }

            winner = maxScorePlayer;
        }