Tile.cs 859 B

123456789101112131415161718192021222324252627282930313233343536
  1. using UnityEngine;
  2. [System.Serializable]
  3. public class MapTile
  4. {
  5. public TerrainType terrainType;
  6. public FeatureType featureType;
  7. public int x, y;
  8. public float height;
  9. public bool isWalkable;
  10. public string name; // For towns/villages
  11. public MapTile(int x, int y)
  12. {
  13. this.x = x;
  14. this.y = y;
  15. this.terrainType = TerrainType.Plains;
  16. this.featureType = FeatureType.None;
  17. this.height = 0f;
  18. this.isWalkable = true;
  19. this.name = string.Empty;
  20. }
  21. public bool IsWater()
  22. {
  23. return terrainType == TerrainType.Ocean ||
  24. terrainType == TerrainType.Lake ||
  25. terrainType == TerrainType.River;
  26. }
  27. public bool CanBuildOn()
  28. {
  29. return terrainType == TerrainType.Plains &&
  30. featureType == FeatureType.None;
  31. }
  32. }