diff --git a/code/Constants.cs b/code/Constants.cs new file mode 100644 index 0000000..d382e59 --- /dev/null +++ b/code/Constants.cs @@ -0,0 +1,5 @@ +public static class Constants +{ + public readonly static Vector3 + TOPDOWN_CAMERA_POSITION = new Vector3(0f, 0f, 280f); +} diff --git a/code/EntityComponents/Lucker/Cameras/AbstractCamera.cs b/code/EntityComponents/Lucker/Cameras/AbstractCamera.cs index 3a48e06..f22e0c7 100644 --- a/code/EntityComponents/Lucker/Cameras/AbstractCamera.cs +++ b/code/EntityComponents/Lucker/Cameras/AbstractCamera.cs @@ -6,7 +6,7 @@ namespace LuckerGame.Components.Lucker.Cameras; public abstract partial class AbstractCamera : EntityComponent, ISingletonComponent { public virtual bool ShouldShowCursor => false; - protected Vector3 CameraPosition { get; set; } + public Vector3 CameraPosition { get; set; } protected Rotation CameraRotation { get; set; } protected float FieldOfView { get; set; } protected IEntity FirstPersonViewer { get; set; } diff --git a/code/Minigames/TerryRaces/Racer.cs b/code/Minigames/TerryRaces/Racer.cs new file mode 100644 index 0000000..faef72f --- /dev/null +++ b/code/Minigames/TerryRaces/Racer.cs @@ -0,0 +1,9 @@ +using LuckerGame.Entities; +using Sandbox; + +namespace Sandbox.Minigames.TerryRaces; + +public class Racer : Pawn +{ + +} diff --git a/code/Minigames/TerryRaces/TerryRacesMinigame.cs b/code/Minigames/TerryRaces/TerryRacesMinigame.cs index 73a8204..81e4c2d 100644 --- a/code/Minigames/TerryRaces/TerryRacesMinigame.cs +++ b/code/Minigames/TerryRaces/TerryRacesMinigame.cs @@ -6,6 +6,7 @@ using LuckerGame.Components.Lucker.Cameras; using LuckerGame.Components.Pawn; using LuckerGame.Entities; using Sandbox; +using Sandbox.Minigames.TerryRaces; using Sandbox.UI; namespace LuckerGame.Minigames.TerryRaces; @@ -15,31 +16,38 @@ public class TerryRaces : Minigame { public override string Name => "Terry Races"; private List Players { get; set; } - private FixedCamera camera; + private FixedCamera Camera; + private List Racers { get; set; } + private float StartingY = 290f; + private float StartingX = 90f; + private float RacerXOffset = 60f; + private int NumberOfRacers = 4; public override void Initialize( List players ) { Players = players; + // Setup cameras for players Players.ForEach( player => { - camera = player.Components.Create(); - camera.LookAt( new Vector3( -110f, 4f, 180f ), Rotation.FromPitch( 45 ) ); - camera.FieldOfViewValue = 120f; + Camera = player.Components.Create(); + Camera.LookAt( Constants.TOPDOWN_CAMERA_POSITION, Rotation.FromPitch( -270 ) ); + Camera.FieldOfViewValue = 100f; } ); - Players.Select( ( player, i ) => (Player: player, Index: i) ).ToList().ForEach( pair => + // SpawnRacers(); + } + + private void SpawnRacers() + { + for ( int i = 0; i < NumberOfRacers; i++ ) { - var player = pair.Player; - var index = pair.Index; - var pawn = new Pawn(); - pawn.Name = player.Name; - pawn.Tags.Add( "victim" ); - pawn.Health = 1; - player.Pawn = pawn; - pawn.DressFromClient( player.Client ); - - } ); + var racer = new Racer(); + var x = StartingX - RacerXOffset * i; + racer.Position = new Vector3( x, StartingY, 0 ); + racer.Rotation = Rotation.FromPitch( -90 ); + Racers.Add( racer ); + } } public override void Tick()