MazeRoom.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using UnityEngine;
  2. using System.Collections.Generic;
  3. /// <summary>
  4. /// Represents a room in the maze
  5. /// </summary>
  6. public class MazeRoom
  7. {
  8. /// <summary>
  9. /// Types of rooms with different purposes
  10. /// </summary>
  11. public enum RoomType
  12. {
  13. Normal, // Regular room
  14. Safe, // Safe room (no monsters)
  15. Rest, // Resting area (healing)
  16. Restroom, // Restroom (special purpose)
  17. Boss, // Boss room
  18. End, // Exit/End room
  19. }
  20. public int Id { get; set; }
  21. public RoomType Type { get; set; }
  22. public int MinX { get; set; }
  23. public int MinY { get; set; }
  24. public int MaxX { get; set; }
  25. public int MaxY { get; set; }
  26. public int Width => MaxX - MinX + 1;
  27. public int Height => MaxY - MinY + 1;
  28. public List<Vector2Int> Exits { get; set; } = new(); // Connection points to other rooms/hallways
  29. public bool IsStart { get; set; }
  30. public bool IsEnd { get; set; }
  31. public MazeRoom(int id, int minX, int minY, int maxX, int maxY, RoomType type = RoomType.Normal)
  32. {
  33. Id = id;
  34. MinX = minX;
  35. MinY = minY;
  36. MaxX = maxX;
  37. MaxY = maxY;
  38. Type = type;
  39. }
  40. /// <summary>
  41. /// Checks if a point is inside this room
  42. /// </summary>
  43. public bool Contains(int x, int y)
  44. {
  45. return x >= MinX && x <= MaxX && y >= MinY && y <= MaxY;
  46. }
  47. /// <summary>
  48. /// Gets the center of the room
  49. /// </summary>
  50. public Vector2Int GetCenter()
  51. {
  52. return new Vector2Int((MinX + MaxX) / 2, (MinY + MaxY) / 2);
  53. }
  54. /// <summary>
  55. /// Gets a random point inside this room
  56. /// </summary>
  57. public Vector2Int GetRandomPoint()
  58. {
  59. int x = Random.Range(MinX + 1, MaxX);
  60. int y = Random.Range(MinY + 1, MaxY);
  61. return new Vector2Int(x, y);
  62. }
  63. }