AStarNode.cs 752 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. public class AStarNode : IPathNode<object>
  3. {
  4. public enum Type
  5. {
  6. Empty = 0,
  7. Wall = 1,
  8. BlueWall = 2,
  9. RedWall = 3,
  10. YellowWall = 4
  11. }
  12. public static Type[] TypeArr = new Type[]{Type.Empty, Type.Wall, Type.BlueWall, Type.RedWall, Type.YellowWall};
  13. public Int32 X { get; set; }
  14. public Int32 Y { get; set; }
  15. public Type type {get; set;}
  16. public bool IsWalkable(object obj)
  17. {
  18. if(type == Type.Wall)
  19. return false;
  20. if(type == Type.Empty)
  21. return true;
  22. Craft craft = obj as Craft;
  23. if(craft != null)
  24. {
  25. if(craft.team == TeamUtil.Team.Blue && type == Type.BlueWall)
  26. {
  27. return true;
  28. }
  29. else if(craft.team == TeamUtil.Team.Red && type == Type.RedWall)
  30. {
  31. return true;
  32. }
  33. }
  34. return false;
  35. }
  36. }