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