private void DestroyAllCubes() { foreach (var cube in _cubes) { _destroyer.Destroy(cube); } }
// Create the about dialog public void About() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Sprite bannerSprite; Texture2D newTex = Resources.Load("sprites/banner") as Texture2D; GameObject banner = new GameObject("banner"); banner.tag = "dialog"; banner.transform.parent = Game.Get().uICanvas.transform; RectTransform trans = banner.AddComponent<RectTransform>(); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit()); banner.AddComponent<CanvasRenderer>(); UnityEngine.UI.Image image = banner.AddComponent<UnityEngine.UI.Image>(); bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1); image.sprite = bannerSprite; image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); DialogBox db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 10f), new Vector2(30, 6), "Valkyrie is a game master helper tool inspired by Fantasy Flight Games' Descent: Road to Legend. Most images used are imported from FFG applications are are copyright FFG and other rights holders."); db.textObj.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 18f), new Vector2(30, 5), "Valkyrie uses DotNetZip-For-Unity and has code derived from Unity Studio."); db.textObj.GetComponent<UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); TextButton tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); }); tb.background.GetComponent<UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public MainMenuScreen() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Game game = Game.Get(); // Name. Should this be the banner, or better to print Valkyrie with the game font? DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Valkyrie"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); // Button for start quest/scenario TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 5), new Vector2(12, 2f), "Start " + game.gameType.QuestName(), delegate { Start(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // Load save game (enabled if exists) if (SaveManager.SaveExists()) { tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 8), new Vector2(12, 2f), "Load " + game.gameType.QuestName(), delegate { SaveManager.Load(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); } else { db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 8), new Vector2(12, 2f), "Load " + game.gameType.QuestName(), Color.red); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.SetFont(game.gameType.GetHeaderFont()); db.AddBorder(); } // Content selection page tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 11), new Vector2(12, 2f), "Select Content", delegate { Content(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // Quest/Scenario editor tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 14), new Vector2(12, 2f), game.gameType.QuestName() + " Editor", delegate { Editor(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); // About page (managed in this class) tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 17), new Vector2(12, 2f), "About", delegate { About(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); /* * // Configuration menu * tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 20), new Vector2(12, 2f), "Options", delegate { Config(); }); * tb.background.GetComponent<UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); * tb.SetFont(game.gameType.GetHeaderFont()); */ // Exit Valkyrie tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 20), new Vector2(12, 2f), "Exit", delegate { Exit(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(game.gameType.GetHeaderFont()); }
// Create page public ContentSelectScreen() { // Clean everything up Destroyer.Destroy(); game = Game.Get(); // Find any content packs at the location game.cd = new ContentData(game.gameType.DataDirectory()); // Check if we found anything (must have found at least base) if (game.cd.allPacks.Count == 0) { ValkyrieDebug.Log("Error: Failed to find any content packs, please check that you have them present in: " + game.gameType.DataDirectory() + System.Environment.NewLine); Application.Quit(); } // load base to get types game.cd.LoadContentID(""); if (game.cd.packTypes.Count > 1) { DrawTypeList(); } else { DrawList(""); } }
// Import content public void Import(string type) { Destroyer.Destroy(); // Create the image Texture2D tex = Resources.Load("sprites/logo") as Texture2D; Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1); DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-3), 8), new Vector2(6, 6), StringKey.NULL, Color.clear, Color.white); db.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite; db.background.AddComponent <SpritePulser>(); // Display message db = new DialogBox(new Vector2(2, 20), new Vector2(UIScaler.GetWidthUnits() - 4, 2), CONTENT_IMPORTING); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); if (type.Equals("D2E")) { importThread = new Thread(new ThreadStart(delegate { fcD2E.Import(); })); } if (type.Equals("MoM")) { importThread = new Thread(new ThreadStart(delegate { fcMoM.Import(); })); } importThread.Start(); //while (!importThread.IsAlive) ; }
public void Test() { if (GameObject.FindGameObjectWithTag(Game.DIALOG) != null) { return; } Game game = Game.Get(); string path = game.quest.questPath; Destroyer.Destroy(); game.cd = new ContentData(game.gameType.DataDirectory()); foreach (string pack in game.cd.GetPacks()) { game.cd.LoadContent(pack); } game.testMode = true; // Fetch all of the quest data and initialise the quest game.quest = new Quest(new QuestData.Quest(path)); game.heroCanvas.SetupUI(); int heroCount = Random.Range(game.quest.qd.quest.minHero, game.quest.qd.quest.maxHero + 1); List <HeroData> hOptions = new List <HeroData>(game.cd.heroes.Values); for (int i = 0; i < heroCount; i++) { game.quest.heroes[i].heroData = hOptions[Random.Range(0, hOptions.Count)]; hOptions.Remove(game.quest.heroes[i].heroData); } // Starting morale is number of heros game.quest.vars.SetValue("$%morale", heroCount); // Set quest flag based on hero count game.quest.vars.SetValue("#heroes", heroCount); game.quest.heroesSelected = true; // Clear off heros if not required if (!game.gameType.DisplayHeroes()) { game.heroCanvas.Clean(); } else { game.heroCanvas.UpdateImages(); game.heroCanvas.UpdateStatus(); } // Draw morale if required if (game.gameType is D2EGameType) { new ClassSelectionScreen(); } else { new InvestigatorItems(); } }
// On quitting void OnApplicationQuit() { // This exists for the editor, because quitting doesn't actually work. Destroyer.Destroy(); // Clean up temporary files QuestLoader.CleanTemp(); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public MainMenu() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Game game = Game.Get(); // Name. We should replace this with a banner DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Valkyrie"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 10), new Vector2(12, 2f), "Start " + game.gameType.QuestName(), delegate { Start(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 13), new Vector2(12, 2f), "Select Content", delegate { Content(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 16), new Vector2(12, 2f), game.gameType.QuestName() + " Editor", delegate { Editor(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 19), new Vector2(12, 2f), "About", delegate { About(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 22), new Vector2(12, 2f), "Exit", delegate { Exit(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); }
// This takes us to the quest select screen public static void List() { // Destroy everything Destroyer.Destroy(); Game game = Game.Get(); game.SelectQuest(); }
// Create a menu which will take up the whole screen and have options. All items are dialog for destruction. public OptionsScreen() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); // Create elements for the screen CreateElements(); }
public void Import(string type) { Destroyer.Destroy(); DialogBox db = new DialogBox(new Vector2(2, 10), new Vector2(UIScaler.GetWidthUnits() - 4, 2), "Importing..."); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); Game.Get().CallAfterFrame(delegate { PerformImport(type); }); }
public static void EditQuest(string path) { ValkyrieDebug.Log("Starting Editor" + Environment.NewLine); Destroyer.Destroy(); Game.Get().audioControl.StopMusic(); QuestEditor.Begin(path); }
void OnTriggerEnter (Collider other) { if(other.gameObject.tag != "Door") destroyer.Destroy (other); }
// Import content public void Import(string type, bool manual_path_selection = false) { string path = null; ValkyrieDebug.Log("INFO: Import " + type); if (manual_path_selection) { string app_filename = ""; if (type.Equals("D2E")) { app_filename = "Road to Legend"; } if (type.Equals("MoM")) { app_filename = "Mansions of Madness"; } string[] array_path = SFB.StandaloneFileBrowser.OpenFilePanel("Select file " + app_filename + ".exe", "", "exe", false); // return when pressing back if (array_path.Length == 0) { return; } path = Path.Combine(Path.GetDirectoryName(array_path[0]), app_filename + "_Data"); // return if wrong file is selected if (!Directory.Exists(path)) { return; } } Destroyer.Destroy(); new LoadingScreen(CONTENT_IMPORTING.Translate()); importType = type; if (type.Equals("D2E")) { importThread = new Thread(new ThreadStart(delegate { fcD2E.Import(path); })); } if (type.Equals("MoM")) { importThread = new Thread(new ThreadStart(delegate { fcMoM.Import(path); })); } #if IA if (type.Equals("IA")) { importThread = new Thread(new ThreadStart(delegate { fcIA.Import(path); })); } #endif importThread.Start(); }
// Import content public void Import(string type) { Destroyer.Destroy(); // Display message DialogBox db = new DialogBox(new Vector2(2, 10), new Vector2(UIScaler.GetWidthUnits() - 4, 2), CONTENT_IMPORTING); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); // Perform importing later, to ensure message is displayed first Game.Get().CallAfterFrame(delegate { PerformImport(type); }); }
private void Act() { if (IsAlive) { anchoredMover.MoveRelativeToSelf(AnchoredMover.Forward); } else { destroyer.Destroy(); } }
// Create the about dialog public void About() { ValkyrieDebug.Log("INFO: Accessing about"); // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Sprite bannerSprite; Texture2D newTex = Resources.Load("sprites/banner") as Texture2D; GameObject banner = new GameObject("banner"); banner.tag = Game.DIALOG; banner.transform.SetParent(Game.Get().uICanvas.transform); RectTransform trans = banner.AddComponent <RectTransform>(); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit()); banner.AddComponent <CanvasRenderer>(); Image image = banner.AddComponent <Image>(); bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1); image.sprite = bannerSprite; image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); UIElement ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 30f) / 2, 10, 30, 6); ui.SetText(ABOUT_FFG); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 30f) / 2, 18, 30, 5); ui.SetText(ABOUT_LIBS); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetWidthUnits() - 5, UIScaler.GetBottom(-3), 5, 2); ui.SetText(Game.Get().version); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(GameStateManager.MainMenu); ui.SetBGColor(BUTTON_BG_COLOR); new UIElementBorder(ui); }
private void Act() { if (IsAlive) { mover.Move(Mover.Foward); } else { destroyer.Destroy(); } }
private void Update() { if (Input.GetKeyDown(KeyCode.D)) { Destroyer.Destroy(transform); } if (Input.GetKeyDown(KeyCode.I)) { Instantiater.Instantiate(transform); } }
// Create the about dialog public void About() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); Sprite bannerSprite; Texture2D newTex = Resources.Load("sprites/banner") as Texture2D; GameObject banner = new GameObject("banner"); banner.tag = Game.DIALOG; banner.transform.SetParent(Game.Get().uICanvas.transform); RectTransform trans = banner.AddComponent <RectTransform>(); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit()); banner.AddComponent <CanvasRenderer>(); UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>(); bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1); image.sprite = bannerSprite; image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit()); DialogBox db = new DialogBox( new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 10f), new Vector2(30, 6), ABOUT_FFG); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox( new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 18f), new Vector2(30, 5), ABOUT_LIBS); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox( new Vector2(UIScaler.GetWidthUnits() - 5, UIScaler.GetBottom(-3)), new Vector2(5, 2), new StringKey(null, Game.Get().version, false)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); TextButton tb = new TextButton( new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Destroyer.MainMenu(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
public SaveSelectScreen(bool performSave = false, Texture2D s = null) { save = performSave; if (!save) { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); } saves = SaveManager.GetSaves(); // Create elements for the screen CreateElements(); }
// This function takes us back to the main menu public static void MainMenu() { // Destroy everything Destroyer.Destroy(); Game game = Game.Get(); // All content data has been loaded by editor, cleanup everything game.cd = new ContentData(game.gameType.DataDirectory()); // Load the base content - pack will be loaded later if required game.ContentLoader.LoadContentID(""); new MainMenuScreen(); }
public void OnEnnemySensed(EnnemyController ennemy) { switch (type) { case PickableTypes.Medkit: ennemy.Heal(hitpoints); NotifyPickableDestroyed(); destroyer.Destroy(); break; case PickableTypes.Shotgun: ennemy.transform.root.GetComponentInChildren <HandController>().Hold(WeaponType.Shotgun); NotifyPickableDestroyed(); destroyer.Destroy(); break; case PickableTypes.Uzi: ennemy.transform.root.GetComponentInChildren <HandController>().Hold(WeaponType.Uzi); NotifyPickableDestroyed(); destroyer.Destroy(); break; } }
// Restarts the current quest public static void Restart() { Game game = Game.Get(); if (!GetCurrentQuest(game, out QuestData.Quest currentQuest)) { // Failsafe. Go to quest selection if there's no valid quest loaded List(); return; } // Go back to quest details Destroyer.Destroy(); new QuestDetailsScreen(currentQuest); }
// Create page public ContentSelectScreen() { // Clean everything up Destroyer.Destroy(); game = Game.Get(); if (game.cd.Count <PackTypeData>() > 1) { DrawTypeList(); } else { DrawList(""); } }
public ContentSelect() { Destroyer.Destroy(); game = Game.Get(); // Find any content packs at the location game.cd = new ContentData(game.gameType.DataDirectory()); // Check if we found anything if (game.cd.allPacks.Count == 0) { Debug.Log("Error: Failed to find any content packs, please check that you have them present in: " + game.gameType.DataDirectory() + System.Environment.NewLine); Application.Quit(); } Update(); }
// Import content public void Import(string type) { Destroyer.Destroy(); new LoadingScreen(CONTENT_IMPORTING.Translate()); importType = type; if (type.Equals("D2E")) { importThread = new Thread(new ThreadStart(delegate { fcD2E.Import(); })); } if (type.Equals("MoM")) { importThread = new Thread(new ThreadStart(delegate { fcMoM.Import(); })); } importThread.Start(); }
public static void Editor() { Game game = Game.Get(); string path = game.quest.questPath; Destroyer.Destroy(); foreach (string pack in game.cd.GetPacks()) { game.cd.LoadContent(pack); } // Stop music game.audioControl.StopMusic(); ValkyrieDebug.Log("Starting Editor" + System.Environment.NewLine); QuestEditor.Begin(path); }
public static void EditCurrentQuest() { var game = Game.Get(); if (!GetCurrentQuestPath(game, out var currentQuestPath)) { // Failsafe. Go to main menu if there's no valid quest loaded MainMenu(); return; } ValkyrieDebug.Log("Starting Editor" + Environment.NewLine); Destroyer.Destroy(); game.audioControl.StopMusic(); QuestEditor.Begin(currentQuestPath); }
public void About() { // This will destroy all, because we shouldn't have anything left at the main menu Destroyer.Destroy(); // Name. We should replace this with a banner DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Valkyrie"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 8f), new Vector2(30, 6), "Valkyrie is a game master helper tool inspired by Fantasy Flight Games' Descent: Road to Legend. Most images used are imported from FFG applications are are copyright FFG and other rights holders."); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 16f), new Vector2(30, 5), "Valkyrie uses DotNetZip-For-Unity and has code derived from Unity Studio."); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); TextButton tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); }); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f); }