public async Task <bool> ActivateNode() { // Verify the Node is ready. if (!await RunNodeReadiness()) { return(false); } // Get Current Tile Data byte[] wtData = this.worldContent.GetWorldTileData(this.currentZone, this.character.curX, this.character.curY); // Identify Level Data at this node: int coordId = Coords.MapToInt(this.character.curX, this.character.curY); string levelId = this.currentZone.nodes.ContainsKey(coordId.ToString()) ? this.currentZone.nodes[coordId.ToString()] : ""; // If the level is valid, we can enter the level. bool isWon = this.campaign.IsLevelWon(this.campaign.zoneId, levelId); // Grant Character Their World Equipment On Casual or Beaten Nodes (after scene generated) if (!isWon && (wtData[5] != (byte)OTerrainObjects.NodeCasual && wtData[5] != (byte)OTerrainObjects.NodeWon)) { CampaignState campaign = Systems.handler.campaignState; campaign.SetUpgrades(0, 0, 0, 0, 0, 0, 0); campaign.SaveCampaign(); } SceneTransition.ToLevel(this.worldData.id, levelId, true); return(true); }
// Go to Level Scene (In World) public static void ToLevel(string worldId, string levelId, bool grantCampaignEquipment = false, bool finalTest = false) { GameHandler handler = Systems.handler; // If we're already in a Level Scene, verify that we're loading a level that's different from our current one. if (Systems.scene is LevelScene && levelId == handler.levelContent.levelId) { return; } // Get Level Path & Retrieve Level Data if (!handler.levelContent.LoadLevelData(levelId)) { if (finalTest == false) { _ = SceneTransition.DownloadLevel(worldId, levelId); } return; } // Update the Level State handler.levelState.SetLevel(levelId, 0); // Prepare Next Scene SceneTransition.nextScene = new LevelScene(grantCampaignEquipment); }
// Close the menu and attempt to load the designated world. public void LoadWorldAttempt() { UIHandler.SetMenu(null, false); string worldID = this.worldIdInput.text.ToUpper(); SceneTransition.ToWorld(worldID); }
// Download a Level private static async Task <bool> DownloadLevel(string worldId, string levelId) { bool success = await WebHandler.LevelRequest(levelId); if (success) { SceneTransition.ToLevel(worldId, levelId, false, true); } return(true); }
// Download a World private static async Task <bool> DownloadWorld(string worldId) { bool success = await WebHandler.WorldRequest(worldId); if (success) { SceneTransition.ToWorld(worldId, true); } return(true); }
public static void ToEditor() { ConsoleTrack.possibleTabs = "Example: `editor`"; ConsoleTrack.helpText = "Load the world editor for this world. No additional parameters required."; if (ConsoleTrack.activate) { // Transition to an Editor Scene SceneTransition.ToWorldEditor(Systems.handler.worldContent.worldId); } }
public virtual void EndLevel() { // If there is an active world, return to the world stage. if (Systems.handler.campaignState.worldId.Length > 0) { SceneTransition.ToWorld(Systems.handler.campaignState.worldId); return; } // Otherwise, go to the planet selection scene: SceneTransition.ToPlanetSelection(); }
public static void WorldChange() { string currentIns = ConsoleTrack.GetArgAsString(); ConsoleTrack.possibleTabs = "Example: `load-world worldIdHere`"; ConsoleTrack.helpText = "This will load a world (if it exists). Enter the world ID of the world to load."; if (ConsoleTrack.activate && currentIns.Length > 0) { SceneTransition.ToWorld(currentIns); } }
public static void LoadWorldEditor() { string currentIns = ConsoleTrack.GetArgAsString(); ConsoleTrack.possibleTabs = "Example: `load-world worldIdHere`"; ConsoleTrack.helpText = "The world ID of the world to load. Will load a world (if it exists)."; if (ConsoleTrack.activate) { SceneTransition.ToWorldEditor(currentIns); } }
private void LoadWorldById(string worldID) { // Load the Special "Users World" menu. if (worldID == "_users") { UIHandler.SetMenu(UIHandler.loadWorldMenu, false); return; } SceneTransition.ToWorld(worldID); return; }
public static void LoadLevelEditor() { string currentIns = ConsoleTrack.GetArgAsString(); ConsoleTrack.possibleTabs = "Example: `load-level QCALQOD16`"; ConsoleTrack.helpText = "The level ID of the level to load."; if (ConsoleTrack.activate) { SceneTransition.ToLevelEditor("", currentIns); } }
public override void ActivateWorldFuncButton() { WEScene scene = (WEScene)Systems.scene; Systems.handler.worldContent.SaveWorld(); GameValues.LastAction = "WEPlayButton"; if (scene.tutorial.tutorialStep == TutorialWorldEdit.finalStep) { UIHandler.AddNotification(UIAlertType.Warning, "Playtest Fixes", "If something goes wrong, don't worry. Return to map editing or reset your position through the tilde (~) console.", 1500); } SceneTransition.ToWorld(scene.worldContent.worldId); }
public override void ActivateFuncButton() { EditorScene scene = (EditorScene)Systems.scene; Systems.handler.levelContent.SaveLevel(); GameValues.LastAction = "EditorPlayButton"; if (scene.tutorial.tutorialStep == TutorialEditor.finalStep) { UIHandler.AddNotification(UIAlertType.Warning, "Playtest Fixes", "If something goes wrong, don't worry. You can open the tilde (~) console enter `editor` to return to the level editor.", 1500); } SceneTransition.ToLevel("", scene.levelContent.levelId); }
public static void ToEditor() { string currentIns = ConsoleTrack.GetArgAsString(); ConsoleTrack.possibleTabs = "Example: `editor 10`"; ConsoleTrack.helpText = "Load the level editor for one of your levels."; if (ConsoleTrack.activate) { // Prepare the current level as the default option. string levelId = currentIns == "" ? Systems.handler.levelContent.levelId : currentIns; // Transition to an Editor Scene SceneTransition.ToLevelEditor("", levelId); } }
public void CheckPlanetHover() { // Reset Mouse Highlight Positions this.mouseHighX = 0; this.mouseHighY = 0; short posX = 100 - 200; short posY = 150; int mouseX = Cursor.MouseX; int mouseY = Cursor.MouseY; // Draw Planets for (short i = this.paging.MinVal; i < this.paging.MaxVal; i++) { // Update Next Position posX += 200; if (posX >= 1380) { posY += 200; posX = 100; } if (mouseX < posX - 60 || mouseX > posX + 95 || mouseY < posY - 60 || mouseY > posY + 135) { continue; } this.mouseHighX = posX; this.mouseHighY = posY; // Activate Level if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked) { SceneTransition.ToLevelEditor("", "__" + i.ToString(), i); return; } } }
// Go to World Scene public static void ToWorld(string worldId, bool finalTest = false) { GameHandler handler = Systems.handler; // If we're already in a World Scene, verify that we're loading a different world from our current one. if (Systems.scene is WorldScene && worldId == handler.worldContent.worldId) { return; } // Get World Path & Retrieve World Data if (!handler.worldContent.LoadWorldData(worldId)) { if (finalTest == false) { _ = SceneTransition.DownloadWorld(worldId); } return; } // Prepare Next Scene SceneTransition.nextScene = new WorldScene(); }
public override void RunTick() { // Update Timer Systems.timer.RunTick(); // Loop through every player and update inputs for this frame tick: foreach (var player in Systems.localServer.players) { //player.Value.input.UpdateKeyStates(Systems.timer.Frame); player.Value.input.UpdateKeyStates(0); // TODO: Update LocalServer so frames are interpreted and assigned here. } // Paging Input (only when in the paging area) InputClient input = Systems.input; // Update UI UIComponent.ComponentWithFocus = null; Cursor.UpdateMouseState(); UIHandler.cornerMenu.RunTick(); // Playing State if (UIHandler.uiState == UIState.Playing) { PagingPress pageInput = this.paging.PagingInput(playerInput); if (pageInput != PagingPress.None) { Systems.sounds.click2.Play(0.5f, 0, 0.5f); if (pageInput == PagingPress.PageChange) { // Apply New Level Data for (short i = this.paging.MinVal; i < this.paging.MaxVal; i++) { this.ApplyLevelDataByNumber(i); } } } // Check if the mouse is hovering over a planet (and draw accordingly if so) this.CheckPlanetHover(); // Activate Level if (playerInput.isPressed(IKey.AButton) == true) { short curVal = this.paging.CurrentSelectionVal; SceneTransition.ToLevelEditor("", "__" + curVal.ToString(), curVal); return; } // Open Menu if (input.LocalKeyPressed(Keys.Escape) || playerInput.isPressed(IKey.Start) || playerInput.isPressed(IKey.Select)) { UIHandler.SetMenu(UIHandler.mainMenu, true); } } // Menu State else { UIHandler.menu.RunTick(); } }
public MainMenu() { this.textBox = new TextBox(null, (short)(Systems.screen.viewHalfWidth - 150 - 16), (short)(Systems.screen.viewHalfHeight - 150 - 16), 316, 378); short centerX = (short)(Systems.screen.viewHalfWidth - 28); short centerY = (short)(Systems.screen.viewHalfHeight - 28 + 40); this.menuTextPos = (short)(Systems.screen.viewHalfWidth - Systems.fonts.baseText.font.MeasureString(MainMenu.menuText).X * 0.5f); //this.goBack = new UICreoTextIcon(null, "Back", "Return", centerX, centerY, delegate () { UIHandler.SetMenu(null, false); } ); this.log = new UICreoTextIcon(null, "Login", "Login", (short)(centerX - 66 - 50), centerY, delegate() { UIHandler.SetMenu(UIHandler.loginMenu, true); UIHandler.loginMenu.ShowMenu(); }); this.controls = new UICreoTextIcon(null, "Gamepad", "Controls", (short)(centerX - 66 - 50), (short)(centerY - 66 - 50), delegate() { UIHandler.SetMenu(UIHandler.controlMenu, true); }); this.worlds = new UICreoTextIcon(null, "MyWorld", "Worlds", centerX, (short)(centerY - 66 - 50), delegate() { SceneTransition.ToPlanetSelection(); }); this.myLevels = new UICreoTextIcon(null, "MyLevels", "My Levels", (short)(centerX + 66 + 50), centerY, delegate() { SceneTransition.ToMyLevels(); }); //this.TOP_RIGHT = new UICreoTextIcon(null, "MyWorld", "My World", (short)(centerX + 66 + 50), (short)(centerY - 66 - 50), delegate () { SceneTransition.ToWorldEditor("__WORLD"); } ); this.myWorld = new UICreoTextIcon(null, "MyWorld", "My World", centerX, (short)(centerY + 66 + 50), delegate() { SceneTransition.ToWorldEditor("__WORLD"); }); }