protected void btnSubmit_Click(object sender, EventArgs e) { string aID; int iD = 1; iD = iD + 1; aID = iD.ToString(); int pNum = Convert.ToInt32(txPH.Text); string firstName = txFname.Text; string lastName = txLname.Text; string email = txMail.Text; string passWord = txPw.Text; //string adminID = Convert.ToString(aID); BusLayer busLayer = new BusLayer(); try { busLayer.InsertAdminDet(aID, firstName, lastName, email, pNum, passWord); GridTest.DataSource = busLayer.SelectAdminDet(); GridTest.DataBind(); if (Page.IsValid) { Response.Redirect("AdminLogIn.aspx"); } } catch { Response.Redirect("ErrorPage.aspx"); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { //app.RegisterMVCGrid("TestGrid", GridTest.Test()); //app.UseMvcGrid(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(new StaticFileOptions { ServeUnknownFileTypes = true, }); app.UseCookiePolicy(); app.RegisterMVCGrid("TestGrid", GridTest.Test()); app.RegisterMVCGrid("TestGrid2", GridTest.Test2()); app.UseMvcGrid(); app.UseMvcGridSignalR(); app.UseMvcWithDefaultRoute(); }
/// <summary>绑定Grid列表 /// 绑定Grid列表 /// </summary> /// <param name="OrderRegisterList">数据源LIST集合</param> private void BindGridTest(List <OrderRegister> OrderRegisterList) { GridTest.DataSource = OrderRegisterList; try { GridTest.DataBind(); } catch (Exception) { } }
/// <summary>绑定Grid列表 /// 绑定Grid列表 /// </summary> /// <param name="OrderRegisterList">数据源LIST集合</param> private void BindGridTest(List <OrderRegister> OrderRegisterList) { ViewState["GridTest"] = OrderRegisterList; GridTest.Rows.Clear(); GridTest.DataSource = OrderRegisterList; try { GridTest.DataBind(); } catch (Exception) { } }
void TestGrid() { var test = new GridTest(Nodes, Entrance, Exit); var isPath = test.AStar(); if (isPath == false) { Debug.Log("NoPath"); RandomizeNodes(); } }
public void loaddata() { try { ds = new DataSet(); ds = dm.GetTestDetails(); GridTest.DataSource = ds; GridTest.DataBind(); } catch (SqlException ex) { ShowMessageBox("Remote Acess Not Available"); } }
private void gridTestShow() { string sql = "select * from Courses where Teacher=@teach and Duration <@dur"; OleDbCommand myCmdTest = new OleDbCommand(sql, myCon); //OleDbParameter myPar = new OleDbParameter("teach", "Houria Houmel"); //myCmdTest.Parameters.Add(myPar); myCmdTest.Parameters.AddWithValue("teach", "Houria Houmel"); myCmdTest.Parameters.AddWithValue("dur", 50); OleDbDataReader rdTest = myCmdTest.ExecuteReader(); GridTest.DataSource = rdTest; GridTest.DataBind(); }
/// <summary> /// This is a helper method for the pathfnding that searches the grid positions adjacent to the current node to determine if the node is in the grid (using the try/catch) /// and that the open/closed lists do not already contain the node (as this would create an infinite loop) /// </summary> /// <returns>List<Node> l_returnNodes (A list of nodes adjacent to the current node)</returns> /// <param name="l_openList">The pathfinding algorithm's open list</param> /// <param name="l_closedList">The pathfinding algorithm's closed list</param> /// <param name="l_currentNode">The node to find adjecant nodes to</param> protected List <Node> FindNeighbours(List <Node> l_openList, List <Node> l_closedList, Node l_currentNode) { int[] l_startGrid = GridTest.GetArrayPosFromVector(l_currentNode.c_nodePosition); //Debug.Log (l_startGrid[0] + ", " + l_startGrid[1] + " is grid pos, current node transform = " + l_currentNode.c_nodePosition); List <Node> l_returnNodes = new List <Node>(); Node l_tempNode = new Node(new Vector3(0, 0, 0)); try{ l_tempNode = GridTest.s_gridPosArray [l_startGrid [0] + 1, l_startGrid [1]]; if (!ListContains(l_openList, l_tempNode) && !ListContains(l_closedList, l_tempNode)) { l_returnNodes.Add(l_tempNode); } } catch { } try{ l_tempNode = GridTest.s_gridPosArray [l_startGrid [0] - 1, l_startGrid [1]]; if (!ListContains(l_openList, l_tempNode) && !ListContains(l_closedList, l_tempNode)) { l_returnNodes.Add(l_tempNode); } } catch { } try{ l_tempNode = GridTest.s_gridPosArray [l_startGrid [0], l_startGrid [1] + 1]; if (!ListContains(l_openList, l_tempNode) && !ListContains(l_closedList, l_tempNode)) { l_returnNodes.Add(l_tempNode); } } catch { } try{ l_tempNode = GridTest.s_gridPosArray [l_startGrid [0], l_startGrid [1] - 1]; if (!ListContains(l_openList, l_tempNode) && !ListContains(l_closedList, l_tempNode)) { l_returnNodes.Add(l_tempNode); } } catch { } return(l_returnNodes); }
public void MyAttack() { if (!c_setupAttack && !c_attacked) { c_setupAttack = true; c_squaresInAttackRange.Clear(); c_squaresInAttackRange = GridTest.CheckRange(transform.position, c_playerHealthScript.c_playerStats.playerAttackRange, "MoveCube"); if (c_squaresInAttackRange.Count != 0) { foreach (GameObject tile in c_squaresInAttackRange) { Debug.Log("Attempting to get character on tile..."); if (tile.GetComponent <AddGridToRange> ().GetEnemyOnTile(c_enemyDamageTag) != null) { c_enemiesInAttackRange.Add(tile.GetComponent <AddGridToRange> ().GetEnemyOnTile(c_enemyDamageTag)); //Debug.Log ("Added to tile"); } } } if (c_enemiesInAttackRange.Count != 0) { c_UI.UpdateBattleDialogue("Please select a target."); //foreach (GameObject enemy in c_enemiesInAttackRange) //Debug.Log (enemy.name); c_UI.DynamicHide(false); StartCoroutine(SearchForTile(c_squaresInAttackRange)); } else { c_UI.UpdateBattleDialogue("There are no targets in range."); c_setupAttack = false; foreach (GameObject tile in c_squaresInAttackRange) { tile.GetComponent <Renderer> ().material.SetColor("_Color", Color.red); } Invoke("DelayClearingSetupTiles", 1.5f); } } else if (c_enemy != null && !c_attacked) { c_playerHealthScript.CancelDefend(); c_myTurnObject.c_delayValue += (int)(c_personalDelay * c_currentSkill.UseSkill(c_enemy.transform.position, c_playerHealthScript, c_enemyDamageTag)); c_attacked = true; Debug.Log("" + gameObject.name + " attacked"); c_setupAttack = false; ClearTileColourInGrid(c_squaresInAttackRange); if (c_currentlyMoving == "Finished Moving") { EndTurn(); } else { c_UI.DynamicHide(true); } } else if (c_attacked) { c_UI.UpdateBattleDialogue("You have already attacked/defended. Please move or end your turn."); } else if (c_enemy == null) { c_UI.UpdateBattleDialogue("Please select a new target."); } }
/// <summary> /// 绑定Grid列表 /// </summary> /// <param name="OrderRegisterList">数据源LIST集合</param> private void BindGridTest(List <OrderRegister> OrderRegisterList) { ViewState["GridTest"] = OrderRegisterList; GridTest.DataSource = OrderRegisterList; GridTest.DataBind(); }
private void Start() { g = GameObject.Find("Grid").GetComponent <GridTest>(); }
/// <summary> /// Uses an A* algorithm to find the shortest path to the node the player selected. /// </summary> /// <returns>The path.</returns> /// <param name="l_startPos">The player's start position.</param> /// <param name="l_endPos">The node the player is trying to reach.</param> private Vector3[] CalculatePath(Vector3 l_startPos, Vector3 l_endPos) { List <Node> l_openList = new List <Node>(); List <Node> l_closedList = new List <Node>(); int[] l_tempGrid = GridTest.GetArrayPosFromVector(l_endPos); Node l_endNode = GridTest.s_gridPosArray [l_tempGrid[0], l_tempGrid[1]]; Vector3[] l_returnArray = new Vector3[0]; bool l_foundPath = false; l_tempGrid = GridTest.GetArrayPosFromVector(l_startPos); Node l_startNode = GridTest.s_gridPosArray [l_tempGrid[0], l_tempGrid[1]]; l_openList.Add(l_startNode); while (l_openList.Count > 0) { Node l_nextNode = new Node(new Vector3(0, 0, 0)); l_nextNode.c_gCost = 5000; l_nextNode.c_fCost = 5000; for (int n = 0; n < l_openList.Count; n++) { if (l_openList[n].c_fCost < l_nextNode.c_fCost) { l_nextNode = l_openList[n]; } } l_openList.Remove(l_nextNode); l_closedList.Add(l_nextNode); if (l_nextNode.c_nodePosition == l_endPos) { l_foundPath = true; l_endNode = l_nextNode; Debug.Log("Found path, breaking"); Debug.Log("Node parent = " + l_endNode.c_parentNode.c_nodePosition); break; } List <Node> l_neighbourNodes = FindNeighbours(l_openList, l_closedList, l_nextNode); for (int n = 0; n < l_neighbourNodes.Count; n++) { if (IsThereObstruction(l_neighbourNodes[n].c_nodePosition) || ListContains(l_closedList, l_neighbourNodes[n])) { continue; } if (l_neighbourNodes[n].c_parentNode == null) { l_neighbourNodes[n].c_parentNode = l_nextNode; } if (l_neighbourNodes[n].c_gCost > l_neighbourNodes[n].c_parentNode.c_gCost + 1 || !ListContains(l_openList, l_neighbourNodes[n])) { l_neighbourNodes[n].c_gCost = l_neighbourNodes[n].c_parentNode.c_gCost++; l_neighbourNodes[n].c_hCost = Mathf.Abs(l_neighbourNodes[n].c_nodePosition.x - l_endPos.x) + Mathf.Abs(l_neighbourNodes[n].c_nodePosition.z - l_endPos.z); l_neighbourNodes[n].c_fCost = l_neighbourNodes[n].c_gCost + l_neighbourNodes[n].c_hCost; l_neighbourNodes[n].c_parentNode = l_nextNode; Debug.Log("Setting Node parent"); if (!ListContains(l_openList, l_neighbourNodes[n])) { l_openList.Add(l_neighbourNodes[n]); } } } } if (l_foundPath) { Debug.Log("Found path, calling backtrack"); l_returnArray = CalculateBacktrack(l_startNode, l_endNode); } for (int n = 0; n < l_closedList.Count; n++) { l_closedList [n].c_gCost = 0; l_closedList [n].c_fCost = 0; l_closedList [n].c_parentNode = null; } for (int n = 0; n < l_openList.Count; n++) { l_openList [n].c_gCost = 0; l_openList [n].c_fCost = 0; l_openList [n].c_parentNode = null; } return(l_returnArray); }
protected void GridTest_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridTest.PageIndex = e.NewPageIndex; loaddata(); GridTest.DataBind(); }
/// <summary> /// Targetses the in range. /// </summary> /// <returns>The in range.</returns> protected List <GameObject> TargetsInRange() { return(GridTest.CheckRange(c_targetPos, c_AOERange, c_targetTeamTag)); }
/// <summary> /// This method uses a Dijkstra algoritm to create a list of all floor tiles within the argument's range. /// I have used for loops as opposed to foreach loops for efficiency and created my own List.Contains() /// method that loops through the list to find a comparable node as this too is much more efficient. /// </summary> /// <returns>GameObject[] l_returnArea: List of game objects in range of the player.</returns> /// <param name="l_startPos">: Player's position in the world (Vector3).</param> /// <param name="l_range">: Range that player can move (int).</param> private GameObject[] CalculateArea(Vector3 l_startPos, int l_range) { List <Node> l_areaInRange = new List <Node>(); List <Node> l_openList = new List <Node>(); List <Node> l_closedList = new List <Node>(); int[] l_tempGrid; l_tempGrid = GridTest.GetArrayPosFromVector(l_startPos); Node l_startNode = GridTest.s_gridPosArray [l_tempGrid[0], l_tempGrid[1]]; l_openList.Add(l_startNode); while (l_openList.Count > 0) { Node l_nextNode = new Node(new Vector3(0, 0, 0)); l_nextNode.c_gCost = int.MaxValue; for (int n = 0; n < l_openList.Count; n++) { if (l_openList[n].c_gCost < l_nextNode.c_gCost) { l_nextNode = l_openList[n]; } } if (l_nextNode == null) { break; } l_openList.Remove(l_nextNode); l_closedList.Add(l_nextNode); if (l_nextNode.c_gCost > l_range) { continue; } List <Node> l_neighbourNodes = FindNeighbours(l_openList, l_closedList, l_nextNode); for (int n = 0; n < l_neighbourNodes.Count; n++) { if (IsThereObstruction(l_neighbourNodes[n].c_nodePosition) || ListContains(l_closedList, l_neighbourNodes[n])) { continue; } if (l_neighbourNodes[n].c_parentNode == null || !ListContains(l_closedList, l_neighbourNodes[n].c_parentNode)) { l_neighbourNodes[n].c_parentNode = l_nextNode; } if ((l_neighbourNodes[n].c_gCost > (l_neighbourNodes[n].c_parentNode.c_gCost + 1) || l_neighbourNodes[n].c_gCost == 0) || !ListContains(l_openList, l_neighbourNodes[n])) { l_neighbourNodes[n].c_gCost = l_neighbourNodes[n].c_parentNode.c_gCost + 1; l_neighbourNodes[n].c_fCost = l_neighbourNodes[n].c_gCost; l_neighbourNodes[n].c_parentNode = l_nextNode; if (!ListContains(l_openList, l_neighbourNodes[n]) && l_neighbourNodes[n].c_gCost <= l_range) { l_openList.Add(l_neighbourNodes[n]); Debug.Log("GCost = " + l_neighbourNodes [n].c_gCost + " added to openList"); if (!ListContains(l_areaInRange, l_neighbourNodes[n])) { l_areaInRange.Add(l_neighbourNodes[n]); Debug.Log("GCost = " + l_neighbourNodes [n].c_gCost + " added to areaInRangeList"); } } } } } List <GameObject> l_returnArea = new List <GameObject> (); foreach (Node n in l_areaInRange) { Debug.Log(n.c_nodePosition); } for (int n = 0; n < l_areaInRange.Count; n++) { l_areaInRange [n].c_gCost = 0; l_areaInRange [n].c_fCost = 0; l_areaInRange [n].c_parentNode = null; GameObject l_tempObj = GridTest.GetTileFromVector(l_areaInRange[n].c_nodePosition); if (l_tempObj != null) { l_returnArea.Add(l_tempObj); } } return(l_returnArea.ToArray()); }