Esempio n. 1
0
 private void SetWinnerToHighestPointEarner()
 {
     // If all of the PlayerSupervisors have equal points, report a tie.
     if (Array.TrueForAll(playerSupervisors, ps => ps.GetPoints() == playerSupervisors[0].GetPoints()))
     {
         gameData.gameResult = $"It's a tie!";
     }
     // Otherwise, report the highest scoring player's name.
     else
     {
         PlayerSupervisor winner = playerSupervisors[0];
         for (int i = 1; i < playerSupervisors.Length; i++)
         {
             if (playerSupervisors[i].GetPoints() > winner.GetPoints())
             {
                 winner = playerSupervisors[i];
             }
         }
         if (winner.GetPlayerType() == PlayerType.Human)
         {
             gameData.gameResult = $"You Win!";
         }
         else
         {
             gameData.gameResult = $"{winner.GetName()} Wins!";
         }
     }
 }
Esempio n. 2
0
 public void UpdateDataLists(bool winStatus, int sec, int ms, int paddleHits, int activeBlocks)
 {
     // append new data to playerData lists at end of game
     gameScoresList.Add(playerSupervisor.GetPoints());
     blocksBrokenList.Add(startingNumBlocks - activeBlocks);
     gameWinStatusList.Add(winStatus);
     gameTimePlayedList.Add(GetElapsedTimeDouble(sec, ms));
     paddleHitCountList.Add(paddleHits);
 }