| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- using UnityEngine;
- using System.Collections.Generic;
- /// <summary>
- /// Represents a room in the maze
- /// </summary>
- public class MazeRoom
- {
- /// <summary>
- /// Types of rooms with different purposes
- /// </summary>
- public enum RoomType
- {
- Normal, // Regular room
- Safe, // Safe room (no monsters)
- Rest, // Resting area (healing)
- Restroom, // Restroom (special purpose)
- Boss, // Boss room
- End, // Exit/End room
- }
- public int Id { get; set; }
- public RoomType Type { get; set; }
- public int MinX { get; set; }
- public int MinY { get; set; }
- public int MaxX { get; set; }
- public int MaxY { get; set; }
- public int Width => MaxX - MinX + 1;
- public int Height => MaxY - MinY + 1;
- public List<Vector2Int> Exits { get; set; } = new(); // Connection points to other rooms/hallways
- public bool IsStart { get; set; }
- public bool IsEnd { get; set; }
- public MazeRoom(int id, int minX, int minY, int maxX, int maxY, RoomType type = RoomType.Normal)
- {
- Id = id;
- MinX = minX;
- MinY = minY;
- MaxX = maxX;
- MaxY = maxY;
- Type = type;
- }
- /// <summary>
- /// Checks if a point is inside this room
- /// </summary>
- public bool Contains(int x, int y)
- {
- return x >= MinX && x <= MaxX && y >= MinY && y <= MaxY;
- }
- /// <summary>
- /// Gets the center of the room
- /// </summary>
- public Vector2Int GetCenter()
- {
- return new Vector2Int((MinX + MaxX) / 2, (MinY + MaxY) / 2);
- }
- /// <summary>
- /// Gets a random point inside this room
- /// </summary>
- public Vector2Int GetRandomPoint()
- {
- int x = Random.Range(MinX + 1, MaxX);
- int y = Random.Range(MinY + 1, MaxY);
- return new Vector2Int(x, y);
- }
- }
|