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; /// /// 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. /// public partial class LuckerGameManager : GameManager { /// /// Called when the game is created (on both the server and client) /// public LuckerGameManager() { if ( Game.IsClient ) { Game.RootPanel = new Hud(); } else if ( Game.IsServer ) { var roundManager = new RoundManager(); } } public override void PostLevelLoaded() { base.PostLevelLoaded(); } /// /// A client has joined the server. Make them a pawn to play with /// 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(); // 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; } } }