Initial commit

This commit is contained in:
gamer147
2023-08-02 19:47:53 -04:00
commit 285a130a81
33 changed files with 1699 additions and 0 deletions

69
code/Game.cs Normal file
View File

@@ -0,0 +1,69 @@

using Sandbox;
using System;
using System.Linq;
using LuckerGame.Components.Client;
using LuckerGame.UI;
using LuckerGame.Entities;
using Sandbox.UI;
//
// You don't need to put things in a namespace, but it doesn't hurt.
//
namespace LuckerGame;
/// <summary>
/// This is your game class. This is an entity that is created serverside when
/// the game starts, and is replicated to the client.
///
/// You can use this to create things like HUDs and declare which player class
/// to use for spawned players.
/// </summary>
public partial class LuckerGameManager : GameManager
{
/// <summary>
/// Called when the game is created (on both the server and client)
/// </summary>
public LuckerGameManager()
{
if ( Game.IsClient )
{
Game.RootPanel = new Hud();
}
else if ( Game.IsServer )
{
var roundManager = new RoundManager();
}
}
public override void PostLevelLoaded()
{
base.PostLevelLoaded();
}
/// <summary>
/// A client has joined the server. Make them a pawn to play with
/// </summary>
public override void ClientJoined( IClient client )
{
base.ClientJoined( client );
// Create a pawn for this client to play with
var lucker = Entities.Lucker.CreateLuckerForClient( client );
// 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
lucker.Position = tx.Position;
}
}
}