/// <summary> /// Unload game content. /// </summary> public void Unload() { GameManager.Content.Unload(); NetworkHandler = null; Background = null; Gui = null; LocalPlayer.Reset(); }
/// <summary> /// Loads anything that we missed. Really, this should do nothing, but /// it is required by IScene. /// </summary> /// <param name="handover">null.</param> public void Load(object handover) { NetworkHandler = (GameNetworkHandler)handover; Background = new Background(); Gui = new InGameGui(); Desktop.Root = Gui; SoundManager.PlaySong("Music/bg_heartbeat"); LocalPlayer.StartEffects(); }
/// <summary> /// Begins loading resources for the game. /// </summary> /// <param name="handover">object[] { host, port, token }</param> public void Load(object handover) { try { // Get server info from handover object[] inputs = (object[])handover; string host = (string)inputs[0]; int port = (int)inputs[1]; int token = (int)inputs[2]; // Load resources required for loading screen ContentManager content = GameManager.Content; LoadingScreen = content.Load <Texture2D>("Backgrounds/title_screen"); StatusLabel = new GuiLabel( 16, 16, "Loading", content.Load <SpriteFont>("Fonts/Arial14"), Color.White ); // Instantiate network handler NetworkHandler = new GameNetworkHandler(); // Begin asynchronously loading game resources, connecting // to server. LoadTask = Task.Run(() => LoadGameResources()); ConnectTask = Task.Run(() => { try { NetworkManager.Connect( host, port, token, NetworkHandler ); } catch (Exception e) { Trace.WriteLine("Exception in LoadGameScene.Load:"); Trace.WriteLine(e.ToString()); // Goto error scene. SceneManager.GotoScene <ErrorScene>(); } }); } catch (Exception e) { Trace.WriteLine("Exception in LoadGameScene.Load():"); Trace.WriteLine(e.ToString()); // Goto error scene. SceneManager.GotoScene <ErrorScene>(); } }
//Shared initialization stuff private void Awake() { QueuedCommands = new List <string>(); QueuedCommands.Add(""); localPlayerID = -1; Application.runInBackground = true; instance = this; spawnLocations = FindObjectsOfType <NetworkSpawnLocation>(); players = new List <NetworkPlayer>(); networkObjects = new List <NetworkObject>(); myLocalPlayer = new NetworkPlayer(); }
/// <summary> /// Begins loading resources for the game. /// </summary> /// <param name="handover">NetworkHandler</param> public void Load(object handover) { // Load resources required for loading screen ContentManager content = GameManager.Content; LoadingScreen = content.Load <Texture2D>("Backgrounds/title_screen"); StatusLabel = new GuiLabel( 16, 16, "Waiting for players", content.Load <SpriteFont>("Fonts/Arial14"), Color.White ); // Send client is ready message. NetworkHandler = (GameNetworkHandler)handover; NetworkHandler.SendMessage(PacketWriter.ClientIsReady()); }
/// <summary> /// Begins countdown for the game. /// </summary> /// <param name="handover">int time</param> public void Load(object handover) { NetworkHandler = (GameNetworkHandler)handover; Time = 6000; // Todo: Rework this yet again. // Load resources required for loading screen ContentManager content = GameManager.Content; LoadingScreen = content.Load <Texture2D>("Backgrounds/title_screen"); StatusLabel = new GuiLabel( 16, 16, "Beginning Countdown", content.Load <SpriteFont>("Fonts/Arial14"), Color.White ); // Start countdown Timer.Reset(); Timer.Start(); }
/// <summary> /// Reset state. /// </summary> public void Unload() { LoadingScreen = null; NetworkHandler = null; }