MazeTile.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UnityEngine;
  2. /// <summary>
  3. /// Represents a single 1x1 unit square in the maze
  4. /// </summary>
  5. public class MazeTile
  6. {
  7. /// <summary>
  8. /// Types of tiles in the maze
  9. /// </summary>
  10. public enum TileType
  11. {
  12. Wall, // Impassable
  13. Floor, // Basic walkable floor
  14. Terrain, // Special terrain with movement penalties
  15. }
  16. /// <summary>
  17. /// Different terrain types with various properties
  18. /// </summary>
  19. public enum TerrainType
  20. {
  21. None = 0, // Not terrain
  22. Normal = 1, // Normal walkable floor (movementCost = 1.0f)
  23. Swamp = 2, // Slow terrain (movementCost = 2.0f)
  24. Lava = 3, // Dangerous terrain (movementCost = 3.0f, may cause damage)
  25. Ice = 4, // Slippery terrain (movementCost = 0.5f, but risky)
  26. Stone = 5, // Hard stone (movementCost = 1.5f)
  27. }
  28. public TileType Type { get; set; }
  29. public TerrainType Terrain { get; set; }
  30. public int RoomId { get; set; } // Which room does this tile belong to (-1 = hallway/corridor)
  31. public int X { get; private set; }
  32. public int Y { get; private set; }
  33. public MazeTile(int x, int y)
  34. {
  35. X = x;
  36. Y = y;
  37. Type = TileType.Wall;
  38. Terrain = TerrainType.None;
  39. RoomId = -1;
  40. }
  41. /// <summary>
  42. /// Gets the movement cost for this tile based on its terrain
  43. /// </summary>
  44. public float GetMovementCost()
  45. {
  46. return Terrain switch
  47. {
  48. TerrainType.Normal => 1.0f,
  49. TerrainType.Swamp => 2.0f,
  50. TerrainType.Lava => 3.0f,
  51. TerrainType.Ice => 0.5f,
  52. TerrainType.Stone => 1.5f,
  53. _ => 1.0f,
  54. };
  55. }
  56. /// <summary>
  57. /// Checks if a character can walk on this tile
  58. /// </summary>
  59. public bool IsWalkable()
  60. {
  61. return Type == TileType.Floor || Type == TileType.Terrain;
  62. }
  63. }