| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using UnityEngine;
- /// <summary>
- /// Represents a single 1x1 unit square in the maze
- /// </summary>
- public class MazeTile
- {
- /// <summary>
- /// Types of tiles in the maze
- /// </summary>
- public enum TileType
- {
- Wall, // Impassable
- Floor, // Basic walkable floor
- Terrain, // Special terrain with movement penalties
- }
- /// <summary>
- /// Different terrain types with various properties
- /// </summary>
- public enum TerrainType
- {
- None = 0, // Not terrain
- Normal = 1, // Normal walkable floor (movementCost = 1.0f)
- Swamp = 2, // Slow terrain (movementCost = 2.0f)
- Lava = 3, // Dangerous terrain (movementCost = 3.0f, may cause damage)
- Ice = 4, // Slippery terrain (movementCost = 0.5f, but risky)
- Stone = 5, // Hard stone (movementCost = 1.5f)
- }
- public TileType Type { get; set; }
- public TerrainType Terrain { get; set; }
- public int RoomId { get; set; } // Which room does this tile belong to (-1 = hallway/corridor)
- public int X { get; private set; }
- public int Y { get; private set; }
- public MazeTile(int x, int y)
- {
- X = x;
- Y = y;
- Type = TileType.Wall;
- Terrain = TerrainType.None;
- RoomId = -1;
- }
- /// <summary>
- /// Gets the movement cost for this tile based on its terrain
- /// </summary>
- public float GetMovementCost()
- {
- return Terrain switch
- {
- TerrainType.Normal => 1.0f,
- TerrainType.Swamp => 2.0f,
- TerrainType.Lava => 3.0f,
- TerrainType.Ice => 0.5f,
- TerrainType.Stone => 1.5f,
- _ => 1.0f,
- };
- }
- /// <summary>
- /// Checks if a character can walk on this tile
- /// </summary>
- public bool IsWalkable()
- {
- return Type == TileType.Floor || Type == TileType.Terrain;
- }
- }
|