コード例 #1
0
        /// <summary>
        /// Handler which takes care of the "shot clock" tick events
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CountdownTimer_Tick(object sender, EventArgs e)
        {
            moveTime--;
            if (moveTime == 0)
            {
                // time is up! change turns
                countdownTimer.Stop();
                lblUpdateUser.Text = $"{penteController.CurrentPlayerName}'s time is up!\nNext player's turn starts now.";
                penteController.MoveTimeElapsed();
                moveTime = 20;
                countdownTimer.Start();
                lblCountdown.Foreground = Brushes.Black;
            }

            if (moveTime == 5)
            {
                lblCountdown.Foreground = Brushes.Red;
            }



            if (name1 != penteController.CurrentPlayerName && name2 != penteController.CurrentPlayerName)
            {
                name2    = penteController.CurrentPlayerName;
                moveTime = 20;
                countdownTimer.Start();
                lblCountdown.Foreground = Brushes.Black;
            }
            else if (name2 == penteController.CurrentPlayerName && name1 != penteController.CurrentPlayerName)
            {
                name1    = penteController.CurrentPlayerName;
                moveTime = 20;
                countdownTimer.Start();
                lblCountdown.Foreground = Brushes.Black;
            }

            lblCountdown.Content = $" {moveTime.ToString()}";
        }