public RobotRunModel(Int32 size, IRobotRunDataAccess dataAccess) { _dataAccess = dataAccess; rnd = new Random(); _isOnDestroyed = false; _gameTime = 0; _gameSize = size; _gameTable = new GameTable(_gameSize); _currentDir = rnd.Next(-2, 3); }
private void GameForm_Load(object sender, EventArgs e) { this.Cursor = new Cursor("C:/Qt/eva/.Net/beadandok/bead3/RobotRun/images/cursor.cur"); _dataAccess = new RobotRunFileDataAccess(); _model = new RobotRunModel(11, _dataAccess); _model.TimeRefreshed += new EventHandler <RobotRunEventArgs>(Game_TimeRefreshed); _model.TableRefreshed += new EventHandler <RobotRunEventArgs>(Game_TableRefreshed); _model.GameOver += new EventHandler <RobotRunEventArgs>(Game_GameOver); _model.GameStuck += new EventHandler <RobotRunEventArgs>(Game_GameStuck); _dataAccess.GameTableSizeChanged += new EventHandler <int>(Game_SizeChanged); _gameSize = 11; _timer = new Timer(); _timer.Interval = 1000; _timer.Tick += new EventHandler(On_Tick); GenerateTable(); SetupTable(); _model.NewGame(_gameSize); _isPaused = false; _timer.Start(); }