Guest User

Untitled

a guest
Jul 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. using UnitySteer;
  4.  
  5. /// <summary>
  6. /// Steers a vehicle to follow a path
  7. /// </summary>
  8. /// <remarks>
  9. /// Based on SteerToFollowPath.
  10. /// </remarks>
  11. [RequireComponent (typeof (Navigator))]
  12. public class SteerForAngryAntPath : SteerForPathSimplified
  13. {
  14.  
  15. #region Private fields
  16. Path _angryAntPath;
  17. #endregion
  18.  
  19.  
  20. #region Public properties
  21. /// <summary>
  22. /// Path to follow
  23. /// </summary>
  24. public Path AngryAntPath {
  25. get {
  26. return this._angryAntPath;
  27. }
  28. }
  29.  
  30. #endregion
  31.  
  32. #region Path event handles
  33. void OnNewPath (Path path)
  34. // When pathfinding via Navigator.targetPosition
  35. {
  36. Debug.Log("PATH DONE " +Time.realtimeSinceStartup);
  37. Debug.Log ("Received new Path from " + path.StartNode + " to " + path.EndNode + ". Took " + path.SeekTime + " seconds.");
  38. _angryAntPath = path;
  39. var collect = new C5.ArrayList<Vector3>();
  40. foreach (var s in path.Segments)
  41. {
  42. collect.Add(s.To.Position);
  43. }
  44. collect.Add(path.EndPosition);
  45. Path = new Vector3Pathway(collect, 0.5f, false);
  46. }
  47.  
  48.  
  49. void OnTargetUnreachable ()
  50. // When pathfinding via Navigator.targetPosition
  51. {
  52. Debug.Log ("Could not pathfind to target position");
  53. _angryAntPath = null;
  54. Path = null;
  55. }
  56.  
  57.  
  58. void OnPathAvailable (Path path)
  59. // When pathfinding via Navigator.RequestPath (startPositio, endPosition)
  60. {
  61. Debug.Log ("Requested Path from " + path.StartNode + " to " + path.EndNode + " is now available. Took " + path.SeekTime + " seconds.");
  62. }
  63.  
  64.  
  65. void OnPathUnavailable ()
  66. // When pathfinding via Navigator.RequestPath (startPositio, endPosition)
  67. {
  68. Debug.Log ("The requested path could not be established.");
  69. }
  70.  
  71.  
  72. void OnPathInvalidated (Path path)
  73. // When a path requested by a Navigator on this GameObject is no longer valid - due to a connection or node disabling or removal
  74. {
  75. Debug.Log ("The path from " + path.StartNode + " to " + path.EndNode + " is no longer valid.");
  76. }
  77.  
  78.  
  79.  
  80. void OnDrawGizmos()
  81. {
  82. if (_angryAntPath != null)
  83. {
  84. _angryAntPath.OnDrawGizmos();
  85. }
  86. }
  87. #endregion
  88. }
Add Comment
Please, Sign In to add comment