More russian roulette setup
This commit is contained in:
@@ -46,4 +46,13 @@ public partial class MinigameManager : Entity
|
|||||||
{
|
{
|
||||||
FindMinigames();
|
FindMinigames();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Tick()
|
||||||
|
{
|
||||||
|
if ( LoadedMinigame is not { IsValid: true } )
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
LoadedMinigame.Tick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,11 @@ public partial class RoundManager : Entity
|
|||||||
Log.Info( "Starting round" );
|
Log.Info( "Starting round" );
|
||||||
StartRound();
|
StartRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( RoundState == RoundState.InProgress )
|
||||||
|
{
|
||||||
|
MinigameManager.Tick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -117,4 +122,10 @@ public partial class RoundManager : Entity
|
|||||||
Players = All.OfType<Lucker>().ToList();
|
Players = All.OfType<Lucker>().ToList();
|
||||||
MinigameManager.StartRandomMinigame( Players );
|
MinigameManager.StartRandomMinigame( Players );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ConCmd.Server("start_round")]
|
||||||
|
public static void ForceStart()
|
||||||
|
{
|
||||||
|
Entity.All.OfType<RoundManager>().FirstOrDefault()?.StartRound();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ using Sandbox;
|
|||||||
|
|
||||||
namespace LuckerGame.Components.Lucker.Cameras;
|
namespace LuckerGame.Components.Lucker.Cameras;
|
||||||
|
|
||||||
public abstract class AbstractCamera : EntityComponent<Entities.Lucker>
|
public abstract class AbstractCamera : EntityComponent<Entities.Lucker>, ISingletonComponent
|
||||||
{
|
{
|
||||||
|
public virtual bool ShouldShowCursor => false;
|
||||||
protected Vector3 CameraPosition { get; set; }
|
protected Vector3 CameraPosition { get; set; }
|
||||||
protected Rotation CameraRotation { get; set; }
|
protected Rotation CameraRotation { get; set; }
|
||||||
protected float FieldOfView { get; set; }
|
protected float FieldOfView { get; set; }
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace LuckerGame.Components.Lucker.Cameras;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class RTSCamera : AbstractCamera, ISingletonComponent
|
public partial class RTSCamera : AbstractCamera, ISingletonComponent
|
||||||
{
|
{
|
||||||
|
public override bool ShouldShowCursor => true;
|
||||||
private const float MaxDistance = 400f;
|
private const float MaxDistance = 400f;
|
||||||
private const float MinDistance = 200f;
|
private const float MinDistance = 200f;
|
||||||
private const float Speed = 4f;
|
private const float Speed = 4f;
|
||||||
|
|||||||
@@ -7,12 +7,21 @@ namespace LuckerGame.Minigames;
|
|||||||
|
|
||||||
public abstract class Minigame : Entity
|
public abstract class Minigame : Entity
|
||||||
{
|
{
|
||||||
public abstract string Name { get; }
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes the minigame with a list of luckers playing it
|
/// The name of this minigame
|
||||||
|
/// </summary>
|
||||||
|
public abstract string Name { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the minigame with a list of luckers playing it.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="players">the players who made it into the minigame</param>
|
/// <param name="players">the players who made it into the minigame</param>
|
||||||
public abstract void Initialize(List<Lucker> players);
|
public abstract void Initialize(List<Lucker> players);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Once a minigame is loaded and initialized, this method is called once per server tick.
|
||||||
|
/// </summary>
|
||||||
|
public abstract void Tick();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cleans up any entities and components created by this minigame.
|
/// Cleans up any entities and components created by this minigame.
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using LuckerGame.Components.Lucker.Cameras;
|
||||||
using LuckerGame.Entities;
|
using LuckerGame.Entities;
|
||||||
using Sandbox;
|
using Sandbox;
|
||||||
|
|
||||||
@@ -9,28 +10,51 @@ namespace LuckerGame.Minigames.RussianRoulette;
|
|||||||
public class RussianRouletteMinigame : Minigame
|
public class RussianRouletteMinigame : Minigame
|
||||||
{
|
{
|
||||||
public override string Name => "Russian Roulette";
|
public override string Name => "Russian Roulette";
|
||||||
|
private List<Lucker> Players { get; set; }
|
||||||
|
private Pawn Shooter { get; set; }
|
||||||
|
private const float ShooterDistance = 50f;
|
||||||
|
private const int CardinalDirections = 4;
|
||||||
|
|
||||||
public override void Initialize( List<Lucker> players )
|
public override void Initialize( List<Lucker> players )
|
||||||
{
|
{
|
||||||
var pawn = new Pawn();
|
Players = players;
|
||||||
|
Shooter = new Pawn();
|
||||||
|
|
||||||
// Get all of the spawnpoints
|
/*// Spawn shooter at a random spawnpoint
|
||||||
var spawnpoints = Entity.All.OfType<SpawnPoint>();
|
var spawnpoints = Entity.All.OfType<SpawnPoint>();
|
||||||
|
|
||||||
// chose a random one
|
|
||||||
var randomSpawnPoint = spawnpoints.OrderBy( x => Guid.NewGuid() ).FirstOrDefault();
|
var randomSpawnPoint = spawnpoints.OrderBy( x => Guid.NewGuid() ).FirstOrDefault();
|
||||||
|
var tx = randomSpawnPoint.Transform;
|
||||||
|
tx.Position = tx.Position + Vector3.Up * 50.0f; // raise it up
|
||||||
|
Shooter.Position = tx.Position;*/
|
||||||
|
|
||||||
// if it exists, place the pawn there
|
// Setup cameras for players
|
||||||
if ( randomSpawnPoint != null )
|
Players.ForEach( player =>
|
||||||
{
|
{
|
||||||
var tx = randomSpawnPoint.Transform;
|
player.Components.Create<RTSCamera>();
|
||||||
tx.Position = tx.Position + Vector3.Up * 50.0f; // raise it up
|
player.Position = Shooter.Position;
|
||||||
pawn.Position = tx.Position;
|
} );
|
||||||
}
|
|
||||||
|
Players.Select((player, i) => (Player: player, Index: i) ).ToList().ForEach( pair =>
|
||||||
|
{
|
||||||
|
var player = pair.Player;
|
||||||
|
var index = pair.Index;
|
||||||
|
var pawn = new Pawn();
|
||||||
|
player.Pawn = pawn;
|
||||||
|
pawn.DressFromClient( player.Client );
|
||||||
|
|
||||||
|
var pawnOffset = ShooterDistance * (index % 2 == 0 ? Vector3.Forward : Vector3.Right) * (index % 4 >= 2 ? -1 : 1);
|
||||||
|
|
||||||
|
player.Pawn.Position = Shooter.Position + pawnOffset;
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick()
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Cleanup()
|
public override void Cleanup()
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
Shooter?.Delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,9 @@
|
|||||||
<root>
|
<root>
|
||||||
<ChatBox/>
|
<ChatBox/>
|
||||||
<VoiceList/>
|
<VoiceList/>
|
||||||
<VotingLobby/>
|
<VotingLobby/>
|
||||||
<Scoreboard/>
|
<Scoreboard/>
|
||||||
|
<CameraCursor/>
|
||||||
<div class="pointer-visible" />
|
|
||||||
|
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|||||||
16
code/UI/HudComponents/CameraCursor.razor
Normal file
16
code/UI/HudComponents/CameraCursor.razor
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
@using LuckerGame.Components.Lucker.Cameras
|
||||||
|
@using Sandbox
|
||||||
|
@using Sandbox.UI
|
||||||
|
@namespace LuckerGame.UI.HudComponents
|
||||||
|
@attribute [StyleSheet]
|
||||||
|
@inherits Panel
|
||||||
|
|
||||||
|
@if (ShouldShowCursor)
|
||||||
|
{
|
||||||
|
<root/>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@code {
|
||||||
|
private bool ShouldShowCursor => Game.LocalClient.Pawn?.Components.Get<AbstractCamera>()?.ShouldShowCursor ?? false;
|
||||||
|
}
|
||||||
3
code/UI/HudComponents/CameraCursor.razor.scss
Normal file
3
code/UI/HudComponents/CameraCursor.razor.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
CameraCursor {
|
||||||
|
pointer-events: all;
|
||||||
|
}
|
||||||
@@ -1,3 +1,6 @@
|
|||||||
Scoreboard {
|
Scoreboard {
|
||||||
z-index: 0;
|
z-index: 0;
|
||||||
|
.scoreboard-panel {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user