protected override void OnInitialized() { opponentsPlay = playsGame[0]; timer = new Timer(); timer.Interval = 100; timer.Elapsed += TimerOnElapsed; timer.Start(); }
public GameResult PlayAgainst(PlayGame playGame) { if (GameOption == playGame.GameOption) { return(GameResult.Draw); } else { if (BeatsTo == playGame.GameOption) { return(GameResult.Victory); } else { return(GameResult.Lose); } } }
private void SelectPlay(PlayGame play) { timer.Stop(); var result = play.PlayAgainst(opponentsPlay); switch (result) { case GameResult.Victory: messageResult = "Victory!!"; messageResultColor = "green"; break; case GameResult.Lose: messageResult = "You Lose :("; messageResultColor = "red"; break; case GameResult.Draw: messageResult = "Draw"; messageResultColor = "yellow"; break; } }
private void TimerOnElapsed(object sender, ElapsedEventArgs e) { index = (index + 1) % playsGame.Count; opponentsPlay = playsGame[index]; StateHasChanged(); }