public Vector3[] GetSolutionPath(IPathTerrain terrain) { if (!HasSuccessfullyCompleted()) { return(null); } LinkedList <Planning.Node> path = GetSolutionPath(); if (path == null || path.Count == 0) { return(null); } Vector3[] pathPoints = new Vector3[path.Count]; int i = 0; foreach (Planning.Node node in path) { Vector3 nodePos = terrain.GetPathNodePos(node.Index); pathPoints[i] = nodePos; i++; } // Set the first position to be the start position pathPoints[0] = GetStartPos(); // Set the last position to be the goal position. int lastIndex = Mathf.Clamp(i, 0, path.Count - 1); System.Diagnostics.Debug.Assert(lastIndex > 1 && lastIndex < path.Count); pathPoints[lastIndex] = GetGoalPos(); return(pathPoints); }
public PathPlanParams_Batch(int startIndex, int[] goalIndexArray, IPathTerrain terrain) { m_startIndex = startIndex; m_goalIndexArray = goalIndexArray; m_goalIndexIdx = 0; m_terrain = terrain; }
public override void Start(Navigation.IPlanningWorld world) { base.Start(world); System.Diagnostics.Debug.Assert(world is IPathTerrain); m_pathTerrain = world as IPathTerrain; }
public void SteerAlongPath(Vector3[] path, IPathTerrain pathTerrain) { //m_pathTerrain = pathTerrain; m_bArrived = false; m_path = new PolylinePathway(path.Length, path); m_path_index = 0; m_seekPos = m_path.Points[m_path_index]; transform.position = m_seekPos; }
public NavTargetGameObject(GameObject targetGameObject, IPathTerrain pathTerrain) { m_targetGameObject = GameObject.FindGameObjectWithTag("Enemy"); m_targetGameObject = targetGameObject; if (m_targetGameObject != null) { m_pathTerrain = pathTerrain; } }
public Vector3[] GetSolutionPath(IPathTerrain terrain) { if (!HasSuccessfullyCompleted()) { return(null); } // LinkedList<Planning.Node> path = GetSolutionPath(); if (m_solutionNodeList == null || m_solutionNodeList.Count == 0) { return(null); } List <int> PathCornerIndexList = null; if (terrain is PathGrid) { PathCornerIndexList = (terrain as PathGrid).CornerIndexs(m_solutionNodeList.ToArray()); } else { Debug.LogError("terrain is not PathGrid"); } Vector3[] pathPoints = new Vector3[PathCornerIndexList.Count]; int i = 0; foreach (int cornerIndex in PathCornerIndexList) { //Debug.Log("node.Index:" + node.Index); Vector3 nodePos = terrain.GetPathNodePos(cornerIndex); pathPoints[i] = nodePos; i++; } // Set the first position to be the start position pathPoints[0] = GetStartPos(); // Set the last position to be the goal position. int lastIndex = Mathf.Clamp(i, 0, PathCornerIndexList.Count - 1); System.Diagnostics.Debug.Assert(lastIndex > 1 && lastIndex < PathCornerIndexList.Count); pathPoints[lastIndex] = GetGoalPos(); return(pathPoints); }
void Start() { if (m_pathTerrainComponent == null) { UnityEngine.Debug.LogError("Must give the PathManagerComponent a reference to the PathTerrainComponent. You can do this through the Unity Editor."); return; } m_terrain = m_pathTerrainComponent.PathTerrain; if (m_terrain == null) { UnityEngine.Debug.LogError("PathTerrain is NULL in PathTerrainComponent. Make sure you have instantiated a path terrain inside the Awake function" + "of your PathTerrainComponent"); return; } foreach (Pool <PathPlanner> .Node planner in m_pathPlannerPool.AllNodes) { planner.Item.Start(m_terrain); } m_bInitialized = true; }
void Start() { if ( m_pathTerrainComponent == null ) { UnityEngine.Debug.LogError("Must give the PathManagerComponent a reference to the PathTerrainComponent. You can do this through the Unity Editor."); return; } m_terrain = m_pathTerrainComponent.PathTerrain; if ( m_terrain == null ) { UnityEngine.Debug.LogError("PathTerrain is NULL in PathTerrainComponent. Make sure you have instantiated a path terrain inside the Awake function" + "of your PathTerrainComponent"); return; } foreach (Pool<PathPlanner>.Node planner in m_pathPlannerPool.AllNodes) { planner.Item.Start(m_terrain); } m_bInitialized = true; }
/// <summary> /// 设置地形. /// </summary> public void SetTerrain(IPathTerrain terrain) { this.terrain = terrain; }
public NavTargetPos(Vector3 targetPos, IPathTerrain pathTerrain) { m_targetPos = targetPos; m_pathTerrain = pathTerrain; }
public void SteerAlongPath(Vector3[] path, IPathTerrain pathTerrain) { m_pathTerrain = pathTerrain; m_bArrived = false; m_path = new PolylinePathway(path.Length, path); }
public NavTargetGameObject(GameObject targetGameObject, IPathTerrain pathTerrain) { m_targetGameObject = targetGameObject; m_pathTerrain = pathTerrain; }
void Awake() { m_path = null; m_bArrived = false; m_pathTerrain = null; }