added nametags
This commit is contained in:
@@ -15,13 +15,13 @@ public class RussianRouletteMinigame : Minigame
|
||||
{
|
||||
public override string Name => "Russian Roulette";
|
||||
private List<Lucker> Players { get; set; }
|
||||
private Entities.Racer Shooter { get; set; }
|
||||
private Entities.Pawn Shooter { get; set; }
|
||||
private const float ShooterDistance = 80f;
|
||||
private const float TimeBetweenShots = 7f;
|
||||
private int Taunted = 0;
|
||||
|
||||
private List<Entities.Racer> DeadVictims => Players
|
||||
.Select( player => player.Pawn as Entities.Racer )
|
||||
private List<Entities.Pawn> DeadVictims => Players
|
||||
.Select( player => player.Pawn as Entities.Pawn )
|
||||
.Where( pawn => !pawn.IsValid || pawn.LifeState != LifeState.Alive )
|
||||
.ToList();
|
||||
|
||||
@@ -30,7 +30,7 @@ public class RussianRouletteMinigame : Minigame
|
||||
public override void Initialize( List<Lucker> players )
|
||||
{
|
||||
Players = players;
|
||||
Shooter = new Entities.Racer();
|
||||
Shooter = new Entities.Pawn();
|
||||
var shooterInventory = Shooter.Components.Create<PawnInventory>();
|
||||
shooterInventory.AddWeapon( new RussianPistol() );
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RussianRouletteMinigame : Minigame
|
||||
{
|
||||
var player = pair.Player;
|
||||
var index = pair.Index;
|
||||
var pawn = new Entities.Racer();
|
||||
var pawn = new Entities.Pawn();
|
||||
pawn.Name = player.Name;
|
||||
pawn.Tags.Add( "victim" );
|
||||
pawn.Health = 1;
|
||||
|
||||
23
code/Minigames/TerryRaces/HoveringTextCreator.cs
Normal file
23
code/Minigames/TerryRaces/HoveringTextCreator.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using LuckerGame.UI;
|
||||
using Sandbox;
|
||||
|
||||
public class HoveringTextCreator : Entity
|
||||
{
|
||||
private string Text { get; set; }
|
||||
private Entity TargetEntity { get; set; }
|
||||
|
||||
public HoveringTextCreator()
|
||||
{
|
||||
|
||||
}
|
||||
public HoveringTextCreator(string text, Entity targetEntity)
|
||||
{
|
||||
Text = text;
|
||||
TargetEntity = targetEntity;
|
||||
}
|
||||
public override void ClientSpawn()
|
||||
{
|
||||
base.ClientSpawn();
|
||||
var hoveringText = new HoveringText(Text, TargetEntity);
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using LuckerGame.Entities;
|
||||
using LuckerGame.UI;
|
||||
using Sandbox;
|
||||
using System;
|
||||
using System.IO;
|
||||
@@ -6,22 +7,58 @@ using System.Linq;
|
||||
using System.Numerics;
|
||||
using System.Reflection.Metadata.Ecma335;
|
||||
|
||||
public class Racer : LuckerGame.Entities.Racer
|
||||
public class Racer : Pawn
|
||||
{
|
||||
public float Speed;
|
||||
private float SpeedModifier = 1f;
|
||||
private Random Random { get; set; }
|
||||
private HoveringText NameTag { get; set; }
|
||||
|
||||
public Racer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Racer( Random random )
|
||||
{
|
||||
Random = random;
|
||||
}
|
||||
|
||||
public override void ClientSpawn()
|
||||
{
|
||||
base.ClientSpawn();
|
||||
NameTag = new( Name, this );
|
||||
}
|
||||
|
||||
public void ContinueRacing()
|
||||
{
|
||||
Position = Position.WithY( Position.y - Speed );
|
||||
SetAnimParameter( "move_x", Speed*500f );
|
||||
SetAnimParameter( "move_x", Speed * 500f * SpeedModifier );
|
||||
ModifySpeed();
|
||||
Position = Position.WithY( Position.y - (Speed * SpeedModifier) );
|
||||
|
||||
}
|
||||
|
||||
private void ModifySpeed()
|
||||
{
|
||||
var roll = Random.NextDouble();
|
||||
switch ( roll )
|
||||
{
|
||||
case >= .90 and < .95:
|
||||
SpeedModifier = 2f;
|
||||
break;
|
||||
case >= .95:
|
||||
SpeedModifier = 0.5f;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void StopRacing()
|
||||
{
|
||||
|
||||
SetAnimParameter( "move_x", 0 );
|
||||
}
|
||||
|
||||
public void GenerateSpeed(Random random, double minSpeed, double maxSpeed)
|
||||
public void GenerateSpeed( double minSpeed, double maxSpeed )
|
||||
{
|
||||
Speed = (float)(RandomExtensions.NextDouble( random, minSpeed, maxSpeed ));
|
||||
Speed = (float)(RandomExtensions.NextDouble( Random, minSpeed, maxSpeed ));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ public class TerryRaces : Minigame
|
||||
{
|
||||
public override string Name => "Terry Races";
|
||||
private Random random = new Random();
|
||||
private HoveringTextCreator NameTag { get; set; }
|
||||
private Racer WinningRacer = null;
|
||||
private FixedCamera Camera;
|
||||
private List<Lucker> Players { get; set; }
|
||||
@@ -51,23 +52,18 @@ public class TerryRaces : Minigame
|
||||
|
||||
public override void Tick()
|
||||
{
|
||||
if ( Racers != null )
|
||||
Racers.ForEach( racer =>
|
||||
{
|
||||
Racers.ForEach( racer =>
|
||||
if (WinningRacer == null)
|
||||
{
|
||||
if ( WinningRacer == null )
|
||||
{
|
||||
// Log.Info( $"{racer.Name} is racing" );
|
||||
GetWinningRacer();
|
||||
racer.ContinueRacing();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Log.Info( $"{racer.Name} is stopping." );
|
||||
racer.StopRacing();
|
||||
}
|
||||
} );
|
||||
}
|
||||
GetWinningRacer();
|
||||
racer.ContinueRacing();
|
||||
}
|
||||
else
|
||||
{
|
||||
racer.StopRacing();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
@@ -79,7 +75,7 @@ public class TerryRaces : Minigame
|
||||
for ( int i = 0; i < RacerNames.Count; i++ )
|
||||
{
|
||||
var clothing = new ClothingContainer();
|
||||
var racer = new Racer();
|
||||
var racer = new Racer(random);
|
||||
var x = StartingX - RacerXOffset * i;
|
||||
|
||||
clothing.Toggle( GetRandomBottomClothing() );
|
||||
@@ -89,7 +85,7 @@ public class TerryRaces : Minigame
|
||||
racer.Name = RacerNames[i];
|
||||
racer.Position = new Vector3( x, StartingY, 0 );
|
||||
racer.Rotation = Rotation.FromYaw( -90 );
|
||||
racer.GenerateSpeed( random, MinimumSpeed, MaximumSpeed );
|
||||
racer.GenerateSpeed(MinimumSpeed, MaximumSpeed );
|
||||
|
||||
Racers.Add( racer );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user