public ICommand CreateCommand() { if (app.WorldDirty) { DialogResult dlgRes = MessageBox.Show("You have unsaved changes. You will have to save the file or cancel", "Save Changes?", MessageBoxButtons.OKCancel, MessageBoxIcon.Information); switch (dlgRes) { case DialogResult.OK: EventArgs e = new EventArgs(); if (app.WorldRoot != null && app.WorldRoot.WorldFilePath != null && !String.Equals(app.WorldRoot.WorldFilePath, "")) { app.SaveWorld(app.WorldRoot.WorldFilePath); app.ResetDirtyWorld(); } else { using (SaveFileDialog dlg = new SaveFileDialog()) { string filename = ""; dlg.Title = "Save World"; dlg.DefaultExt = "mvw"; if (app.WorldRoot != null && app.WorldRoot.WorldFilePath != null) { filename = app.WorldRoot.WorldFilePath; dlg.FileName = app.WorldRoot.WorldFilePath; foreach (WorldObjectCollection obj in app.WorldRoot.WorldObjectCollections) { obj.Filename = ""; } } else { if (app.WorldRoot == null) { return(null); } } dlg.Filter = "Multiverse World files (*.mvw)|*.mvw|xml files (*.xml)|*.xml|All files (*.*)|*.*"; dlg.RestoreDirectory = true; if (dlg.ShowDialog() == DialogResult.OK) { app.WorldRoot.WorldFilePath = dlg.FileName; string title = String.Format("World Editor : {0}", dlg.FileName.Substring(dlg.FileName.LastIndexOf("\\") + 1)); app.SaveWorld(dlg.FileName); app.ResetDirtyWorld(); } } } break; case DialogResult.Cancel: return(null); } } ICommand cmd = new UnloadCollectionCommand(app, topCollection); return(cmd); }
public void PlayGame() { if (worldEditor.WorldName != "") { GameObject spawnPoint = GameObject.FindGameObjectWithTag("Beginning"); GameObject endPoint = GameObject.FindGameObjectWithTag("Ending"); if (spawnPoint != null) { if (endPoint != null) { worldEditor.SaveWorld(false); EditorUI.SetActive(false); PlayButton.SetActive(false); GameUI.SetActive(true); GameUIManager.singleton.RestHearts(); worldEditor.Cursor.SetActive(false); worldEditor.MainCamera.GetComponent <CameraOrbiting>().enabled = false; worldEditor.MainCamera.GetComponent <SmoothCamera2D>().enabled = true; worldEditor.enabled = false; endPoint.GetComponent <SpriteRenderer>().color = Color.clear; spawnPoint.GetComponent <SpriteRenderer>().color = Color.clear; if (isEditor) { StopButton.SetActive(true); } player = Instantiate(PlayerPrefab, spawnPoint.transform.position, Quaternion.identity); //Check Delegate if isn't null if (GameHasBeenStarted != null) { GameHasBeenStarted(); } //PlayerProperties if (doublejump) { player.GetComponent <PlatformerMotor2D>().numOfAirJumps = 1; } if (walljump) { player.GetComponent <PlatformerMotor2D>().enableWallJumps = true; } if (wallstick) { player.GetComponent <PlatformerMotor2D>().enableWallSticks = true; } if (wallslide) { player.GetComponent <PlatformerMotor2D>().enableWallSlides = true; } if (cornergrab) { player.GetComponent <PlatformerMotor2D>().enableCornerGrabs = true; } if (dash) { player.GetComponent <PlatformerMotor2D>().enableDashes = true; } Fade.singleton.FadeIn(0f); Fade.singleton.FadeOut(6f); spawnPoint.GetComponent <Beginning>().PlayAnimation(); } else { Notifications.singleton.GetNotification("No Ending!", Color.yellow); } } else { Notifications.singleton.GetNotification("No Beginning!", Color.yellow); } } else { Notifications.singleton.GetNotification("No Name!", Color.yellow); } }