101 lines
No EOL
2.6 KiB
C#
101 lines
No EOL
2.6 KiB
C#
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using Unity.VisualScripting;
|
|
|
|
namespace DungeonGenerator
|
|
{
|
|
public enum RoomType
|
|
{
|
|
Normal,
|
|
Entrance,
|
|
Monster,
|
|
Boss
|
|
}
|
|
|
|
public class Room
|
|
{
|
|
public Room(RoomType roomType, int width, int height, Point positionOfTopLeft)
|
|
{
|
|
TypeOfRoom = roomType;
|
|
Width = width;
|
|
Height = height;
|
|
PositionOfTopLeft = positionOfTopLeft;
|
|
}
|
|
|
|
private List<Room> _topAdjacentRooms = new List<Room>();
|
|
private List<Room> _bottomAdjacentRooms = new List<Room>();
|
|
private List<Room> _leftAdjacentRooms = new List<Room>();
|
|
private List<Room> _rightAdjacentRooms = new List<Room>();
|
|
|
|
public RoomType TypeOfRoom { get; set; }
|
|
public int Height { get; set; }
|
|
public int Width { get; set; }
|
|
public Point PositionOfTopLeft { get; set; }
|
|
|
|
public List<Point> GetPointsInRoom()
|
|
{
|
|
List<Point> points = new List<Point>();
|
|
for (int i = 0; i < Width; i++)
|
|
{
|
|
for (int j = 0; j < Height; j++)
|
|
{
|
|
points.Add(new Point(PositionOfTopLeft.X + i, PositionOfTopLeft.Y + j));
|
|
}
|
|
}
|
|
|
|
return points;
|
|
}
|
|
|
|
public int GetDistanceToRoom(Room other)
|
|
{
|
|
Point centerOfRoom = GetCenterOfRoom();
|
|
Point centerOfOther = other.GetCenterOfRoom();
|
|
return centerOfRoom.ManhattanDistance(centerOfOther);
|
|
}
|
|
|
|
public Point GetCenterOfRoom()
|
|
{
|
|
return new Point(PositionOfTopLeft.X + Width / 2, PositionOfTopLeft.Y + Height / 2);
|
|
}
|
|
|
|
public void AddTopAdjacentRoom(Room room)
|
|
{
|
|
_topAdjacentRooms.Add(room);
|
|
}
|
|
|
|
public List<Room> GetTopAdjaceRooms()
|
|
{
|
|
return _topAdjacentRooms;
|
|
}
|
|
|
|
public void AddBottomAdjacentRoom(Room room)
|
|
{
|
|
_bottomAdjacentRooms.Add(room);
|
|
}
|
|
|
|
public List<Room> GetBottomAdjaceRooms()
|
|
{
|
|
return _bottomAdjacentRooms;
|
|
}
|
|
|
|
public void AddLeftAdjacentRoom(Room room)
|
|
{
|
|
_leftAdjacentRooms.Add(room);
|
|
}
|
|
|
|
public List<Room> GetLeftAdjaceRooms()
|
|
{
|
|
return _leftAdjacentRooms;
|
|
}
|
|
|
|
public void AddRightAdjacentRoom(Room room)
|
|
{
|
|
_rightAdjacentRooms.Add(room);
|
|
}
|
|
|
|
public List<Room> GetRightAdjaceRooms()
|
|
{
|
|
return _rightAdjacentRooms;
|
|
}
|
|
}
|
|
} |