TurnBasedAI.cs 977 B

12345678910111213141516171819202122232425
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. namespace Pathfinding.Examples {
  4. /// <summary>Helper script in the example scene 'Turn Based'</summary>
  5. [HelpURL("http://arongranberg.com/astar/docs/class_pathfinding_1_1_examples_1_1_turn_based_a_i.php")]
  6. public class TurnBasedAI : VersionedMonoBehaviour {
  7. public int movementPoints = 2;
  8. public BlockManager blockManager;
  9. public SingleNodeBlocker blocker;
  10. public GraphNode targetNode;
  11. public BlockManager.TraversalProvider traversalProvider;
  12. void Start () {
  13. blocker.BlockAtCurrentPosition();
  14. }
  15. protected override void Awake () {
  16. base.Awake();
  17. // Set the traversal provider to block all nodes that are blocked by a SingleNodeBlocker
  18. // except the SingleNodeBlocker owned by this AI (we don't want to be blocked by ourself)
  19. traversalProvider = new BlockManager.TraversalProvider(blockManager, BlockManager.BlockMode.AllExceptSelector, new List<SingleNodeBlocker>() { blocker });
  20. }
  21. }
  22. }