-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathStatics.cs
160 lines (142 loc) · 5.59 KB
/
Statics.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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
namespace Console_Monsters;
public static class Statics
{
#region Options
public static bool DisableMovementAnimation { get; set; } = false;
public static bool DisableBattle { get; set; } = false;
public static bool DisableBattleTransition { get; set; } = false;
public static bool FirstTimeLaunching { get; set; } = true;
public static bool AudioEnabled { get; set; } = true;
#endregion
public readonly static Random BattleTransitionRandom = new();
public readonly static Random GameRandom = new(7);
public readonly static Random BattleRandom = new(7);
public readonly static Player character = new();
public readonly static List<MonsterBase> ownedMonsters = new();
public readonly static List<MonsterBase> partyMonsters = new();
public readonly static Dictionary<ConsoleKey, UserKeyPress> keyMappings = new();
public readonly static Dictionary<UserKeyPress, (ConsoleKey Main, ConsoleKey? Alternate)> reverseKeyMappings = new();
private static MapBase map = null!;
public static MapBase Map
{
get => map;
set
{
map = value;
if (map is not null && map.AudioFile is not null)
{
AudioController.PlaySound(map.AudioFile);
}
else
{
AudioController.StopSound();
}
}
}
public static DateTime PrevioiusRender { get; set; } = DateTime.Now;
public const int MaxPartySize = 6;
public static bool GameRunning { get; set; } = true;
public static bool StartMenu { get; set; } = true;
public static bool InInventory { get; set; } = false;
public static string[] DefaultMaptext => new[]
{
$" [{reverseKeyMappings[UserKeyPress.Up].ToDisplayString()}]: Up" +
$" [{reverseKeyMappings[UserKeyPress.Left].ToDisplayString()}]: Left" +
$" [{reverseKeyMappings[UserKeyPress.Down].ToDisplayString()}]: Down" +
$" [{reverseKeyMappings[UserKeyPress.Right].ToDisplayString()}]: Right" +
$" [{reverseKeyMappings[UserKeyPress.Status].ToDisplayString()}]: Status" +
$" [{reverseKeyMappings[UserKeyPress.Escape].ToDisplayString()}]: Menu",
};
public static string[] DefaultMaptextWithInteract => new[]
{
$" [{reverseKeyMappings[UserKeyPress.Up].ToDisplayString()}]: Up" +
$" [{reverseKeyMappings[UserKeyPress.Left].ToDisplayString()}]: Left" +
$" [{reverseKeyMappings[UserKeyPress.Down].ToDisplayString()}]: Down" +
$" [{reverseKeyMappings[UserKeyPress.Right].ToDisplayString()}]: Right" +
$" [{reverseKeyMappings[UserKeyPress.Status].ToDisplayString()}]: Status" +
$" [{reverseKeyMappings[UserKeyPress.Escape].ToDisplayString()}]: Menu" +
$" [{reverseKeyMappings[UserKeyPress.Action].ToDisplayString()}]: Action",
};
public static string[] MapTextPressEnter => new string[]
{
$" [{reverseKeyMappings[UserKeyPress.Confirm].ToDisplayString()}]: Confirm" +
$" [{reverseKeyMappings[UserKeyPress.Action].ToDisplayString()}]: Exit Dialogue" +
$" [{reverseKeyMappings[UserKeyPress.Escape].ToDisplayString()}]: Menu",
};
public static string[] MapText
{
get
{
if (PromptText is not null)
{
return MapTextPressEnter;
}
if (character.IsIdle)
{
var interactTile = character.InteractTile;
if (Map.CanInteractWithMapTile(interactTile.I, interactTile.J))
{
return DefaultMaptextWithInteract;
}
}
return DefaultMaptext;
}
}
public static string[] BattleText => new[]
{
$"Battles are still in development.",
$"Let's just pretend you won this battle. :D",
$"[{reverseKeyMappings[UserKeyPress.Confirm].ToDisplayString()}]: exit battle"
};
public static string[]? PromptText { get; set; } = null;
public static int SelectedPlayerInventoryItem { get; set; } = 0;
public static readonly Towel.DataStructures.IBag<ItemBase> PlayerInventory = Towel.DataStructures.BagMap.New<ItemBase>();
static Statics()
{
character = new()
{
Animation = Player.IdleDown,
};
PlayerInventory.TryAdd(ExperienceBerries.Instance);
PlayerInventory.TryAdd(HealthPotionLarge.Instance);
PlayerInventory.TryAdd(HealthPotionMedium.Instance);
PlayerInventory.TryAdd(HealthPotionSmall.Instance);
PlayerInventory.TryAdd(MonsterBox.Instance);
PlayerInventory.TryAdd(Mushroom.Instance);
PlayerInventory.TryAdd(Leaf.Instance);
PlayerInventory.TryAdd(Key.Instance);
PlayerInventory.TryAdd(Candle.Instance);
DefaultKeyMappings();
partyMonsters.Clear();
partyMonsters.Add(new Turtle());
}
[System.Diagnostics.DebuggerHidden]
public static (int, int) Subtract((int, int) a, (int, int) b) => (a.Item1 - b.Item1, a.Item2 - b.Item2);
[System.Diagnostics.DebuggerHidden]
public static (int, int) Modulus((int, int) a, (int?, int?) b) => (b.Item1 is null ? a.Item1 : a.Item1 % b.Item1.Value, b.Item2 is null ? a.Item2 : a.Item2 % b.Item2.Value);
public static void DefaultKeyMappings()
{
reverseKeyMappings.Clear();
reverseKeyMappings.Add(UserKeyPress.Up, (ConsoleKey.UpArrow, ConsoleKey.W));
reverseKeyMappings.Add(UserKeyPress.Down, (ConsoleKey.DownArrow, ConsoleKey.S));
reverseKeyMappings.Add(UserKeyPress.Left, (ConsoleKey.LeftArrow, ConsoleKey.A));
reverseKeyMappings.Add(UserKeyPress.Right, (ConsoleKey.RightArrow, ConsoleKey.D));
reverseKeyMappings.Add(UserKeyPress.Confirm, (ConsoleKey.Enter, null));
reverseKeyMappings.Add(UserKeyPress.Action, (ConsoleKey.E, null));
reverseKeyMappings.Add(UserKeyPress.Status, (ConsoleKey.B, null));
reverseKeyMappings.Add(UserKeyPress.Escape, (ConsoleKey.Escape, null));
ApplyKeyMappings();
}
public static void ApplyKeyMappings()
{
keyMappings.Clear();
foreach (var pair in reverseKeyMappings)
{
keyMappings.Add(pair.Value.Main, pair.Key);
if (pair.Value.Alternate is not null)
{
keyMappings.Add(pair.Value.Alternate.Value, pair.Key);
}
}
}
}