Compare commits
2 Commits
35b16afd9a
...
fixed-came
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b9dbe07e1f | ||
|
|
4a338d9502 |
15
.sbproj
15
.sbproj
@@ -37,20 +37,7 @@
|
|||||||
"GameSettings": {},
|
"GameSettings": {},
|
||||||
"Addons": "",
|
"Addons": "",
|
||||||
"PreLaunchCommand": "",
|
"PreLaunchCommand": "",
|
||||||
"PostLaunchCommand": "lucker_minigames_per_round 1"
|
"PostLaunchCommand": ""
|
||||||
}
|
|
||||||
],
|
|
||||||
"PackageSettings": [
|
|
||||||
{
|
|
||||||
"DisplayType": "Integer",
|
|
||||||
"Choices": [],
|
|
||||||
"ConVarName": "lucker_minigames_per_round",
|
|
||||||
"DisplayName": "Minigames Per Round",
|
|
||||||
"DefaultValue": "0",
|
|
||||||
"Description": "The number of minigames played per round",
|
|
||||||
"Group": "Other",
|
|
||||||
"Minimum": 1,
|
|
||||||
"Maximum": 12
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ namespace LuckerGame.Entities;
|
|||||||
public partial class MinigameManager : Entity
|
public partial class MinigameManager : Entity
|
||||||
{
|
{
|
||||||
[Net] public Minigame LoadedMinigame { get; private set; }
|
[Net] public Minigame LoadedMinigame { get; private set; }
|
||||||
private List<TypeDescription> AvailableMinigames { get; set; }
|
private List<Minigame> AvailableMinigames { get; set; }
|
||||||
private List<Lucker> InvolvedPlayers { get; set; }
|
|
||||||
|
|
||||||
public override void Spawn()
|
public override void Spawn()
|
||||||
{
|
{
|
||||||
@@ -24,10 +23,9 @@ public partial class MinigameManager : Entity
|
|||||||
|
|
||||||
public void StartMinigame(List<Lucker> players, string minigameName = null)
|
public void StartMinigame(List<Lucker> players, string minigameName = null)
|
||||||
{
|
{
|
||||||
InvolvedPlayers = players.ToList();
|
|
||||||
if (CheckForMinigames())
|
if (CheckForMinigames())
|
||||||
{
|
{
|
||||||
LoadedMinigame = string.IsNullOrEmpty( minigameName ) ? TypeLibrary.Create<Minigame>(AvailableMinigames.OrderBy( _ => Guid.NewGuid() ).FirstOrDefault().TargetType) : TypeLibrary.Create<Minigame>( minigameName );
|
LoadedMinigame = string.IsNullOrEmpty( minigameName ) ? AvailableMinigames.OrderBy( _ => Guid.NewGuid() ).FirstOrDefault() : TypeLibrary.Create<Minigame>( minigameName );
|
||||||
ChatBox.AddInformation( To.Everyone, $"Starting {LoadedMinigame.Name}" );
|
ChatBox.AddInformation( To.Everyone, $"Starting {LoadedMinigame.Name}" );
|
||||||
LoadedMinigame.Initialize( players );
|
LoadedMinigame.Initialize( players );
|
||||||
}
|
}
|
||||||
@@ -48,7 +46,7 @@ public partial class MinigameManager : Entity
|
|||||||
{
|
{
|
||||||
AvailableMinigames = TypeLibrary.GetTypes<Minigame>()
|
AvailableMinigames = TypeLibrary.GetTypes<Minigame>()
|
||||||
.Where( type => !type.IsAbstract && !type.IsInterface )
|
.Where( type => !type.IsAbstract && !type.IsInterface )
|
||||||
.ToList();
|
.Select( td => TypeLibrary.Create<Minigame>( td.TargetType ) ).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Event.Hotload]
|
[Event.Hotload]
|
||||||
@@ -56,43 +54,13 @@ public partial class MinigameManager : Entity
|
|||||||
{
|
{
|
||||||
FindMinigames();
|
FindMinigames();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Goes through the players included in the loaded minigame and deletes and nulls out any pawns assigned to them
|
|
||||||
/// </summary>
|
|
||||||
private void CleanupPlayerPawns()
|
|
||||||
{
|
|
||||||
if ( LoadedMinigame is not { IsValid: true } || InvolvedPlayers == null)
|
|
||||||
{
|
|
||||||
Log.Warning( "Attempted to clean up players without a minigame loaded!" );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
InvolvedPlayers.ForEach( player =>
|
|
||||||
{
|
|
||||||
player.Pawn.Delete();
|
|
||||||
player.Pawn = null;
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
public void Tick()
|
||||||
/// Called once per tick by the RoundManager. Ticks any running minigame.
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>true if the current minigame has ended, else false</returns>
|
|
||||||
public bool Tick()
|
|
||||||
{
|
{
|
||||||
if ( LoadedMinigame is not { IsValid: true } )
|
if ( LoadedMinigame is not { IsValid: true } )
|
||||||
{
|
{
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
var ended = LoadedMinigame.Tick();
|
LoadedMinigame.Tick();
|
||||||
if ( !ended )
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
LoadedMinigame.Cleanup();
|
|
||||||
LoadedMinigame = null;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ public partial class RoundManager : Entity
|
|||||||
|
|
||||||
private const int MinigamesPerRound = 1;
|
private const int MinigamesPerRound = 1;
|
||||||
|
|
||||||
[ConVar.Replicated("lucker_minigames_per_round")]
|
private int MinigamesLeftInRound { get; set; }
|
||||||
public static int MinigamesLeftInRound { get; set; }
|
|
||||||
|
|
||||||
private List<Lucker> Players { get; set; }
|
private List<Lucker> Players { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
@@ -77,19 +76,7 @@ public partial class RoundManager : Entity
|
|||||||
|
|
||||||
if ( RoundState == RoundState.InProgress )
|
if ( RoundState == RoundState.InProgress )
|
||||||
{
|
{
|
||||||
var ended = MinigameManager.Tick();
|
MinigameManager.Tick();
|
||||||
if ( ended )
|
|
||||||
{
|
|
||||||
MinigamesLeftInRound--;
|
|
||||||
if ( MinigamesLeftInRound > 0 )
|
|
||||||
{
|
|
||||||
MinigameManager.StartMinigame( Players );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RoundState = RoundState.NotStarted;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,11 +120,6 @@ public partial class RoundManager : Entity
|
|||||||
|
|
||||||
RoundState = RoundState.InProgress;
|
RoundState = RoundState.InProgress;
|
||||||
Players = All.OfType<Lucker>().ToList();
|
Players = All.OfType<Lucker>().ToList();
|
||||||
Players.ForEach( player =>
|
|
||||||
{
|
|
||||||
player.Ready = false;
|
|
||||||
} );
|
|
||||||
MinigamesLeftInRound = MinigamesPerRound;
|
|
||||||
MinigameManager.StartMinigame( Players, minigameName );
|
MinigameManager.StartMinigame( Players, minigameName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using Sandbox;
|
|||||||
|
|
||||||
namespace LuckerGame.Components.Lucker.Cameras;
|
namespace LuckerGame.Components.Lucker.Cameras;
|
||||||
|
|
||||||
public abstract class AbstractCamera : EntityComponent<Entities.Lucker>, ISingletonComponent
|
public abstract partial class AbstractCamera : EntityComponent<Entities.Lucker>, ISingletonComponent
|
||||||
{
|
{
|
||||||
public virtual bool ShouldShowCursor => false;
|
public virtual bool ShouldShowCursor => false;
|
||||||
protected Vector3 CameraPosition { get; set; }
|
protected Vector3 CameraPosition { get; set; }
|
||||||
@@ -16,11 +16,11 @@ public abstract class AbstractCamera : EntityComponent<Entities.Lucker>, ISingle
|
|||||||
/// Handles any input-independent camera updates (ie following a pawn)
|
/// Handles any input-independent camera updates (ie following a pawn)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void UpdateCameraParameters();
|
protected abstract void UpdateCameraParameters();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles any input dependent camera updates (ie moving around a top down cam)
|
/// Handles any input dependent camera updates (ie moving around a top down cam)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract void BuildInput();
|
public virtual void BuildInput() { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Applies Camera parameters to the static Camera
|
/// Applies Camera parameters to the static Camera
|
||||||
|
|||||||
41
code/EntityComponents/Lucker/Cameras/FixedCamera.cs
Normal file
41
code/EntityComponents/Lucker/Cameras/FixedCamera.cs
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
using Sandbox;
|
||||||
|
|
||||||
|
namespace LuckerGame.Components.Lucker.Cameras;
|
||||||
|
|
||||||
|
public partial class FixedCamera : AbstractCamera, ISingletonComponent
|
||||||
|
{
|
||||||
|
[Net] public float FieldOfViewValue { get; set; } = 70f;
|
||||||
|
public override bool ShouldShowCursor => true;
|
||||||
|
protected override void UpdateCameraParameters()
|
||||||
|
{
|
||||||
|
FieldOfView = FieldOfViewValue;
|
||||||
|
FirstPersonViewer = null;
|
||||||
|
SoundSource = new Transform { Position = CameraPosition };
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ClientRpc doesn't allow for nullable versions of non-nullable types
|
||||||
|
/// so here we are
|
||||||
|
/// </summary>
|
||||||
|
public void UpdateCameraPositionRotation( Vector3? position = null, Rotation? rotation = null )
|
||||||
|
{
|
||||||
|
CameraPosition = (Vector3)(position.Equals( null ) ? CameraPosition : position);
|
||||||
|
CameraRotation = (Rotation)(rotation.Equals( null ) ? CameraRotation : rotation);
|
||||||
|
}
|
||||||
|
|
||||||
|
[ClientRpc]
|
||||||
|
public void LookAt( Vector3 position )
|
||||||
|
{
|
||||||
|
UpdateCameraPositionRotation( position );
|
||||||
|
}
|
||||||
|
[ClientRpc]
|
||||||
|
public void LookAt( Rotation rotation )
|
||||||
|
{
|
||||||
|
UpdateCameraPositionRotation( rotation: rotation );
|
||||||
|
}
|
||||||
|
[ClientRpc]
|
||||||
|
public void LookAt( Vector3 position, Rotation rotation )
|
||||||
|
{
|
||||||
|
UpdateCameraPositionRotation( position, rotation );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,8 +21,7 @@ public abstract class Minigame : Entity
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Once a minigame is loaded and initialized, this method is called once per server tick.
|
/// Once a minigame is loaded and initialized, this method is called once per server tick.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>true if the minigame has ended, false otherwise</returns>
|
public abstract void Tick();
|
||||||
public abstract bool Tick();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Cleans up any entities and components created by this minigame.
|
/// Cleans up any entities and components created by this minigame.
|
||||||
|
|||||||
@@ -16,10 +16,8 @@ public class RussianRouletteMinigame : Minigame
|
|||||||
public override string Name => "Russian Roulette";
|
public override string Name => "Russian Roulette";
|
||||||
private List<Lucker> Players { get; set; }
|
private List<Lucker> Players { get; set; }
|
||||||
private Pawn Shooter { get; set; }
|
private Pawn Shooter { get; set; }
|
||||||
|
|
||||||
private const float ShooterDistance = 80f;
|
private const float ShooterDistance = 80f;
|
||||||
private const float TimeBetweenShots = 7f;
|
private const float TimeBetweenShots = 7f;
|
||||||
private const float TimeBetweenDeathAndEnd = 5f;
|
|
||||||
private int Taunted = 0;
|
private int Taunted = 0;
|
||||||
|
|
||||||
private List<Pawn> DeadVictims => Players
|
private List<Pawn> DeadVictims => Players
|
||||||
@@ -28,7 +26,6 @@ public class RussianRouletteMinigame : Minigame
|
|||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
private TimeSince TimeSinceShot { get; set; }
|
private TimeSince TimeSinceShot { get; set; }
|
||||||
private TimeSince TimeSinceDeadVictim { get; set; }
|
|
||||||
|
|
||||||
public override void Initialize( List<Lucker> players )
|
public override void Initialize( List<Lucker> players )
|
||||||
{
|
{
|
||||||
@@ -61,10 +58,9 @@ public class RussianRouletteMinigame : Minigame
|
|||||||
pawn.LookAt(Shooter.Position);
|
pawn.LookAt(Shooter.Position);
|
||||||
} );
|
} );
|
||||||
TimeSinceShot = 0;
|
TimeSinceShot = 0;
|
||||||
Taunted = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Tick()
|
public override void Tick()
|
||||||
{
|
{
|
||||||
if ( DeadVictims.Any() )
|
if ( DeadVictims.Any() )
|
||||||
{
|
{
|
||||||
@@ -72,14 +68,10 @@ public class RussianRouletteMinigame : Minigame
|
|||||||
{
|
{
|
||||||
ChatBox.AddChatEntry( To.Everyone, "Shooter", "Heh, nothing personnel, kid." );
|
ChatBox.AddChatEntry( To.Everyone, "Shooter", "Heh, nothing personnel, kid." );
|
||||||
Taunted = int.MaxValue;
|
Taunted = int.MaxValue;
|
||||||
TimeSinceDeadVictim = 0;
|
|
||||||
}
|
|
||||||
else if(TimeSinceDeadVictim > TimeBetweenDeathAndEnd)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if ( TimeSinceShot > TimeBetweenShots )
|
if ( TimeSinceShot > TimeBetweenShots )
|
||||||
{
|
{
|
||||||
TimeSinceShot = 0;
|
TimeSinceShot = 0;
|
||||||
Taunted = 0;
|
Taunted = 0;
|
||||||
@@ -103,8 +95,6 @@ public class RussianRouletteMinigame : Minigame
|
|||||||
ChatBox.AddChatEntry( To.Everyone, "Shooter", "Im gettin' ready!" );
|
ChatBox.AddChatEntry( To.Everyone, "Shooter", "Im gettin' ready!" );
|
||||||
Taunted++;
|
Taunted++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Cleanup()
|
public override void Cleanup()
|
||||||
|
|||||||
52
code/Minigames/TerryRaces/TerryRacesMinigame.cs
Normal file
52
code/Minigames/TerryRaces/TerryRacesMinigame.cs
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Numerics;
|
||||||
|
using LuckerGame.Components.Lucker.Cameras;
|
||||||
|
using LuckerGame.Components.Pawn;
|
||||||
|
using LuckerGame.Entities;
|
||||||
|
using Sandbox;
|
||||||
|
using Sandbox.UI;
|
||||||
|
|
||||||
|
namespace LuckerGame.Minigames.TerryRaces;
|
||||||
|
|
||||||
|
[Library( "mg_terry_races" )]
|
||||||
|
public class TerryRaces : Minigame
|
||||||
|
{
|
||||||
|
public override string Name => "Terry Races";
|
||||||
|
private List<Lucker> Players { get; set; }
|
||||||
|
private FixedCamera camera;
|
||||||
|
|
||||||
|
public override void Initialize( List<Lucker> players )
|
||||||
|
{
|
||||||
|
Players = players;
|
||||||
|
// Setup cameras for players
|
||||||
|
Players.ForEach( player =>
|
||||||
|
{
|
||||||
|
camera = player.Components.Create<FixedCamera>();
|
||||||
|
camera.LookAt( new Vector3( -110f, 4f, 180f ), Rotation.FromPitch( 45 ) );
|
||||||
|
camera.FieldOfViewValue = 120f;
|
||||||
|
} );
|
||||||
|
|
||||||
|
Players.Select( ( player, i ) => (Player: player, Index: i) ).ToList().ForEach( pair =>
|
||||||
|
{
|
||||||
|
var player = pair.Player;
|
||||||
|
var index = pair.Index;
|
||||||
|
var pawn = new Pawn();
|
||||||
|
pawn.Name = player.Name;
|
||||||
|
pawn.Tags.Add( "victim" );
|
||||||
|
pawn.Health = 1;
|
||||||
|
player.Pawn = pawn;
|
||||||
|
pawn.DressFromClient( player.Client );
|
||||||
|
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Cleanup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
@using Sandbox;
|
|
||||||
@using System;
|
|
||||||
@using System.Linq;
|
|
||||||
@using System.Threading.Tasks;
|
|
||||||
@using Sandbox.Menu;
|
|
||||||
@using Sandbox.UI;
|
|
||||||
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
@inherits Panel
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<label class="game-title">
|
|
||||||
@Game.Menu.Package.Title
|
|
||||||
</label>
|
|
||||||
|
|
||||||
@if ( Lobby == null )
|
|
||||||
{
|
|
||||||
<div class="controls">
|
|
||||||
<a class="button">Loading...</a>
|
|
||||||
|
|
||||||
<a class="button" href="/lobby/list">Return</a>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<div class="col">
|
|
||||||
<label>Members (@Lobby.MemberCount/@Lobby.MaxMembers)</label>
|
|
||||||
|
|
||||||
<div class="span">
|
|
||||||
@foreach (var member in Lobby.Members)
|
|
||||||
{
|
|
||||||
<img class="avatar" src="avatar:@member.Id" tooltip="@member.Name" />
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@if ( Lobby.Owner.IsMe )
|
|
||||||
{
|
|
||||||
<div class="span">
|
|
||||||
@if ( MaxPlayersSupported > 1 )
|
|
||||||
{
|
|
||||||
<FormGroup class="form-group">
|
|
||||||
<Label>Maximum Players</Label>
|
|
||||||
<Control>
|
|
||||||
<SliderControl ShowRange=@true Min=@(1f) Max=@MaxPlayersSupported Value:bind=@Game.Menu.Lobby.MaxMembers />
|
|
||||||
</Control>
|
|
||||||
</FormGroup>
|
|
||||||
}
|
|
||||||
|
|
||||||
<FormGroup class="form-group">
|
|
||||||
<Label>Map</Label>
|
|
||||||
<Control>
|
|
||||||
<SlimPackageCard OnLaunch=@OnMapClicked Package=@MapPackage />
|
|
||||||
</Control>
|
|
||||||
</FormGroup>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="spacer" />
|
|
||||||
|
|
||||||
|
|
||||||
<a class="button" @onclick=@LeaveLobby>Leave Lobby</a>
|
|
||||||
|
|
||||||
<a class="button" @onclick=@Start>Start</a>
|
|
||||||
|
|
||||||
<a class="button" href="/lobby/list">Return</a>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
Friend Owner => Lobby.Owner;
|
|
||||||
ILobby Lobby => Game.Menu.Lobby;
|
|
||||||
|
|
||||||
int MaxPlayersSupported { get; set; } = 1;
|
|
||||||
Package MapPackage { get; set; }
|
|
||||||
|
|
||||||
void OnMapClicked()
|
|
||||||
{
|
|
||||||
Game.Overlay.ShowPackageSelector( "type:map sort:popular", OnMapSelected );
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnMapSelected( Package map )
|
|
||||||
{
|
|
||||||
MapPackage = map;
|
|
||||||
Game.Menu.Lobby.Map = map.FullIdent;
|
|
||||||
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LeaveLobby()
|
|
||||||
{
|
|
||||||
Lobby?.Leave();
|
|
||||||
|
|
||||||
this.Navigate( "/lobby/list" );
|
|
||||||
}
|
|
||||||
|
|
||||||
async Task Start()
|
|
||||||
{
|
|
||||||
await Game.Menu.StartServerAsync( Game.Menu.Lobby.MaxMembers, $"{Game.Menu.Lobby.Owner.Name}'s game", Game.Menu.Lobby.Map );
|
|
||||||
}
|
|
||||||
|
|
||||||
async void FetchPackage()
|
|
||||||
{
|
|
||||||
MapPackage = await Package.FetchAsync( Game.Menu.Lobby?.Map ?? "facepunch.square", true );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnAfterTreeRender( bool firstTime )
|
|
||||||
{
|
|
||||||
FetchPackage();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
|
||||||
{
|
|
||||||
MaxPlayersSupported = Game.Menu.Package.GetMeta<int>( "MaxPlayers", 1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
@using Sandbox;
|
|
||||||
@using System.Linq;
|
|
||||||
@using System.Threading.Tasks;
|
|
||||||
@using Sandbox.Menu;
|
|
||||||
@using Sandbox.UI;
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<div class="game-title">
|
|
||||||
@Game.Menu.Package.Title
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
@if (Game.InGame)
|
|
||||||
{
|
|
||||||
<a class="button" onclick=@LeaveGame>Leave</a>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<a class="button" href="/setup">Play</a>
|
|
||||||
|
|
||||||
<a class="button" href="/lobby/list">Lobbies</a>
|
|
||||||
|
|
||||||
@if ( Game.Menu.Package.SupportsSavedGames && Game.Menu.SavedGames.Any())
|
|
||||||
{
|
|
||||||
<a class="button" href="/setup/save">Load Save</a>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
<a class="button" @onclick=@Game.Menu.Close>Quit</a>
|
|
||||||
</div>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
void LeaveGame()
|
|
||||||
{
|
|
||||||
Game.Menu.LeaveServer( "Leaving" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
@using Sandbox;
|
|
||||||
@using Sandbox.UI;
|
|
||||||
@using System.Linq;
|
|
||||||
@using System.Threading.Tasks;
|
|
||||||
@using Sandbox.Menu;
|
|
||||||
|
|
||||||
@inherits RootPanel
|
|
||||||
@implements Sandbox.Menu.ILoadingScreenPanel
|
|
||||||
@attribute [StyleSheet]
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
|
|
||||||
<root style="flex-direction: column;">
|
|
||||||
<div class="background" />
|
|
||||||
|
|
||||||
<div style="flex-grow: 1;" />
|
|
||||||
|
|
||||||
<div class="controls" style="flex-direction: row; justify-content: center;">
|
|
||||||
<a class="button">@( Progress.Title ?? "Loading..." )</a>
|
|
||||||
</div>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
public LoadingProgress Progress;
|
|
||||||
|
|
||||||
public void OnLoadingProgress( LoadingProgress progress )
|
|
||||||
{
|
|
||||||
Progress = progress;
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
|
|
||||||
LoadingScreen
|
|
||||||
{
|
|
||||||
background-color: #262934;
|
|
||||||
padding: 128px 128px;
|
|
||||||
opacity: 1;
|
|
||||||
flex-direction: column;
|
|
||||||
font-size: 25px;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
transition: all 0.3s ease-out;
|
|
||||||
color: rgba( white, 0.8 );
|
|
||||||
|
|
||||||
.background
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-image: url( https://files.facepunch.com/tony/1b1311b1/boxes.webm );
|
|
||||||
opacity: 0.2;
|
|
||||||
background-size: contain;
|
|
||||||
filter: blur( 20px );
|
|
||||||
mask: linear-gradient( 45deg, white, white, black );
|
|
||||||
mask-scope: filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:intro
|
|
||||||
{
|
|
||||||
opacity: 0;
|
|
||||||
transform: scaleX( 1.1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
.game-title
|
|
||||||
{
|
|
||||||
font-family: Roboto;
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 70px;
|
|
||||||
color: rgba( white, 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls
|
|
||||||
{
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 50px;
|
|
||||||
align-items: flex-start;
|
|
||||||
font-family: Roboto;
|
|
||||||
text-transform: uppercase;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
@using Sandbox;
|
|
||||||
@using System;
|
|
||||||
@using System.Linq;
|
|
||||||
@using System.Threading.Tasks;
|
|
||||||
@using Sandbox.Menu;
|
|
||||||
@using Sandbox.UI;
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
@inherits Panel
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<label class="game-title">
|
|
||||||
@Game.Menu.Package.Title
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<div class="span">
|
|
||||||
<label>Showing @Game.Menu.Lobbies.Count() @(Game.Menu.Lobbies.Count() == 1 ? "lobby" : "lobbies")</label>
|
|
||||||
<i class="with-click" tooltip="Refresh lobbies" @onclick=@Refresh>refresh</i>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="scroll">
|
|
||||||
@foreach ( var lobby in Game.Menu.Lobbies )
|
|
||||||
{
|
|
||||||
<a class="button" @onclick=@( () => JoinLobby( lobby ) ) >@(lobby.Owner.Name)'s lobby (@lobby.MemberCount/@lobby.MaxMembers)</a>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="spacer" />
|
|
||||||
|
|
||||||
<a class="button" @onclick=@CreateLobbyAsync>Create Lobby</a>
|
|
||||||
<a class="button" href="/">Return</a>
|
|
||||||
</div>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
public async void CreateLobbyAsync()
|
|
||||||
{
|
|
||||||
await Game.Menu.CreateLobbyAsync( 64, "game", true );
|
|
||||||
Game.Menu.Lobby.Map = "facepunch.square";
|
|
||||||
this.Navigate( "/lobby/active" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void JoinLobby( ILobby lobby )
|
|
||||||
{
|
|
||||||
if ( lobby == null ) return;
|
|
||||||
|
|
||||||
// don't exist in two lobbies at once
|
|
||||||
Game.Menu.Lobby?.Leave();
|
|
||||||
|
|
||||||
await lobby.JoinAsync();
|
|
||||||
this.Navigate( "/lobby/active" );
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Refresh()
|
|
||||||
{
|
|
||||||
await Game.Menu.QueryLobbiesAsync( null, 1 );
|
|
||||||
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override int BuildHash()
|
|
||||||
{
|
|
||||||
return HashCode.Combine( Game.Menu.Lobbies.Count() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
@using System;
|
|
||||||
@using Sandbox;
|
|
||||||
@using Sandbox.UI;
|
|
||||||
|
|
||||||
@inherits Sandbox.UI.NavHostPanel
|
|
||||||
@implements Sandbox.Menu.IGameMenuPanel
|
|
||||||
@attribute [StyleSheet]
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
|
|
||||||
<root style="flex-direction: column;">
|
|
||||||
<div class="background" />
|
|
||||||
<div class="navigator-canvas" slot="navigator-canvas" />
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
public MainMenu()
|
|
||||||
{
|
|
||||||
DefaultUrl = "/";
|
|
||||||
|
|
||||||
AddDestination( "/", typeof( FrontPage ) );
|
|
||||||
AddDestination( "/setup", typeof( SetupGame ) );
|
|
||||||
|
|
||||||
AddDestination( "/lobby/list", typeof( LobbyBrowser ) );
|
|
||||||
AddDestination( "/lobby/active", typeof( ActiveLobby ) );
|
|
||||||
|
|
||||||
BindClass( "ingame", () => Game.InGame );
|
|
||||||
}
|
|
||||||
|
|
||||||
[GameEvent.Menu.ServerJoined]
|
|
||||||
public void OnServerJoined() => Navigate( "/" );
|
|
||||||
|
|
||||||
[GameEvent.Menu.ServerLeave]
|
|
||||||
public void OnServerLeave() => Navigate ("/" );
|
|
||||||
|
|
||||||
protected override int BuildHash()
|
|
||||||
{
|
|
||||||
return HashCode.Combine( Game.InGame, Game.Menu.Lobby, Game.Menu.Lobby?.Map );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,195 +0,0 @@
|
|||||||
|
|
||||||
MainMenu
|
|
||||||
{
|
|
||||||
background-color: #262934;
|
|
||||||
padding: 128px 128px;
|
|
||||||
opacity: 1;
|
|
||||||
flex-direction: column;
|
|
||||||
font-size: 25px;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
position: absolute;
|
|
||||||
transition: all 0.3s ease-out;
|
|
||||||
color: rgba( white, 0.8 );
|
|
||||||
|
|
||||||
.background
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
background-image: url( https://files.facepunch.com/tony/1b1311b1/boxes.webm );
|
|
||||||
opacity: 0.2;
|
|
||||||
background-size: cover;
|
|
||||||
filter: blur( 20px );
|
|
||||||
mask: linear-gradient( 45deg, white, white, black );
|
|
||||||
mask-scope: filter;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:intro
|
|
||||||
{
|
|
||||||
opacity: 0;
|
|
||||||
transform: scaleX( 1.1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
&.ingame
|
|
||||||
{
|
|
||||||
background-color: #262934ee;
|
|
||||||
backdrop-filter: blur(10px);
|
|
||||||
|
|
||||||
.background
|
|
||||||
{
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.scroll
|
|
||||||
{
|
|
||||||
flex-direction: column;
|
|
||||||
max-height: 386px;
|
|
||||||
overflow: scroll;
|
|
||||||
gap: 50px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.spacer
|
|
||||||
{
|
|
||||||
height: 1px;
|
|
||||||
background-image: linear-gradient( to right, rgba( white, 0.4 ), rgba( white, 0 ) );
|
|
||||||
width: 512px;
|
|
||||||
margin: 16px 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.game-title
|
|
||||||
{
|
|
||||||
font-family: Roboto Condensed;
|
|
||||||
font-weight: 700;
|
|
||||||
font-size: 70px;
|
|
||||||
color: rgba( white, 1 );
|
|
||||||
padding-bottom: 64px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.col
|
|
||||||
{
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls
|
|
||||||
{
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 50px;
|
|
||||||
align-items: flex-start;
|
|
||||||
text-transform: uppercase;
|
|
||||||
|
|
||||||
a, .button
|
|
||||||
{
|
|
||||||
font-family: Roboto;
|
|
||||||
|
|
||||||
&:hover
|
|
||||||
{
|
|
||||||
color: rgba( white, 1 );
|
|
||||||
font-weight: 900;
|
|
||||||
sound-in: ui.button.over;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active
|
|
||||||
{
|
|
||||||
sound-in: ui.button.press;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.span
|
|
||||||
{
|
|
||||||
gap: 128px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.navigator-canvas
|
|
||||||
{
|
|
||||||
flex-direction: column;
|
|
||||||
height: 100%;
|
|
||||||
flex-grow: 1;
|
|
||||||
flex-shrink: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navigator-body
|
|
||||||
{
|
|
||||||
position: absolute;
|
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
bottom: 0;
|
|
||||||
top: 0;
|
|
||||||
flex-direction: column;
|
|
||||||
justify-content: center;
|
|
||||||
transition: opacity 0.15s ease-out;
|
|
||||||
|
|
||||||
&.hidden
|
|
||||||
{
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FormGroup
|
|
||||||
{
|
|
||||||
flex-direction: column;
|
|
||||||
min-width: 300px;
|
|
||||||
gap:16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
SlimPackageCard
|
|
||||||
{
|
|
||||||
flex-direction: row;
|
|
||||||
gap: 12px;
|
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
> i
|
|
||||||
{
|
|
||||||
&:hover
|
|
||||||
{
|
|
||||||
cursor: pointer;
|
|
||||||
color: white;
|
|
||||||
transform: scale( 1.1 );
|
|
||||||
sound-in: ui.button.over;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active
|
|
||||||
{
|
|
||||||
sound-in: ui.button.press;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
i
|
|
||||||
{
|
|
||||||
font-family: Material Icons;
|
|
||||||
text-transform: lowercase;
|
|
||||||
|
|
||||||
&.with-click
|
|
||||||
{
|
|
||||||
&:hover
|
|
||||||
{
|
|
||||||
cursor: pointer;
|
|
||||||
color: white;
|
|
||||||
transform: scale( 1.1 );
|
|
||||||
sound-in: ui.button.over;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:active
|
|
||||||
{
|
|
||||||
sound-in: ui.button.press;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar
|
|
||||||
{
|
|
||||||
width: 64px;
|
|
||||||
height: 64px;
|
|
||||||
|
|
||||||
&:hover
|
|
||||||
{
|
|
||||||
border: 1px solid white;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
@using Sandbox;
|
|
||||||
@using System;
|
|
||||||
@using System.Linq;
|
|
||||||
@using Sandbox.UI;
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
@inherits Panel
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<label class="game-title">
|
|
||||||
@Game.Menu.Package.Title
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
@foreach ( var save in Game.Menu.SavedGames.OrderByDescending( x => x.Time ) )
|
|
||||||
{
|
|
||||||
<a class="button" @onclick=@(() => LoadSavedGame( save ))>@save.Name - @save.Time</a>
|
|
||||||
}
|
|
||||||
|
|
||||||
<div class="spacer" />
|
|
||||||
|
|
||||||
<a class="button" href="/">Return</a>
|
|
||||||
</div>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
async void LoadSavedGame( SavedGame save )
|
|
||||||
{
|
|
||||||
if ( save != null )
|
|
||||||
{
|
|
||||||
Game.Menu.Lobby.SavedGame = save.Name;
|
|
||||||
|
|
||||||
if ( !string.IsNullOrEmpty( save.Map ) )
|
|
||||||
Game.Menu.Lobby.Map = save.Map;
|
|
||||||
|
|
||||||
await Game.Menu.StartServerAsync( Game.Menu.Lobby.MaxMembers, Game.Menu.Lobby.Title, Game.Menu.Lobby.Map ?? "facepunch.square" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override int BuildHash()
|
|
||||||
{
|
|
||||||
return HashCode.Combine( Game.Menu.Lobby, Game.Menu.Lobby?.Map );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
@using Sandbox;
|
|
||||||
@using System;
|
|
||||||
@using System.Linq;
|
|
||||||
@using System.Threading.Tasks;
|
|
||||||
@using Sandbox.Menu;
|
|
||||||
@using Sandbox.UI;
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
@inherits Panel
|
|
||||||
|
|
||||||
<root>
|
|
||||||
<label class="game-title">
|
|
||||||
@Game.Menu.Package.Title
|
|
||||||
</label>
|
|
||||||
|
|
||||||
<div class="controls">
|
|
||||||
<div class="span">
|
|
||||||
@if ( MaxPlayersSupported > 1 )
|
|
||||||
{
|
|
||||||
<FormGroup class="form-group">
|
|
||||||
<Label>Maximum Players</Label>
|
|
||||||
<Control>
|
|
||||||
<SliderControl ShowRange=@true Min=@(1f) Max=@MaxPlayersSupported Value:bind=@Game.Menu.Lobby.MaxMembers />
|
|
||||||
</Control>
|
|
||||||
</FormGroup>
|
|
||||||
}
|
|
||||||
|
|
||||||
<FormGroup class="form-group">
|
|
||||||
<Label>Map</Label>
|
|
||||||
<Control>
|
|
||||||
<SlimPackageCard OnLaunch=@OnMapClicked Package=@MapPackage />
|
|
||||||
</Control>
|
|
||||||
</FormGroup>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="spacer" />
|
|
||||||
|
|
||||||
<a class="button" onclick=@Play>Start</a>
|
|
||||||
<a class="button" href="/">Return</a>
|
|
||||||
</div>
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
int MaxPlayersSupported { get; set; } = 1;
|
|
||||||
int MaxPlayers { get; set; } = 1;
|
|
||||||
Package MapPackage { get; set; }
|
|
||||||
|
|
||||||
void OnMapClicked()
|
|
||||||
{
|
|
||||||
Game.Overlay.ShowPackageSelector( "type:map sort:popular", OnMapSelected );
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnMapSelected( Package map )
|
|
||||||
{
|
|
||||||
MapPackage = map;
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override async Task OnParametersSetAsync()
|
|
||||||
{
|
|
||||||
MaxPlayersSupported = Game.Menu.Package.GetMeta<int>( "MaxPlayers", 1 );
|
|
||||||
MaxPlayers = MaxPlayersSupported;
|
|
||||||
|
|
||||||
MapPackage = await Package.FetchAsync( "facepunch.square", false );
|
|
||||||
StateHasChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
async Task Play()
|
|
||||||
{
|
|
||||||
await Game.Menu.StartServerAsync( MaxPlayers, $"My game", MapPackage.FullIdent );
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override int BuildHash()
|
|
||||||
{
|
|
||||||
return HashCode.Combine( MaxPlayers, MapPackage );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
@using System;
|
|
||||||
@using Sandbox;
|
|
||||||
@namespace LuckerGame.UI.MainMenu
|
|
||||||
@inherits Sandbox.UI.Panel
|
|
||||||
|
|
||||||
<root>
|
|
||||||
@if ( Package == null )
|
|
||||||
{
|
|
||||||
<div class="button" @onclick=@OnCardClicked>Select Package</div>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<div class="button" @onclick=@OnCardClicked>@Package.Title</div>
|
|
||||||
<i tooltip="See information about this package" @onclick=@( () => Game.Overlay.ShowPackageModal( Package.FullIdent ) )>info</i>
|
|
||||||
}
|
|
||||||
</root>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
public Package Package { get; set; }
|
|
||||||
public System.Action OnLaunch { get; set; }
|
|
||||||
|
|
||||||
void OnCardClicked()
|
|
||||||
{
|
|
||||||
OnLaunch?.Invoke();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override int BuildHash()
|
|
||||||
{
|
|
||||||
return HashCode.Combine( Package );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user