This repository has been archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Common.cs
69 lines (61 loc) · 1.95 KB
/
Common.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Collections.Generic;
namespace LevelGenerator
{
/// This class holds the project common functions and constants.
public static class Common
{
/// Unknown reference.
public static readonly int UNKNOWN = -1;
/// The directions in which a room may connect to other rooms.
///
/// The direction `up` is not listed here to avoid positioning conflict
/// during the room placement.
public enum Direction
{
Right = 0,
Down = 1,
Left = 2
};
/// Return the array of all weapon types.
public static Direction[] AllDirections()
{
return (Direction[]) Enum.GetValues(typeof(Direction));
}
/// Define the room codes for printing purposes.
public enum RoomCode
{
N = 0, // Room
C = 100, // Corridor
B = 101, // Boss room or dungeon exit
E = 102, // Empty space
}
/// Return a random integer percentage (from 0 to 99, 100 numbers).
public static int RandomPercent(
ref Random _rand
) {
return _rand.Next(100);
}
/// Return a random integer number from the entered inclusive range.
public static int RandomInt(
(int min, int max) _range,
ref Random _rand
) {
return _rand.Next(_range.min, _range.max + 1);
}
/// Return a random element from the entered array.
public static T RandomElementFromArray<T>(
T[] _range,
ref Random _rand
) {
return _range[_rand.Next(0, _range.Length)];
}
/// Return a random element from the entered list.
public static T RandomElementFromList<T>(
List<T> _range,
ref Random _rand
) {
return _range[_rand.Next(0, _range.Count)];
}
}
}