added nametags
This commit is contained in:
@@ -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 ));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user