private void chkDemo_CheckedChanged(object sender, EventArgs e) { var newGame = chkDemo.Checked ? (GameOfLifeBase <CellWorld>) new GameOfLifeOpt() : new GameOfLife(); var stopped = _game.Stop; _game.Stop = true; _gameTask?.Wait(2000); newGame.Initialize(new Generation <CellWorld> { Live = _game.CurrentGeneration }); _game = newGame; _app.SetGame(_game); _game.Stop = stopped; if (!stopped) { StartGame(); } }
public StartForm() { InitializeComponent(); _game = new GameOfLife(); _app = new GameOfLifeApp(new Configuration(), _game); txtBack.Text = _app.Configuration.BackColor.ToAbgr().ToString("X8"); txtLive.Text = _app.Configuration.LiveColor.ToAbgr().ToString("X8"); txtBorn.Text = _app.Configuration.BornColor.ToAbgr().ToString("X8"); txtDead.Text = _app.Configuration.DeadColor.ToAbgr().ToString("X8"); txtDelay.Text = _app.Configuration.TargetMs.ToString("D"); trkDelay.Value = 4; if (Directory.Exists("patterns")) { var di = new DirectoryInfo("patterns"); lstPatterns.Items.AddRange(di.GetFiles()); } var appTask = new Task(_app.Run); appTask.Start(); }
public void SetGame(GameOfLifeBase <CellWorld> game) { this.game = game; UpdateConfiguration(); }
public GameOfLifeApp(Configuration configuration, GameOfLifeBase <CellWorld> game) : base(configuration) { this.game = game; }