From dbf0218371ce006b674b0ede8e6a4d97932ff2c6 Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Tue, 1 Aug 2023 01:31:25 +0100 Subject: Add footprints --- code/phase/AssignPhase.cs | 49 ++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'code/phase/AssignPhase.cs') diff --git a/code/phase/AssignPhase.cs b/code/phase/AssignPhase.cs index f29aa62..f69ca7b 100644 --- a/code/phase/AssignPhase.cs +++ b/code/phase/AssignPhase.cs @@ -3,11 +3,10 @@ using Sandbox.UI; using System; using System.Collections.Generic; using System.Linq; -using System.Net.Http.Headers; namespace MurderGame; -public class AssignPhase : BasePhase +public partial class AssignPhase : BasePhase { public override string Title => "Assigning teams"; public int TicksElapsed; @@ -42,18 +41,18 @@ public class AssignPhase : BasePhase "Zulu" }; - private List HexColours = new() + private List Colors = new() { - "#0074D9", // blue - "#7FDBFF", // aqua - "#39CCCC", // teal - "#F012BE", // fuchsia - "#FF4136", // red - "#FF851B", // orange - "#FFDC00", // yellow - "#3D9970", // olive - "#2ECC40", // lime - "#01FF70" // green + 0x0074D9, // blue + 0x7FDBFF, // aqua + 0x39CCCC, // teal + 0xF012BE, // fuchsia + 0xFF4136, // red + 0xFF851B, // orange + 0xFFDC00, // yellow + 0x3D9970, // olive + 0x2ECC40, // lime + 0x01FF70 // green }; public override void Activate() @@ -63,17 +62,18 @@ public class AssignPhase : BasePhase { entity.Delete(); } + DeleteFootprints(); // cleanup -- end var detectivesNeeded = 1; var murderersNeeded = 1; - Random random = new(); + Random random = new(Guid.NewGuid().GetHashCode()); var spawnPoints = Entity.All.OfType().OrderBy( _ => random.Next() ).ToList(); var clients = Game.Clients.ToList().OrderBy( _ => random.Next() ); var natoNamesRemaining = new List(NatoNames.OrderBy( _ => random.Next() )); - var coloursRemaining = new List(HexColours.OrderBy( _ => random.Next() )); + var colorsRemaining = new List(Colors.OrderBy( _ => random.Next() )); foreach ( var client in clients ) { @@ -99,9 +99,9 @@ public class AssignPhase : BasePhase { natoNamesRemaining = new List(NatoNames); } - if (coloursRemaining.Count == 0) + if (colorsRemaining.Count == 0) { - coloursRemaining = new List(HexColours); + colorsRemaining = new List(Colors); } // assign team @@ -134,15 +134,24 @@ public class AssignPhase : BasePhase pawn.CharacterName = natoName; // assign nato name - var hexColour = coloursRemaining[0]; - coloursRemaining.RemoveAt( 0 ); - pawn.HexColor = hexColour; + var hexColor = colorsRemaining[0]; + colorsRemaining.RemoveAt( 0 ); + pawn.Color = Color.FromRgb(hexColor); RoleOverlay.Show( To.Single( client ) ); } base.TimeLeft = 5; } + [ClientRpc] + public static void DeleteFootprints() + { + foreach (var entity in Entity.All.OfType()) + { + entity.Delete(); + } + } + public override void Deactivate() { foreach (var client in Game.Clients) -- cgit v1.2.3-70-g09d2