/* * Will link this grid westernly to the given grid. * REQUIRE: this.grid.cells_vertical == given.grid.cells_vertical * ENSURE: this.grid.east_border_cells.east_cells * == given.grid.west_border_cells * && given.grid.west_border_cells.west_cells * == this.grid.east_border_cells */ public void linkWesternlyTo(Grid east_grid) { //loop through the grid of cells for (int j = 0; j < this.cells_vertical; j++) { //set this grid's east border to the east_grid's west border this.cells[this.cells_horizontal - 1, j].setEastCell( east_grid.cells[0, j]); //set the east_grid's west border to this grid's east border east_grid.cells[0, j].setWestCell( this.cells[this.cells_horizontal - 1, j]); } }
// Allows the game to perform any initialization it needs to before starting to run. // This is where it can query for any required services and load any non-graphic // related content. Calling base.Initialize will enumerate through any components // and initialize them as well. protected override void Initialize() { this.camera_angle = new Vector3(2, 3, -5); int grid_width = GraphicsDevice.Viewport.Width / 4; int grid_height = GraphicsDevice.Viewport.Height / 4; //initially set to pause mode this.is_playing = false; //set up the grids this.north_grid = new Grid(this, 10, 10, GraphicsDevice.Viewport.Width/2 - grid_width/2, GraphicsDevice.Viewport.Height/2 - grid_height - (grid_height/2), grid_width, grid_height); this.center_grid = new Grid(this, 10, 10, GraphicsDevice.Viewport.Width / 2 - grid_width/2, GraphicsDevice.Viewport.Height / 2 - (grid_height / 2), grid_width, grid_height); this.south_grid = new Grid(this, 10, 10, GraphicsDevice.Viewport.Width / 2 - grid_width/2, GraphicsDevice.Viewport.Height/2 + (grid_height / 2), grid_width, grid_height); this.west_grid = new Grid(this, 10, 10, GraphicsDevice.Viewport.Width/2 - grid_width/2 - grid_width, GraphicsDevice.Viewport.Height/2 - (grid_height/2), grid_width, grid_height); this.east_grid = new Grid(this, 10, 10, GraphicsDevice.Viewport.Width/2 + grid_width/2, GraphicsDevice.Viewport.Height/2 - (grid_height/2), grid_width, grid_height); //Components.Add(this.north_grid); //Components.Add(this.center_grid); //Components.Add(this.south_grid); //Components.Add(this.west_grid); //Components.Add(this.east_grid); base.Initialize(); //set the west grid as current //this.current_cell = this.west_grid.firstCell(); //this.current_cell.selectCell(); }
/* * Will link this grid southernly to the given grid. * REQUIRE: this.grid.cells_horizontal == given.grid.cells_horizontal * ENSURE: this.grid.north_border_cells.north_cells * == given.grid.south_border_cells * && given.grid.south_border_cells.south_cells * == this.grid.north_border_cells */ public void linkSouthernlyTo(Grid north_grid) { //loop through the grid of cells for (int i = 0; i < this.cells_horizontal; i++) { //set this grid's north border to the north_grid's south border this.cells[i, 0].setNorthCell( north_grid.cells[i, north_grid.cells_vertical - 1]); //set the north_grid's south border to this grid's north border north_grid.cells[i, north_grid.cells_vertical - 1].setSouthCell( this.cells[i, 0]); } }