Created
February 24, 2011 08:09
-
-
Save ricardojmendez/841909 to your computer and use it in GitHub Desktop.
Draft seeker using AngryAnt's Path 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using UnityEngine; | |
using UnitySteer; | |
/// <summary> | |
/// Steers a vehicle to follow a path | |
/// </summary> | |
/// <remarks> | |
/// Based on SteerToFollowPath. | |
/// </remarks> | |
[RequireComponent (typeof (Navigator))] | |
public class SteerForAngryAntPath : SteerForPathSimplified | |
{ | |
#region Private fields | |
Path _angryAntPath; | |
#endregion | |
#region Public properties | |
/// <summary> | |
/// Path to follow | |
/// </summary> | |
public Path AngryAntPath { | |
get { | |
return this._angryAntPath; | |
} | |
} | |
#endregion | |
#region Path event handles | |
void OnNewPath (Path path) | |
// When pathfinding via Navigator.targetPosition | |
{ | |
Debug.Log("PATH DONE " +Time.realtimeSinceStartup); | |
Debug.Log ("Received new Path from " + path.StartNode + " to " + path.EndNode + ". Took " + path.SeekTime + " seconds."); | |
_angryAntPath = path; | |
var collect = new C5.ArrayList<Vector3>(); | |
foreach (var s in path.Segments) | |
{ | |
collect.Add(s.To.Position); | |
} | |
collect.Add(path.EndPosition); | |
Path = new Vector3Pathway(collect, 0.5f, false); | |
} | |
void OnTargetUnreachable () | |
// When pathfinding via Navigator.targetPosition | |
{ | |
Debug.Log ("Could not pathfind to target position"); | |
_angryAntPath = null; | |
Path = null; | |
} | |
void OnPathAvailable (Path path) | |
// When pathfinding via Navigator.RequestPath (startPositio, endPosition) | |
{ | |
Debug.Log ("Requested Path from " + path.StartNode + " to " + path.EndNode + " is now available. Took " + path.SeekTime + " seconds."); | |
} | |
void OnPathUnavailable () | |
// When pathfinding via Navigator.RequestPath (startPositio, endPosition) | |
{ | |
Debug.Log ("The requested path could not be established."); | |
} | |
void OnPathInvalidated (Path path) | |
// When a path requested by a Navigator on this GameObject is no longer valid - due to a connection or node disabling or removal | |
{ | |
Debug.Log ("The path from " + path.StartNode + " to " + path.EndNode + " is no longer valid."); | |
} | |
void OnDrawGizmos() | |
{ | |
if (_angryAntPath != null) | |
{ | |
_angryAntPath.OnDrawGizmos(); | |
} | |
} | |
#endregion | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment