//TODO: Flip tiles and blocks to match rotations. /// <summary> /// Rotates the city to the right. /// </summary> public void RotateRight() { //To find the distance each piece of the grid should be to connect it together Vector2 spacing = new Vector2 (Tiles.GRIDWIDTH / 2f, Tiles.GRIDHEIGHT / 2f); spacing.X = (float)Math.Round (spacing.X, 0); spacing.Y = (float)Math.Round (spacing.Y, 0); //Direction for the orientation of the city. Is used to draw features correctly. Direction.RotateRight(); Camera.Direction.RotateRight(); Block[,,] blockresult = new Block[Game1.MAXX, Game1.MAXY, Game1.MAXZ]; Tile[,] tileresult = new Tile[Game1.MAXX, Game1.MAXY]; for (int y = 0; y < Game1.MAXY; y++) for (int x = 0; x < Game1.MAXX; x++) { //Rotate the tiles tileresult [x, y] = _tiles [Game1.MAXY - 1 - y, x]; //Recalculate the drawrect. tileresult [x, y].DrawRect = GetTileDrawRect(x,y); //Rotate the blocks for (int z = 0; z < Game1.MAXZ; z++) { blockresult [x, y, z] = _blocks [Game1.MAXY - 1 - y, x, z]; //Recalc block position blockresult[x,y,z].DrawRect = new Rectangle( tileresult[x,y].DrawRect.X, tileresult[x,y].DrawRect.Y - (Blocks.BLOCKHEIGHT*(z+1)), 31,31); } } _blocks = (Block[,,])blockresult.Clone(); _tiles = (Tile[,])tileresult.Clone(); CheckRoadSanity(); }
/// <summary> /// Rotates the city to the left. /// </summary> public void RotateLeft() { Vector2 spacing = new Vector2 (Tiles.GRIDWIDTH / 2f, Tiles.GRIDHEIGHT / 2f); spacing.X = (float)Math.Round (spacing.X, 0); spacing.Y = (float)Math.Round (spacing.Y, 0); Direction.RotateLeft(); Camera.Direction.RotateRight(); Block[,,] blockresult = new Block[Game1.MAXX, Game1.MAXY, Game1.MAXZ]; Tile[,] tileresult = new Tile[Game1.MAXX, Game1.MAXY]; for (int y = 0; y < Game1.MAXY; y++) for (int x = 0; x < Game1.MAXX; x++) { //Rotate the tiles tileresult [x, y] = _tiles [y, Game1.MAXX - 1 - x]; //Recalculate the drawrect. tileresult [x, y].DrawRect = GetTileDrawRect(x,y); //Rotate the blocks for (int z = 0; z < Game1.MAXZ; z++) { blockresult [x, y, z] = _blocks [y, Game1.MAXX - 1 - x, z]; //Recalc block position blockresult[x,y,z].DrawRect = new Rectangle( tileresult[x,y].DrawRect.X, tileresult[x,y].DrawRect.Y - (Blocks.BLOCKHEIGHT*(z+1)), 31,31); } } _blocks = (Block[,,])blockresult.Clone(); _tiles = (Tile[,])tileresult.Clone(); CheckRoadSanity(); }