/// <summary> /// Generates a grid specified by user /// </summary> /// <param name="sender">Button Click, not used.</param> /// <param name="e">Button Click, not used.</param> protected void Generate(object sender, EventArgs e) { int r, c; //Try to convert the text in text boxes to ints try { r = Convert.ToInt32(entryRows.Text); c = Convert.ToInt32(entryCols.Text); } //if it fails, log it, but dont close. Maybe user just mistyped. catch (FormatException ex) { Console.WriteLine(ex.ToString()); return; } if (CheckBounds(r, c)) { board = new GameBoard(r, c); GridConstructor gc = new GridConstructor(r, c, this); gc.Show(); gc.SetGrid(); } else { //if bounds check is not met, then display a specific dialog. ErrorDialog error = new ErrorDialog(2); error.Show(); } }
void Start() { gridConstructor = GetComponent <GridConstructor>(); gridX = (ushort)gridConstructor.gridSizeX; gridY = (ushort)gridConstructor.gridSizeY; gridXMinus1 = (ushort)(gridX - 1); gridYLog2 = (ushort)Mathf.Log(gridY, 2); if (Mathf.Log(gridX, 2) != (int)Mathf.Log(gridX, 2) || Mathf.Log(gridY, 2) != (int)Mathf.Log(gridY, 2)) { Debug.Log("Invalid Grid, size in X and Y must be power of 2"); } if (calcGrid == null || calcGrid.Length != gridX * gridY) { calcGrid = new AStarNode[gridX * gridY]; } openSet = new PriorityQueueB <int>(new ComparePFNodeMatrix(calcGrid)); }
void Awake() { grid = GetComponent <GridConstructor>(); requestManager = GetComponent <PathRequestManager>(); }
/// <summary> /// Creates a new instance of the <see cref="GridBuilder{TModel}" />. /// </summary> /// <param name="helper">The <see cref="HtmlHelper" /> that is used to construct the grid.</param> /// <param name="dataSource">The collection of objects that will be bound to the grid.</param> public GridBuilder(HtmlHelper helper, IEnumerable <TModel> dataSource) { htmlHelper = helper; DataSource = dataSource; Constructor = new GridConstructor <TModel>(htmlHelper, DataSource); }