public GameController( Form PreviousPage, int player1Time, int player2Time, int timeAddedAfterEveryMove = 0, int startingPlayer = 0 // 0 for white, 1 for black ) { InitializeComponent(); WinnerLabel.Visible = false; SwitchPlayerButton.Visible = true; StartStopButton.Visible = true; this.previousPage = PreviousPage; this.player1Time = new PlayerTimer(player1Time, timeAddedAfterEveryMove); this.player2Time = new PlayerTimer(player2Time, timeAddedAfterEveryMove); Player1TimeLabel.Text = this.player1Time.GetTimeString(); Player2TimeLabel.Text = this.player2Time.GetTimeString(); StartPlayer(startingPlayer); timer = new Timer(); timer.Interval = 10; timer.Tick += new EventHandler(this.Tick); timer.Start(); }
//ISimpleAudioPlayer kickSound; //ISimpleAudioPlayer clapSound; public MainPage(int mainTimeMin, int additionalTimSec) { playerTimer1 = new PlayerTimer(mainTimeMin, additionalTimSec); playerTimer2 = new PlayerTimer(mainTimeMin, additionalTimSec); Device.StartTimer(new TimeSpan(0, 0, 0, 0, 100), Callback); InitializeComponent(); }
private void PrintTime(PlayerTimer playerTimer, Button button) { if (playerTimer.Time.TotalSeconds >= 60) { button.Text = string.Format("{0:D2}:{1:D2}", playerTimer.Time.Minutes, playerTimer.Time.Seconds); } else if (playerTimer.Time.TotalSeconds <= 15) { button.Text = string.Format("{0:D2}:{1:D1}", playerTimer.Time.Seconds, (int)Math.Round((double)playerTimer.Time.Milliseconds / 100, 1)); //Transform(button); } else { button.Text = string.Format("{0:D2}", playerTimer.Time.Seconds); } }