public Point tankFindPath(Grid dp, Grid cp) { Point start = new Point(cp.row, cp.col); Point end = new Point(dp.row, dp.col); var parent = maze.FindPath(start, end, false); lGarr = new List<Point>(); while (parent != null) { lGarr.Add(parent); parent = parent.ParentPoint; } Point retp = null; int len; if ((len = lGarr.Count) >= 2) { retp = lGarr[len - 2]; } return retp; }
public Grid getPointRowColTest() { Grid retg = new Grid(32, 29); Vector3 retv3 = getPointCoodTest(retg); return retg; }
public Grid getPointRowCol(Vector3? pos) { int retRow = 0; int retCol = 0; for (int r = 0; r < row; r++) { if (pos.Value.Z < 2400 - 40 * r && pos.Value.Z >= 2400 - 40 * (r + 1)) { retRow = r + 1; break; } } for (int c = 0; c < col; c++) { if (pos.Value.X < leftBoundary - 40 * c && pos.Value.X >= leftBoundary - 40 * (c + 1)) { retCol = c + 1; break; } } Grid retg = new Grid(retRow, retCol); return retg; }
public Vector3 getPointCoodTest(Grid rc) { Vector3 retv = new Vector3(); retv.Y = 0f; for (int r = 0; r < row; r++) { if (rc.row == r) { retv.Z = 2200 - 40 * r - 20; break; } } for (int c = 0; c < col; c++) { if (rc.col == c) { retv.X = leftBoundary - 40 * c - 20; } } return retv; }
public Vector3 getPointRowColTest(Grid g) { Grid retg = g; Vector3 retv3 = getPointCoodTest(retg); return retv3; }
public void navigate(GameTime gameTime, bool PURSUE) { preTankPosition = translation.Translation; Grid destinationPositionRowCol = new Grid(0, 0); if (reNavigateTime == 0) { if (PURSUE == true) { pickPosition = Tank.tankPosition; destinationPositionRowCol = getPointRowCol(pickPosition); } if (PURSUE == false) { if (Tank.tankPosition.Z > 0) { pickPosition = new Vector3(-500, 0, -500); } else { pickPosition = new Vector3(-500, 0, 500); } destinationPositionRowCol = getPointRowCol(pickPosition); } isNavigate = true; preMousePick = pickPosition; bStart = false; reNavigateTime = 3000; } if (bCollision) { bCollision = false; string tm = changeModel(); if (tm.CompareTo("IDLE") == 0) { v.Speed = 0; speed = Vector3.Zero; translation.Translation = preTankPosition; } } else { isNavigate = false; } //streeing float distance = Vector3.Distance(Tank.tankPosition, tankPosition); if (distance > MIN_DISTANCE) { Vector3 pursueDirect = Tank.tankPosition - tankPosition; pursueDirect.Normalize(); v.increaseVelocity(gameTime); speed = pursueDirect * v.Speed; tankPosition += speed; } }