public void init() { if (initComplete == false) { //set ref gridScript = Ref.getGridScript(); visibleObstManager = GetComponent <VisibleObstManager>(); managerScript = Ref.getManagerGO().GetComponent <Manager>(); recalculateTime = GetComponent <AgentProps>().cooperationLenght; spatialAStarScript = GetComponent <SpatialAStar>(); spaceTimeAStarScript = GetComponent <SpaceTimeAStar>(); agent = transform; followPathScript = agent.GetComponent <FollowPath>(); //saves initial grid in grid var saveInitalGrid(); spaceTimeAStarScript.init(); spatialAStarScript.init(grid); spaceTimeAStarScript.setSpacialAStarScript(spatialAStarScript); managerScript.increaseFrameCount(); //here we switch the role of target and agent spatialAStarScript.FindPathSpatial(target.position, agent.position, true, null); path = spaceTimeAStarScript.FindPath(agent.position, target.position, true); followPathScript.init(); followPathScript.setNewPath(path); } initComplete = true; }
void restartPath() { saveInitalGrid(); spatialAStarScript.init(grid); managerScript.increaseFrameCount(); //here we switch the role of target and agent spatialAStarScript.FindPathSpatial(target.position, agent.position, true, null); path = spaceTimeAStarScript.FindPath(agent.position, target.position, true); followPathScript = agent.GetComponent <FollowPath>(); followPathScript.setNewPath(path); }
void Start() { managerScript = Ref.getManagerGO().GetComponent <Manager>(); gridScript = Ref.getGridScript(); visibleObstManagerScript = GetComponent <VisibleObstManager>(); agentPropsScript = GetComponent <AgentProps>(); saveInitalGrid(); agent = transform; spatialAStarScript = GetComponent <SpatialAStar>(); spatialAStarScript.init(grid); managerScript.increaseFrameCount(); path = spatialAStarScript.FindPathSpatial(agent.position, target.position, true, null); followPathScript = agent.GetComponent <FollowPath>(); followPathScript.init(); followPathScript.setNewPath(path); }
public void restartPath() { Node[,,] gridGlobal = gridScript.getGrid(); foreach (Node node in coveredNodes) { gridScript.markNode(gridGlobal[node.gridX, node.gridY, 0], true); } coveredNodes = visibleObstManagerScript.getAllObstCoveredNodes(); foreach (Node node in coveredNodes) { gridScript.getGrid()[node.gridX, node.gridY, 0].walkable = false; } saveInitalGrid(); spatialAStarScript.init(grid); managerScript.increaseFrameCount(); path = spatialAStarScript.FindPathSpatial(agent.position, target.position, true, null); followPathScript = agent.GetComponent <FollowPath>(); followPathScript.setNewPath(path); }