Exemplo n.º 1
0
        public void Should_Return_True_If_User_Wants_To_Search_Again()
        {
            var generator = new PlayAgain();

            //act & assert
            //Assert.IsTrue(PlayAgain.PlayAgainLoop());
            Assert.AreEqual(PlayAgain.PlayAgainLoop(), true);
        }
Exemplo n.º 2
0
 static void Main(string[] args)
 {
     do //loop to play again.
     {
         double investment = GetInvestmentAmount();
         double interest   = GetAnnualInerest();
         double term       = GetTermOfInvestment();
         double money      = CalculateInvestment(investment, interest, term);
         DisplayInvestment(money, term);
     } while (PlayAgain.DoPlayAgain());
 }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            int number;

            do
            {
                number = GetPosInts();
                Result(number);
                Console.ReadLine();
            } while (PlayAgain.DoPlayAgain());
        }
Exemplo n.º 4
0
 private void Awake()
 {
     instance      = this;
     playerManager = GetComponentInChildren <PlayerManager>();
     enemy         = GetComponentInChildren <EnnemyController>();
     UI            = transform.Find("UI").gameObject;
     canvas        = UI.transform.Find("Canvas").gameObject;
     timerUI       = canvas.transform.Find("Timer").gameObject;
     playAgainUI   = canvas.transform.Find("PlayAgain").gameObject;
     playAgain     = playAgainUI.GetComponent <PlayAgain>();
 }
Exemplo n.º 5
0
 void Start()
 {
     currentHealth   = totalHealth;
     cameraShaker    = FindObjectOfType <CameraFollow>();
     playAgainCanvas = FindObjectOfType <PlayAgain>();
     score           = FindObjectOfType <Score>();
     clipPlayer      = FindObjectOfType <ClipPlayer>();
     clipAudioSource = clipPlayer.GetComponent <AudioSource>();
     audioSource     = GetComponent <AudioSource>();
     playAgainCanvas.Hide();
 }
Exemplo n.º 6
0
    //public static PlayerManager playerManager;

    private void Awake()
    {
        instance = this;
        //playerManager = GetComponentInChildren<PlayerManager>();
        UI      = transform.Find("UI").gameObject;
        canvas  = UI.transform.Find("Canvas").gameObject;
        timerUI = canvas.transform.Find("Timer").gameObject;
        Debug.Log("BUG : " + timerUI);
        timerUI.GetComponent <TimerUI>().SetManager(this);
        playAgainUI = canvas.transform.Find("PlayAgain").gameObject;
        playAgain   = playAgainUI.GetComponent <PlayAgain>();
        players.AddRange(FindObjectsOfType <Player>());
        alives.AddRange(FindObjectsOfType <Player>());
    }
Exemplo n.º 7
0
    public void EndTimer(bool hasWon)
    {
        playAgainCanvas = FindObjectOfType <PlayAgain>();
        float timeToRecord = currentTime;

        if (timeToRecord < highScore && hasWon)
        {
            highScore = timeToRecord;
        }
        print(highScore);
        playAgainCanvas.currentScore.text = FormatTime(timeToRecord);
        playAgainCanvas.highScore.text    = FormatTime(highScore);
        scoreCanvas.enabled = false;
    }
Exemplo n.º 8
0
        //in/out userScore
        static void UserPlay(ref int userScore)
        {
            //do while with Playagain? return string
            //in/out userScore ref
            //calls Play Again and play again isn't called in Main

            // creates an object called generator that can generate a random number
            Random generator = new Random();
            int    d1, d2;
            bool   playAgain;


            do
            {
                playAgain = false;

                //d1 & d2 random number between 1-6
                d1 = generator.Next(1, 7);
                d2 = generator.Next(1, 7);

                //display rolls, d1 & d2
                Console.WriteLine("Dice 1 rolled: " + d1);
                Console.WriteLine("Dice 2 rolled: " + d2);

                //conditions
                //no 1's rolled
                if (d1 != 1 && d2 != 1)
                {
                    userScore += (d1 + d2);
                    Console.WriteLine("Your score is " + userScore);
                    playAgain = PlayAgain.DoPlayAgain();
                }
                //if user didn't win ask to roll again
                else if (d1 == 1 && d2 == 1)
                {
                    userScore = 0;
                    Console.WriteLine("Your score is " + userScore);
                }
                //display that it's now the computer's turn
                else
                {
                    Console.WriteLine("Your score is " + userScore);
                    //display that it's now the computer's turn
                    Console.WriteLine("It's the computers turn");
                }
            } while (playAgain == true);
        }
Exemplo n.º 9
0
        void ReleaseDesignerOutlets()
        {
            if (FinalScoreLabel != null)
            {
                FinalScoreLabel.Dispose();
                FinalScoreLabel = null;
            }

            if (PlayAgain != null)
            {
                PlayAgain.Dispose();
                PlayAgain = null;
            }

            if (PostScore != null)
            {
                PostScore.Dispose();
                PostScore = null;
            }
        }
Exemplo n.º 10
0
        static void Main(string[] args)
        {
            //local varaibles
            int userWins = 0;
            int computerWins = 0;
            int uNum, d1, d2, winner;

            // creates an object called generator that can generate a random number
            Random generator = new Random();

            do//loop to play again.
            {
                uNum = GetInt("The total of two dice", MIN, MAX);
                int compRand = PlayGame(uNum, out d1, out d2, generator);
                winner = DeterminWinner(uNum, compRand);
                IncrementScores(winner, ref userWins, ref computerWins);
                DisplayWinner(winner); //Mari's says pass ing userWins & ComputerWins
            } while (PlayAgain.DoPlayAgain());


            Console.ReadLine();
        }
Exemplo n.º 11
0
 private void OnClick_Again()
 {
     PlayAgain?.Invoke();
 }
Exemplo n.º 12
0
 public override void Render()
 {
     base.Render();
     PlayAgain.Render();
     QuitButton.Render();
 }
Exemplo n.º 13
0
 private void btn_PlayAgain_Click(object sender, EventArgs e)
 {
     PlayAgain?.Invoke(sender, e);
 }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            Random rnd = new Random();
            int    UserCard1 = rnd.Next(1, 10);
            int    UserCard2 = rnd.Next(1, 10);
            int    DealerCard1 = rnd.Next(1, 10);
            int    DealerCard2 = rnd.Next(1, 10);
            int    HitCard1 = rnd.Next(1, 10);
            int    HitCard2 = rnd.Next(1, 10);
            int    UserSum1, DealerSum1;
            int    UserPot   = 0;
            int    DealerPot = 0;
            string _wager;
            int    wager;
            string PlayAgain;

            //System.Threading.Thread.sleep(20);
            try
            {
                do
                {
                    System.Console.WriteLine("How much would you like to wager?");
                    _wager = System.Console.ReadLine();

                    wager = Int32.Parse(_wager);
                    System.Console.WriteLine($"{wager} Wagered");

                    UserSum1 = UserCard1 + UserCard2;



                    System.Console.WriteLine($"Your Card Count: {UserSum1}");
                    DealerSum1 = DealerCard1 + DealerCard2;
                    System.Console.WriteLine($"The Dealers Card Count: {DealerSum1}");

                    System.Threading.Thread.Sleep(20);

                    /*do
                     *  {
                     *      DealerSum1 = DealerSum1 + HitCard1;
                     *      System.Console.WriteLine($"Dealer Card Count: {DealerSum1}");
                     *  } while (DealerSum1 <= 17);*/

                    System.Console.WriteLine("Hit?  (Y/N)");
                    string hit = System.Console.ReadLine();
                    if (hit.ToUpper() == "Y")
                    {
                        UserSum1 = UserSum1 + HitCard1;
                        System.Console.WriteLine($"Your Card Count: {UserSum1}");
                        if (DealerSum1 <= 17)
                        {
                            DealerSum1 = DealerSum1 + HitCard2;
                        }
                        //do
                        //{
                        //    DealerSum1 = DealerSum1 + HitCard2;
                        //} while (DealerSum1 <= 17);
                        System.Console.WriteLine($"Dealer Card Count: {DealerSum1}");

                        if ((DealerSum1 > UserSum1) && (DealerSum1 <= 21))
                        {
                            DealerPot = wager + DealerPot;
                        }
                        else
                        {
                            UserPot = wager + UserPot;
                        }
                        //System.Console.WriteLine($"Current User Pot: {UserPot}   Current Dealer Pot: {DealerPot}");
                    }
                    if (hit.ToUpper() == "N")
                    {
                        System.Console.WriteLine($"Your Card Count: {UserSum1}");
                        if (DealerSum1 <= 17)
                        {
                            DealerSum1 = DealerSum1 + HitCard2;
                        }
                        //do
                        //{
                        //    DealerSum1 = DealerSum1 + HitCard2;
                        //} while (DealerSum1 <= 17);
                        System.Console.WriteLine($"Dealer Card Count: {DealerSum1}");

                        if ((DealerSum1 > UserSum1) && (DealerSum1 <= 21))
                        {
                            DealerPot = wager + DealerPot;
                        }
                        else
                        {
                            UserPot = wager + UserPot;
                        }
                    }
                    System.Console.WriteLine($"Current User Pot: {UserPot}   Current Dealer Pot: {DealerPot}");

                    System.Console.WriteLine($"Would you like to play again?  (Y/N)");
                    PlayAgain = System.Console.ReadLine();
                } while (PlayAgain.ToUpper() == "Y");
            }
            catch
            {
            }
        }
        static void Main(string[] args)
        {
            string PlayAgain;

            do
            {
                Console.WriteLine("Input 1 or 2 to Play: \n1: Player VS. Player \n2: Player VS. Computer");
                int MenuInput = Int32.Parse(Console.ReadLine());

                if (MenuInput == 1)
                {
                    Console.WriteLine("Please enter player one's name: ");
                    string PlayerOne = Console.ReadLine();
                    Console.WriteLine(PlayerOne + " You will be playing as 'X' \n\nPlease enter player two's name: ");
                    string PlayerTwo = Console.ReadLine();
                    Console.WriteLine("\n" + PlayerTwo + " You will be playing as 'O'");
                    Human NumOne = new Human('X', PlayerOne);
                    Human NumTwo = new Human('O', PlayerTwo);

                    Controller.PrintGameBoard();

                    for (int i = 1; i <= (Controller.Length * Controller.Width) / 2; i++) // total number of spaces on the game board (divided by two)...if no one wins in 42 turns the game is a tie
                    {
                        NumOne.TakeATurn();
                        if (Controller.CheckWin())
                        {
                            Console.WriteLine("Congratulations " + NumOne.Name + "! You Win!");
                            break;
                        }
                        NumTwo.TakeATurn();
                        if (Controller.CheckWin())
                        {
                            Console.WriteLine("Congratulations " + NumTwo.Name + "! You Win!");
                            break;
                        }
                        if (i == (Controller.Length * Controller.Width) / 2)
                        {
                            Console.WriteLine("This game is a tie!");
                        }
                    }
                }
                else if (MenuInput == 2)
                {
                    Console.WriteLine("Please enter your name: ");
                    string PlayerName = Console.ReadLine();
                    Console.WriteLine(PlayerName + " You will be playing as 'X'");
                    Human    Player = new Human('X', PlayerName);
                    Computer Comp   = new Computer('O');

                    Controller.PrintGameBoard();

                    for (int i = 1; i <= (Controller.Length * Controller.Width) / 2; i++) // total number of spaces on the game board (divided by two)...if no one wins in 42 turns the game is a tie
                    {
                        Player.TakeATurn();
                        if (Controller.CheckWin())
                        {
                            Console.WriteLine("Congratulations " + Player.Name + "! You Win!");
                            break;
                        }
                        Comp.TakeATurn();
                        if (Controller.CheckWin())
                        {
                            Console.WriteLine("The Computer is the winner!");
                            break;
                        }
                        if (i == (Controller.Length * Controller.Width) / 2)
                        {
                            Console.WriteLine("This game is a tie!");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("Invalid Input...Please enter 1 or 2");
                }

                Controller.ResetGameBoard();

                Console.WriteLine("Would you like to play again? (y/n)");
                PlayAgain = Console.ReadLine();
                PlayAgain = PlayAgain.ToUpper();
            } while (PlayAgain == "Y" || PlayAgain == "YES");



            Console.Read();
        }
Exemplo n.º 16
0
 // click of the "Play Again" button that appears when the game is over
 private void PlayAgainButton_Click(object sender, EventArgs e)
 {
     soundClick.Play(); // play a "click" when the button is pressed
     PlayAgain?.Invoke(sender, e);
 }