More russian roulette setup
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LuckerGame.Components.Lucker.Cameras;
|
||||
using LuckerGame.Entities;
|
||||
using Sandbox;
|
||||
|
||||
@@ -9,28 +10,51 @@ namespace LuckerGame.Minigames.RussianRoulette;
|
||||
public class RussianRouletteMinigame : Minigame
|
||||
{
|
||||
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 )
|
||||
{
|
||||
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>();
|
||||
|
||||
// chose a random one
|
||||
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
|
||||
if ( randomSpawnPoint != null )
|
||||
// Setup cameras for players
|
||||
Players.ForEach( player =>
|
||||
{
|
||||
var tx = randomSpawnPoint.Transform;
|
||||
tx.Position = tx.Position + Vector3.Up * 50.0f; // raise it up
|
||||
pawn.Position = tx.Position;
|
||||
}
|
||||
player.Components.Create<RTSCamera>();
|
||||
player.Position = Shooter.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()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
Shooter?.Delete();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user