List <Waypoint> path = new List <Waypoint> (); //todo make private public List <Waypoint> GetPath(Transform end, CustomNavMesh cNavMesh, Waypoint currentNodePos) { startWaypoint = currentNodePos; endWaypoint = TransformToWaypoint(end); ClearAll(); LoadNodes(cNavMesh); BreathFirstSearch(cNavMesh); CreatePath(); return(path); }
private void BreathFirstSearch(CustomNavMesh cNavMesh) { queue.Enqueue(startWaypoint); while (queue.Count > 0 && isRunning) { searchCenter = queue.Dequeue(); HaltIfEndFound(); ExploreNeighbors(cNavMesh.canNotMovePast); searchCenter.isExplored = true; } }
private void LoadNodes(CustomNavMesh cNavMesh) { var waypoints = cNavMesh.points; foreach (Vector2Int waypoint in waypoints) { // overlapping blocks? if (grid.ContainsKey(waypoint)) { Debug.LogWarning("Skipping Overlapping Block " + waypoint); } else { // add to dictionary grid.Add(waypoint, new Waypoint(waypoint)); } } }
// Use this for initialization void Start() { coll = GetComponent <CapsuleCollider2D> (); tracking = transform.position; player = FindObjectOfType <PlayerController> (); pathfinding = GetComponent <Pathfinding> (); cNavMesh = GetComponentInParent <CustomNavMesh> (); myRoom = GetComponentInParent <RoomGeneration> (); roLo = GetComponent <RobotLoadout> (); anims = GetComponentsInChildren <Animator> (); if (enemyType == 0) { basic = GetComponent <BasicEnemy> (); } if (enemyType == 1) { rangeShort = GetComponent <RangeShortEnemy> (); } }