Tile.cs 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. namespace PathfindingPCL
  3. {
  4. internal class Tile : Node
  5. {
  6. protected TileType tileType;
  7. internal int Row { get; set; }
  8. internal int Col { get; set; }
  9. public Tile(TileType _type, int _row, int _col)
  10. {
  11. tileType = _type;
  12. Row = _row;
  13. Col = _col;
  14. }
  15. internal bool IsValidPath()
  16. {
  17. return tileType.Equals(TileType.Bridge) || tileType.Equals(TileType.Grass) || tileType.Equals(TileType.Path);
  18. }
  19. internal double Cost()
  20. {
  21. switch (tileType)
  22. {
  23. case TileType.Path :
  24. return 1;
  25. case TileType.Bridge:
  26. case TileType.Grass:
  27. return 2;
  28. default :
  29. return double.PositiveInfinity;
  30. }
  31. }
  32. public override string ToString()
  33. {
  34. return "[" + Row + ";" + Col + ";" + tileType.ToString() + "]";
  35. }
  36. }
  37. }