Skip to content

Commit f1a1b79

Browse files
committed
Merge branch 'rob'
2 parents f683628 + 7173857 commit f1a1b79

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

Station/Station/Buggy.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ public void onObstacle()
204204
public void onPathClear()
205205
{
206206
buggyAction("is now able to progress in section " + getSectionName());
207+
go();
207208
}
208209
public void onBuggyParked()
209210
{
@@ -220,6 +221,8 @@ public void onBuggyParked()
220221
else
221222
buggyAction("parked! " + (lapsCompleted - 1) + " lap(s) completed!"); // Buggy 1 has to go an extra lap in 2-buggy mode
222223
}
224+
if (direction == Direction.Clockwise)
225+
Program.print("Challenge complete!", ConsoleColor.Yellow, ConsoleColor.Black);
223226
}
224227
public void onPingRecieved()
225228
{

Station/Station/Communications.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Communications
3737

3838
public Communications()
3939
{
40-
port.PortName = "COM13";
40+
port.PortName = "COM17";
4141
port.BaudRate = 9600;
4242
port.Open();
4343

@@ -95,7 +95,7 @@ public bool send(int buggy_id, string command, Action offlineHandler = null)
9595
{
9696
if (offlineHandler == null)
9797
{
98-
Program.print(" Command " + command + " received after " + reps + " attempts");
98+
Program.print("Command " + command + " received after " + reps + " attempts");
9999
}
100100
return false;
101101
}

Station/Station/Program.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ namespace Station
88
{
99
class Program
1010
{
11+
public static bool inputOn = false;
1112
/// <summary>
1213
/// Only one thread can print at a time
1314
/// This can prevent potential interleaving output from different threads and buggies
@@ -28,8 +29,9 @@ class Program
2829

2930
static void Main(string[] args)
3031
{
31-
Console.WriteLine("Initialising...");
32+
print("Initialising...", ConsoleColor.DarkYellow);
3233
Station station = new Station();
34+
inputOn = true;
3335
while (true)
3436
{
3537
string input = readInput();
@@ -38,7 +40,9 @@ static void Main(string[] args)
3840
Environment.Exit(0);
3941
if (input == "RESET")
4042
{
43+
inputOn = false;
4144
station.setUp();
45+
inputOn = true;
4246
continue;
4347
}
4448

@@ -105,6 +109,8 @@ private static bool executeCommand(Station station, string command, int buggyID)
105109
/// </summary>
106110
private static void printInput()
107111
{
112+
if (!inputOn)
113+
return;
108114
clearInput();
109115
lock (printLock)
110116
{
@@ -213,16 +219,20 @@ public static void print(string message)
213219
/// Prints <c>message</c> with the specified background colour.
214220
/// Adds newline and redraws the input buffer
215221
/// </summary>
216-
public static void print(string message, ConsoleColor? backgroundColor)
222+
public static void print(string message,
223+
ConsoleColor? backgroundColour,
224+
ConsoleColor? foregroundColour = ConsoleColor.Gray)
217225
{
218226
lock (printLock)
219227
{
220228
clearInput();
221229
Console.CursorLeft = 0;
222-
Console.BackgroundColor = backgroundColor ?? emptyColour;
230+
Console.BackgroundColor = backgroundColour ?? emptyColour;
231+
Console.ForegroundColor = foregroundColour ?? ConsoleColor.Gray;
223232
Console.WriteLine(message);
224233
printInput();
225234
Console.BackgroundColor = emptyColour;
235+
Console.ForegroundColor = ConsoleColor.Gray;
226236
}
227237
}
228238
}

0 commit comments

Comments
 (0)