public Square_Grid(int[ , ] map_grid, float s) { int x_L = map_grid.GetLength(0); int y_L = map_grid.GetLength(1); #region Control_Node[ , ] //control_nodes Vector3 centre_ = new Vector3((x_L - 1) * s / 2f, 0f, (y_L - 1) * s / 2f); Control_Node[,] C_ = new Control_Node[x_L, y_L]; for (int y = 0; y < y_L; y += 1) { for (int x = 0; x < x_L; x += 1) { Vector3 from_corner = new Vector3(s * x, 0f, s * y); // Vector3 p_ = from_corner - centre_; // bool On_ = (map_grid[x, y] == 1); C_[x, y] = new Control_Node(p_, s, On_); } } #endregion #region Square[ , ] //squares squares = new Square[x_L - 1, y_L - 1]; for (int y = 0; y < y_L - 1; y += 1) { for (int x = 0; x < x_L - 1; x += 1) { squares[x, y] = new Square(C_[x, y + 1], C_[x + 1, y + 1], C_[x + 1, y], C_[x, y]); } } #endregion }
public Square(Control_Node a, Control_Node b, Control_Node c, Control_Node d) { control_Nodes = new Control_Node[4] { a, b, c, d }; nodes = new Node[4] { a.right, c.top, d.right, d.top }; #region sum sum = 0; // if (a.Active) { sum += 8; } if (b.Active) { sum += 4; } if (c.Active) { sum += 2; } if (d.Active) { sum += 1; } // #endregion }