aboutsummaryrefslogtreecommitdiffstats
path: root/code/phase/WaitPhase.cs
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.com>2023-07-27 22:11:31 +0100
committerLeonardo Bishop <me@leonardobishop.com>2023-07-27 22:11:31 +0100
commit71db52c5443a7bf82d9a23a770994a42b043be04 (patch)
treef75f2605bb1bdc53842cd85c90d105dcc77e1c10 /code/phase/WaitPhase.cs
Initial commit
Diffstat (limited to 'code/phase/WaitPhase.cs')
-rw-r--r--code/phase/WaitPhase.cs43
1 files changed, 43 insertions, 0 deletions
diff --git a/code/phase/WaitPhase.cs b/code/phase/WaitPhase.cs
new file mode 100644
index 0000000..4f2e876
--- /dev/null
+++ b/code/phase/WaitPhase.cs
@@ -0,0 +1,43 @@
+using Sandbox;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MurderGame;
+
+public class WaitPhase : BasePhase
+{
+ public override string Title => "Waiting for players";
+ public bool CountIn { get; set; }
+ public int TicksElapsed { get; set; }
+
+ private bool _isCountDown { get; set; }
+
+ public override void Tick()
+ {
+ if (Game.Clients.Count >= MurderGame.MinPlayers)
+ {
+ if (!CountIn || (_isCountDown && ++TicksElapsed % Game.TickRate == 0 && --base.TimeLeft == 0))
+ {
+ base.NextPhase = new AssignPhase();
+ base.IsFinished = true;
+ }
+ else if (CountIn && !_isCountDown)
+ {
+ _isCountDown = true;
+ base.TimeLeft = 10;
+ }
+ } else if (CountIn && _isCountDown)
+ {
+ _isCountDown = false;
+ base.TimeLeft = -1;
+ }
+ }
+
+ public override void HandleClientJoin( ClientJoinedEvent e )
+ {
+
+ }
+}