Implemented randomly dispersing monster rooms.
This commit is contained in:
parent
5895a9f878
commit
9c02b11299
12 changed files with 394 additions and 0 deletions
25
PuzzleGameProject/Assets/Scripts/DungeonGenerator/Point.cs
Normal file
25
PuzzleGameProject/Assets/Scripts/DungeonGenerator/Point.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
|
||||
namespace DungeonGenerator
|
||||
{
|
||||
public struct Point
|
||||
{
|
||||
public int X { get; }
|
||||
public int Y { get; }
|
||||
|
||||
public Point(int x, int y) {
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
public override bool Equals(object obj) => obj is Point p && X == p.X && Y == p.Y;
|
||||
public override int GetHashCode() => HashCode.Combine(X, Y);
|
||||
|
||||
public override string ToString() => $"({X}, {Y})";
|
||||
|
||||
public static Point operator +(Point a, Point b) => new Point(a.X + b.X, a.Y + b.Y);
|
||||
public static Point operator -(Point a, Point b) => new Point(a.X - b.X, a.Y - b.Y);
|
||||
|
||||
public int ManhattanDistance(Point other) => Math.Abs(X - other.X) + Math.Abs(Y - other.Y);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue