-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtility.cs
More file actions
96 lines (92 loc) · 2.88 KB
/
Utility.cs
File metadata and controls
96 lines (92 loc) · 2.88 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TextEngine.Models;
namespace TextEngine
{
public static class Utility
{
public static Direction StringToDirection(string dir)
{
switch(dir)
{
case "n":
case "north":
return Direction.North;
case "s":
case "south":
return Direction.South;
case "e":
case "east":
return Direction.East;
case "w":
case "west":
return Direction.West;
case "nw":
case "northwest":
return Direction.Northwest;
case "ne":
case "northeast":
return Direction.Northeast;
case "sw":
case "southwest":
return Direction.Southwest;
case "se":
case "southeast":
return Direction.Southeast;
case "u":
case "up":
return Direction.Up;
case "d":
case "down":
return Direction.Down;
default:
return Direction.None;
}
}
public static Direction DirectionOpposite(Direction dir)
{
switch (dir)
{
case Direction.South:
return Direction.North;
case Direction.North:
return Direction.South;
case Direction.West:
return Direction.East;
case Direction.East:
return Direction.West;
case Direction.Southeast:
return Direction.Northwest;
case Direction.Southwest:
return Direction.Northeast;
case Direction.Northeast:
return Direction.Southwest;
case Direction.Northwest:
return Direction.Southeast;
case Direction.Down:
return Direction.Up;
case Direction.Up:
return Direction.Down;
default:
return Direction.None;
}
}
public static void Print(ConsoleColor color, string message)
{
ConsoleColor c = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(message);
Console.ForegroundColor = c;
}
public static void ProcessCombat()
{
foreach(Monster m in Program.character.CurrentRoom.Monsters)
{
m.Attack();
}
}
}
}