/// <summary> /// Since character selection at the moment is the final stage in the menus, this loads the new level based on the previous /// level selection and current character selection /// </summary> void OnCharacterSelect(Button button, MouseButtonEventArgs eventArgs, string characterSelection) { if (LKernel.Get<MainMenuUIHandler>().GameType == GameTypeEnum.SinglePlayer) { this.characterSelection = characterSelection; LevelChangeRequest request = new LevelChangeRequest() { NewLevelName = levelSelection, CharacterNames = new string[] { characterSelection }, IsMultiplayer = false, }; LKernel.GetG<LevelManager>().LoadLevel(request); } }
// why is this in here? :U public void Start_Game() { if (LKernel.Get<MainMenuUIHandler>().GameType == GameTypeEnum.NetworkedClient) { var characters = new string[netMgr.Players.Count]; foreach (NetworkEntity p in netMgr.Players) { characters[p._GlobalID] = p.Selection ?? "Twilight Sparkle"; } LevelChangeRequest request = new LevelChangeRequest() { NewLevelName = _levelSelection, CharacterNames = characters, IsMultiplayer = true, }; LKernel.GetG<LevelManager>().LoadLevel(request); } }
/// <summary> /// Loads a level! /// </summary> /// <param name="delay"> /// Minimum time to wait (in seconds) before we load the level, to let stuff like loading screens have a chance to render. /// Pass 0 to load the new level instantly. /// </param> public void LoadLevel(LevelChangeRequest request, float delay = INITIAL_DELAY) { Pauser.IsPaused = false; var eventArgs = new LevelChangedEventArgs(new Level(request.NewLevelName), CurrentLevel, request); // fire our preUnload events Invoke(OnLevelPreUnload, eventArgs); if (delay > 0) { // we need to have this because otherwise we start loading before we manage to render a frame, and we need to render a frame to // show stuff like a loading screen // reset these elapsed = 0; frameOneRendered = frameTwoRendered = false; // set up a little frame started handler with our events preUnloadFrameStartedHandler = new FrameListener.FrameStartedHandler( (fe) => { return DelayedRun_FrameStarted(fe, delay, LoadLevelNow, eventArgs); }); LKernel.Get<Root>().FrameStarted += preUnloadFrameStartedHandler; } else { // if our delay is 0, just load the level and don't do any of the delayed stuff LoadLevelNow(eventArgs); } }
/// <summary> /// Since character selection at the moment is the final stage in the menus, this loads the new level based on the previous /// level selection and current character selection /// </summary> void OnCharacterSelect(Button button, MouseButtonEventArgs eventArgs, string characterSelection) { //This will need to do other things at some point. //Like what, past Elision? You're so f*****g helpful. this.characterSelection = characterSelection; if (LKernel.Get<MainMenuUIHandler>().GameType == GameTypeEnum.NetworkedHost) { var localplayer = (from p in netMgr.Players where p.local select p).First(); localplayer.SetSelection(characterSelection); string[] characters = new string[netMgr.Players.Count]; foreach (NetworkEntity p in netMgr.Players) { characters[p._GlobalID] = p.Selection ?? "Twilight Sparkle"; } LevelChangeRequest request = new LevelChangeRequest() { NewLevelName = _levelSelection, CharacterNames = characters, IsMultiplayer = true, }; LKernel.GetG<LevelManager>().LoadLevel(request); netMgr.ForEachConnection(c => c.SendPacket(Commands.StartGame, _levelSelection, false)); } else if (LKernel.Get<MainMenuUIHandler>().GameType == GameTypeEnum.NetworkedClient) { try { var MainPlayer = (from p in netMgr.Players where p.local select p).First(); netMgr.SingleConnection.SendPacket(Commands.RequestPlayerChange, MainPlayer.SerializeChange("Selection", characterSelection)); } finally { } } }