Initial commit
This commit is contained in:
22
code/Minigames/Minigame.cs
Normal file
22
code/Minigames/Minigame.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using LuckerGame.Entities;
|
||||
using Sandbox;
|
||||
|
||||
namespace LuckerGame.Minigames;
|
||||
|
||||
public abstract class Minigame : Entity
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
/// <summary>
|
||||
/// Initializes the minigame with a list of luckers playing it
|
||||
/// </summary>
|
||||
/// <param name="players">the players who made it into the minigame</param>
|
||||
public abstract void Initialize(List<Lucker> players);
|
||||
|
||||
/// <summary>
|
||||
/// Cleans up any entities and components created by this minigame.
|
||||
/// It is not necessary to remove the lucker's pawns, the manager will do so if any were assigned.
|
||||
/// </summary>
|
||||
public abstract void Cleanup();
|
||||
}
|
||||
36
code/Minigames/RussianRoulette/RussianRouletteMinigame.cs
Normal file
36
code/Minigames/RussianRoulette/RussianRouletteMinigame.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LuckerGame.Entities;
|
||||
using Sandbox;
|
||||
|
||||
namespace LuckerGame.Minigames.RussianRoulette;
|
||||
|
||||
public class RussianRouletteMinigame : Minigame
|
||||
{
|
||||
public override string Name => "Russian Roulette";
|
||||
|
||||
public override void Initialize( List<Lucker> players )
|
||||
{
|
||||
var pawn = new Pawn();
|
||||
|
||||
// Get all of the spawnpoints
|
||||
var spawnpoints = Entity.All.OfType<SpawnPoint>();
|
||||
|
||||
// chose a random one
|
||||
var randomSpawnPoint = spawnpoints.OrderBy( x => Guid.NewGuid() ).FirstOrDefault();
|
||||
|
||||
// if it exists, place the pawn there
|
||||
if ( randomSpawnPoint != null )
|
||||
{
|
||||
var tx = randomSpawnPoint.Transform;
|
||||
tx.Position = tx.Position + Vector3.Up * 50.0f; // raise it up
|
||||
pawn.Position = tx.Position;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user