/// <summary> /// Builds the structure /// </summary> /// <param name="p">The point at which to build</param> private void BuildCallback( Point3D p ) { if ( m_User.Map == null || m_User.Map == Map.Internal ) return; m_Building.Clear(); // Calculate bounds Point2D start = new Point2D( int.MaxValue, int.MaxValue ); Point2D end = Point2D.Zero; int z = int.MaxValue; foreach ( Point2D point in m_Tiles.Keys ) { start.X = Math.Min( start.X, point.X ); start.Y = Math.Min( start.Y, point.Y ); end.X = Math.Max( end.X, point.X ); end.Y = Math.Max( end.Y, point.Y ); ArrayList tiles = m_Tiles[ point ] as ArrayList; foreach( Tile t in tiles ) { z = Math.Min( z, t.Z ); } } Point2D center = Point2D.Zero; center.X = start.X + ( ( end.X - start.X ) / 2 ); center.Y = start.Y + ( ( end.Y - start.Y ) / 2 ); foreach( Point2D point in m_Tiles.Keys ) { int xOffset = point.X - center.X; int yOffset = point.Y - center.Y; ArrayList tiles = m_Tiles[ point ] as ArrayList; if ( tiles == null || tiles.Count == 0 ) continue; foreach( Tile t in tiles ) { int zOffset = t.Z - p.Z; Server.Items.Static item = new Server.Items.Static( t.ID - 16384 ); item.MoveToWorld( new Point3D( p.X + xOffset, p.Y + yOffset, p.Z + zOffset ), m_User.Map ); m_Building.Add( item ); } } ResendGump(); }
private void BuildBoard(ChessControl chess, Point3D p, Map map) { chess.m_BoardHeight = p.Z + 5; // Placing stairs on the specified point chess.BoardNorthWestCorner = new Point2D(p.X, p.Y); #region Board Tiles int stairNW = 1909; int stairSE = 1910; int stairSW = 1911; int stairNE = 1912; int stairS = 1901; int stairE = 1902; int stairN = 1903; int stairW = 1904; int black = 1295; //hue = 2406; int white = 1298; //hue = 2101; #endregion for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int tile = 0; if (x % 2 == 0) { if (y % 2 == 0) { tile = white; //swapped } else { tile = black; } } else { if (y % 2 == 0) { tile = black; //swapped } else { tile = white; } } if (chess.Orientation == BoardOrientation.EastWest) // Invert tiles if the orientation is EW { if (tile == black) { tile = white; //swapped } else { tile = black; } } for (int kx = 0; kx < chess.m_SquareWidth; kx++) { for (int ky = 0; ky < chess.m_SquareWidth; ky++) { Server.Items.Static s = new Server.Items.Static(tile); if (tile == black) { s.Hue = m_BoardBlackHue; m_BoardBlackTiles.Add(s); } else if (tile == white) { s.Hue = m_BoardWhiteHue; m_BoardWhiteTiles.Add(s); } Point3D target = new Point3D(p.X + x * chess.m_SquareWidth + kx, p.Y + y * chess.m_SquareWidth + ky, chess.m_BoardHeight); s.MoveToWorld(target, map); } } } } Point3D nw = new Point3D(p.X - 1, p.Y - 1, p.Z); Point3D ne = new Point3D(p.X + 8 * chess.m_SquareWidth, p.Y - 1, p.Z); Point3D se = new Point3D(p.X + 8 * chess.m_SquareWidth, p.Y + 8 * chess.m_SquareWidth, p.Z); Point3D sw = new Point3D(p.X - 1, p.Y + 8 * chess.m_SquareWidth, p.Z); Server.Items.Static NW = new Server.Items.Static(stairNW) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(NW); NW.MoveToWorld(nw, map); Server.Items.Static NE = new Server.Items.Static(stairNE) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(NE); NE.MoveToWorld(ne, map); Server.Items.Static SE = new Server.Items.Static(stairSE) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(SE); SE.MoveToWorld(se, map); Server.Items.Static SW = new Server.Items.Static(stairSW) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(SW); SW.MoveToWorld(sw, map); for (int x = 0; x < 8 * chess.m_SquareWidth; x++) { Point3D top = new Point3D(p.X + x, p.Y - 1, p.Z); Point3D bottom = new Point3D(p.X + x, p.Y + 8 * chess.m_SquareWidth, p.Z); Point3D left = new Point3D(p.X - 1, p.Y + x, p.Z); Point3D right = new Point3D(p.X + chess.m_SquareWidth * 8, p.Y + x, p.Z); Server.Items.Static N = new Server.Items.Static(stairN) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(N); N.MoveToWorld(top, map); Server.Items.Static S = new Server.Items.Static(stairS) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(S); S.MoveToWorld(bottom, map); Server.Items.Static W = new Server.Items.Static(stairW) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(W); W.MoveToWorld(left, map); Server.Items.Static E = new Server.Items.Static(stairE) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(E); E.MoveToWorld(right, map); } }
private static void BuildBoard(ChessControl chess, Point3D p, Map map) { chess.m_BoardHeight = p.Z + 5; // Placing stairs on the specified point chess.BoardNorthWestCorner = new Point2D(p.X, p.Y); #region Board Tiles int stairNW = 1909; int stairSE = 1910; int stairSW = 1911; int stairNE = 1912; int stairS = 1901; int stairE = 1902; int stairN = 1903; int stairW = 1904; int black = 1295; int white = 1298; #endregion for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { int tile = 0; if (x % 2 == 0) { if (y % 2 == 0) { tile = black; } else { tile = white; } } else { if (y % 2 == 0) { tile = white; } else { tile = black; } } if (chess.Orientation == BoardOrientation.EastWest) // Invert tiles if the orientation is EW { if (tile == white) { tile = black; } else { tile = white; } } for (int kx = 0; kx < chess.m_SquareWidth; kx++) { for (int ky = 0; ky < chess.m_SquareWidth; ky++) { Server.Items.Static s = new Server.Items.Static(tile); Point3D target = new Point3D(p.X + x * chess.m_SquareWidth + kx, p.Y + y * chess.m_SquareWidth + ky, chess.m_BoardHeight); s.MoveToWorld(target, map); } } } } Point3D nw = new Point3D(p.X - 1, p.Y - 1, p.Z); Point3D ne = new Point3D(p.X + 8 * chess.m_SquareWidth, p.Y - 1, p.Z); Point3D se = new Point3D(p.X + 8 * chess.m_SquareWidth, p.Y + 8 * chess.m_SquareWidth, p.Z); Point3D sw = new Point3D(p.X - 1, p.Y + 8 * chess.m_SquareWidth, p.Z); new Server.Items.Static(stairNW).MoveToWorld(nw, map); new Server.Items.Static(stairNE).MoveToWorld(ne, map); new Server.Items.Static(stairSE).MoveToWorld(se, map); new Server.Items.Static(stairSW).MoveToWorld(sw, map); for (int x = 0; x < 8 * chess.m_SquareWidth; x++) { Point3D top = new Point3D(p.X + x, p.Y - 1, p.Z); Point3D bottom = new Point3D(p.X + x, p.Y + 8 * chess.m_SquareWidth, p.Z); Point3D left = new Point3D(p.X - 1, p.Y + x, p.Z); Point3D right = new Point3D(p.X + chess.m_SquareWidth * 8, p.Y + x, p.Z); new Server.Items.Static(stairN).MoveToWorld(top, map); new Server.Items.Static(stairS).MoveToWorld(bottom, map); new Server.Items.Static(stairW).MoveToWorld(left, map); new Server.Items.Static(stairE).MoveToWorld(right, map); } }
private void BuildBoard( ChessControl chess, Point3D p, Map map ) { chess.m_BoardHeight = p.Z + 5; // Placing stairs on the specified point chess.BoardNorthWestCorner = new Point2D( p.X, p.Y ); #region Board Tiles int stairNW = 1909; int stairSE = 1910; int stairSW = 1911; int stairNE = 1912; int stairS = 1901; int stairE = 1902; int stairN = 1903; int stairW = 1904; int black = 1295; //hue = 2406; int white = 1298; //hue = 2101; #endregion for ( int x = 0; x < 8; x++ ) { for ( int y = 0; y < 8; y++ ) { int tile = 0; if ( x % 2 == 0 ) { if ( y % 2 == 0 ) tile = white;//swapped else tile = black; } else { if ( y % 2 == 0 ) tile = black;//swapped else tile = white; } if ( chess.Orientation == BoardOrientation.EastWest ) // Invert tiles if the orientation is EW { if ( tile == black ) tile = white;//swapped else tile = black; } for ( int kx = 0; kx < chess.m_SquareWidth; kx++ ) { for ( int ky = 0; ky < chess.m_SquareWidth; ky++ ) { Server.Items.Static s = new Server.Items.Static( tile ); if (tile == black) { s.Hue = m_BoardBlackHue; m_BoardBlackTiles.Add(s); } else if (tile == white) { s.Hue = m_BoardWhiteHue; m_BoardWhiteTiles.Add(s); } Point3D target = new Point3D( p.X + x * chess.m_SquareWidth + kx, p.Y + y * chess.m_SquareWidth + ky, chess.m_BoardHeight ); s.MoveToWorld( target, map ); } } } } Point3D nw = new Point3D( p.X - 1, p.Y - 1, p.Z ); Point3D ne = new Point3D( p.X + 8 * chess.m_SquareWidth, p.Y - 1, p.Z ); Point3D se = new Point3D( p.X + 8 * chess.m_SquareWidth, p.Y + 8 * chess.m_SquareWidth, p.Z ); Point3D sw = new Point3D( p.X - 1, p.Y + 8 * chess.m_SquareWidth, p.Z ); Server.Items.Static NW = new Server.Items.Static(stairNW) {Hue = m_BoardStairsHue}; m_BoardStairsTiles.Add(NW); NW.MoveToWorld( nw, map ); Server.Items.Static NE = new Server.Items.Static(stairNE) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(NE); NE.MoveToWorld(ne, map); Server.Items.Static SE = new Server.Items.Static(stairSE) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(SE); SE.MoveToWorld(se, map); Server.Items.Static SW = new Server.Items.Static(stairSW) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(SW); SW.MoveToWorld(sw, map); for ( int x = 0; x < 8 * chess.m_SquareWidth; x++ ) { Point3D top = new Point3D( p.X + x, p.Y - 1, p.Z ); Point3D bottom = new Point3D( p.X + x, p.Y + 8 * chess.m_SquareWidth, p.Z ); Point3D left = new Point3D( p.X - 1, p.Y + x, p.Z ); Point3D right = new Point3D( p.X + chess.m_SquareWidth * 8, p.Y + x, p.Z ); Server.Items.Static N = new Server.Items.Static(stairN) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(N); N.MoveToWorld(top, map); Server.Items.Static S = new Server.Items.Static(stairS) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(S); S.MoveToWorld(bottom, map); Server.Items.Static W = new Server.Items.Static(stairW) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(W); W.MoveToWorld(left, map); Server.Items.Static E = new Server.Items.Static(stairE) { Hue = m_BoardStairsHue }; m_BoardStairsTiles.Add(E); E.MoveToWorld(right, map); } }
private static void BuildBoard( ChessControl chess, Point3D p, Map map ) { chess.m_BoardHeight = p.Z + 5; // Placing stairs on the specified point chess.BoardNorthWestCorner = new Point2D( p.X, p.Y ); #region Board Tiles int stairNW = 1909; int stairSE = 1910; int stairSW = 1911; int stairNE = 1912; int stairS = 1901; int stairE = 1902; int stairN = 1903; int stairW = 1904; int black = 1295; int white = 1298; #endregion for ( int x = 0; x < 8; x++ ) { for ( int y = 0; y < 8; y++ ) { int tile = 0; if ( x % 2 == 0 ) { if ( y % 2 == 0 ) tile = black; else tile = white; } else { if ( y % 2 == 0 ) tile = white; else tile = black; } if ( chess.Orientation == BoardOrientation.EastWest ) // Invert tiles if the orientation is EW { if ( tile == white ) tile = black; else tile = white; } for ( int kx = 0; kx < chess.m_SquareWidth; kx++ ) { for ( int ky = 0; ky < chess.m_SquareWidth; ky++ ) { Server.Items.Static s = new Server.Items.Static( tile ); Point3D target = new Point3D( p.X + x * chess.m_SquareWidth + kx, p.Y + y * chess.m_SquareWidth + ky, chess.m_BoardHeight ); s.MoveToWorld( target, map ); } } } } Point3D nw = new Point3D( p.X - 1, p.Y - 1, p.Z ); Point3D ne = new Point3D( p.X + 8 * chess.m_SquareWidth, p.Y - 1, p.Z ); Point3D se = new Point3D( p.X + 8 * chess.m_SquareWidth, p.Y + 8 * chess.m_SquareWidth, p.Z ); Point3D sw = new Point3D( p.X - 1, p.Y + 8 * chess.m_SquareWidth, p.Z ); new Server.Items.Static( stairNW ).MoveToWorld( nw, map ); new Server.Items.Static( stairNE ).MoveToWorld( ne, map ); new Server.Items.Static( stairSE ).MoveToWorld( se, map ); new Server.Items.Static( stairSW ).MoveToWorld( sw, map ); for ( int x = 0; x < 8 * chess.m_SquareWidth; x++ ) { Point3D top = new Point3D( p.X + x, p.Y - 1, p.Z ); Point3D bottom = new Point3D( p.X + x, p.Y + 8 * chess.m_SquareWidth, p.Z ); Point3D left = new Point3D( p.X - 1, p.Y + x, p.Z ); Point3D right = new Point3D( p.X + chess.m_SquareWidth * 8, p.Y + x, p.Z ); new Server.Items.Static( stairN ).MoveToWorld( top, map ); new Server.Items.Static( stairS ).MoveToWorld( bottom, map ); new Server.Items.Static( stairW ).MoveToWorld( left, map ); new Server.Items.Static( stairE ).MoveToWorld( right, map ); } }