// Return a single quest, quest name is without file extension public static QuestData.Quest GetSingleQuest(string questName, bool getHidden = false) { QuestData.Quest quest = null; Game game = Game.Get(); // Look in the user application data directory string dataLocation = Game.AppData(); mkDir(dataLocation); mkDir(ContentData.DownloadPath()); string path = ContentData.DownloadPath() + Path.DirectorySeparatorChar + questName + ".valkyrie"; QuestLoader.ExtractSinglePackagePartial(path); // load quest QuestData.Quest q = new QuestData.Quest(Path.Combine(ContentData.TempValyriePath, Path.GetFileName(path))); // Check quest is valid and of the right type if (q.valid && q.type.Equals(game.gameType.TypeName())) { // Is the quest hidden? if (!q.hidden || getHidden) { // Add quest to quest list quest = q; } } // Return list of available quests return(quest); }
// Return list of quests available in the user path unpackaged (editable) public static Dictionary <string, QuestData.Quest> GetUserUnpackedQuests() { var quests = new Dictionary <string, QuestData.Quest>(); // Read user application data for quests string dataLocation = Game.AppData(); mkDir(dataLocation); List <string> questDirectories = GetUnpackedQuests(dataLocation); string tempPath = ContentData.TempPath; string gameType = Game.Get().gameType.TypeName(); // go through all found quests foreach (string p in questDirectories) { // Android stores the temp path in the data dir, we don't want the extracted scenarios from there if (p.StartsWith(tempPath, System.StringComparison.OrdinalIgnoreCase)) { continue; } // read quest var q = new QuestData.Quest(p); // Check if valid and correct type if (q.valid && q.type.Equals(gameType)) { quests.Add(p, q); } } return(quests); }
// This is called when a quest is selected public void StartQuest(QuestData.Quest q) { // Fetch all of the quest data and initialise the quest quest = new Quest(q); // Draw the hero icons, which are buttons for selection heroCanvas.SetupUI(); // Add a finished button to start the quest UIElement ui = new UIElement(Game.HEROSELECT); ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.FINISHED, Color.green); ui.SetFont(gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(EndSelection); new UIElementBorder(ui, Color.green); // Add a title to the page ui = new UIElement(Game.HEROSELECT); ui.SetLocation(8, 1, UIScaler.GetWidthUnits() - 16, 3); ui.SetText(new StringKey("val", "SELECT", gameType.HeroesName())); ui.SetFont(gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); heroCanvas.heroSelection = new HeroSelection(); ui = new UIElement(Game.HEROSELECT); ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.QuestSelect); new UIElementBorder(ui, Color.red); }
/// <summary> /// Select to delete /// </summary> /// <param file="file">File name to delete</param> public void Delete(QuestData.Quest q) { ValkyrieDebug.Log("INFO: Delete quest"); string toDelete = ""; if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie") { toDelete = ContentData.DownloadPath() + Path.DirectorySeparatorChar + Path.GetFileName(q.path); File.Delete(toDelete); // update quest status : downloaded/updated Game.Get().questsList.SetQuestAvailability(Path.GetFileNameWithoutExtension(q.path), false); } else { // this is not an archive, it is a local quest within a directory Directory.Delete(q.path, true); Game.Get().questsList.UnloadLocalQuests(); } Destroyer.Dialog(); // Pull up the quest selection page Game.Get().questSelectionScreen.Show(); }
// Return list of quests available in the user path (includes packages) public static Dictionary <string, QuestData.Quest> GetUserQuests() { Dictionary <string, QuestData.Quest> quests = new Dictionary <string, QuestData.Quest>(); // Read user application data for quests string dataLocation = Game.AppData(); mkDir(dataLocation); List <string> questDirectories = GetUnpackedQuests(dataLocation); // Read extracted packages questDirectories.AddRange(GetUnpackedQuests(ContentData.TempValyriePath)); // go through all found quests foreach (string p in questDirectories) { // read quest QuestData.Quest q = new QuestData.Quest(p); // Check if valid and correct type if (q.valid && q.type.Equals(Game.Get().gameType.TypeName())) { quests.Add(p, q); } } return(quests); }
// Return a dictionary of all available quests public static Dictionary <string, QuestData.Quest> GetQuests(bool getHidden = false) { Dictionary <string, QuestData.Quest> quests = new Dictionary <string, QuestData.Quest>(); Game game = Game.Get(); // Look in the user application data directory string dataLocation = Game.AppData(); mkDir(dataLocation); CleanTemp(); mkDir(ContentData.DownloadPath()); // Get a list of downloaded quest not packed List <string> questDirectories = GetQuests(ContentData.DownloadPath()); // Extract only required files from downloaded packages ExtractPackages(ContentData.DownloadPath()); // Get the list of extracted packages questDirectories.AddRange(GetQuests(ContentData.TempValyriePath)); // Add the list of editor quest if (game.gameType is MoMGameType) { dataLocation += "/MoM/Editor"; } if (game.gameType is D2EGameType) { dataLocation += "/D2E/Editor"; } if (game.gameType is IAGameType) { dataLocation += "/IA/Editor"; } questDirectories.AddRange(GetQuests(dataLocation)); // Go through all directories foreach (string p in questDirectories) { // load quest QuestData.Quest q = new QuestData.Quest(p); // Check quest is valid and of the right type if (q.valid && q.type.Equals(game.gameType.TypeName())) { // Is the quest hidden? if (!q.hidden || getHidden) { // Add quest to quest list quests.Add(p, q); } } } // Return list of available quests return(quests); }
private static bool GetCurrentQuest(Game game, out QuestData.Quest currentQuest) { if (!GetCurrentQuestPath(game, out string questPath)) { currentQuest = null; return(false); } currentQuest = new QuestData.Quest(questPath); return(true); }
void Start() { game = Game.Get(); if (key == "") { Debug.Log("Download key is not set, this should not happen"); return; } QuestData.Quest q = game.questsList.GetQuestData(key); string package = q.package_url + key + ".valkyrie"; StartCoroutine(Download(package, delegate { Save(key); })); }
// Construct a new quest from quest data public Quest(QuestData.Quest q) { game = Game.Get(); // This happens anyway but we need it to be here before the following code is executed game.quest = this; // Static data from the quest file qd = new QuestData(q); // Initialise data boardItems = new Dictionary <string, BoardComponent>(); vars = new VarManager(); items = new HashSet <string>(); monsters = new List <Monster>(); heroSelection = new Dictionary <string, List <Quest.Hero> >(); puzzle = new Dictionary <string, Puzzle>(); eventQuota = new Dictionary <string, int>(); delayedEvents = new List <QuestData.Event.DelayedEvent>(); undo = new Stack <string>(); log = new List <LogEntry>(); monsterSelect = new Dictionary <string, string>(); GenerateMonsterSelection(); eManager = new EventManager(); // Populate null hero list, these can then be selected as hero types heroes = new List <Hero>(); for (int i = 1; i <= game.gameType.MaxHeroes(); i++) { heroes.Add(new Hero(null, i)); } // Set quest vars for selected expansions foreach (string s in game.cd.GetLoadedPackIDs()) { if (s.Length > 0) { vars.SetValue("#" + s, 1); } } }
// Construct a new quest from quest data public Quest(QuestData.Quest q) { game = Game.Get(); // This happens anyway but we need it to be here before the following code is executed game.quest = this; // Static data from the quest file qd = new QuestData(q); // Initialise data boardItems = new Dictionary <string, BoardComponent>(); vars = new VarManager(); items = new HashSet <string>(); monsters = new List <Monster>(); heroSelection = new Dictionary <string, List <Quest.Hero> >(); puzzle = new Dictionary <string, Puzzle>(); eventQuota = new Dictionary <string, int>(); eManager = new EventManager(); delayedEvents = new List <QuestData.Event.DelayedEvent>(); undo = new Stack <string>(); log = new List <LogEntry>(); // Populate null hero list, these can then be selected as hero types heroes = new List <Hero>(); for (int i = 1; i <= game.gameType.MaxHeroes(); i++) { heroes.Add(new Hero(null, i)); } // Set quest vars for selected expansions Dictionary <string, string> packs = game.config.data.Get(game.gameType.TypeName() + "Packs"); if (packs != null) { foreach (KeyValuePair <string, string> kv in packs) { vars.SetValue("#" + kv.Key, 1); } } }
// This is called when a quest is selected public void StartQuest(QuestData.Quest q) { if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie") { // extract the full package QuestLoader.ExtractSinglePackageFull(ContentData.DownloadPath() + Path.DirectorySeparatorChar + Path.GetFileName(q.path)); } // Fetch all of the quest data and initialise the quest quest = new Quest(q); // Draw the hero icons, which are buttons for selection heroCanvas.SetupUI(); // Add a finished button to start the quest UIElement ui = new UIElement(Game.HEROSELECT); ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.FINISHED, Color.green); ui.SetFont(gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(EndSelection); new UIElementBorder(ui, Color.green); // Add a title to the page ui = new UIElement(Game.HEROSELECT); ui.SetLocation(8, 1, UIScaler.GetWidthUnits() - 16, 3); ui.SetText(new StringKey("val", "SELECT", gameType.HeroesName())); ui.SetFont(gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); heroCanvas.heroSelection = new HeroSelection(); ui = new UIElement(Game.HEROSELECT); ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.QuestSelect); new UIElementBorder(ui, Color.red); }
// This is called when a quest is selected public void StartQuest(QuestData.Quest q) { // Fetch all of the quest data and initialise the quest quest = new Quest(q); // Draw the hero icons, which are buttons for selection heroCanvas.SetupUI(); // Add a finished button to start the quest TextButton endSelection = new TextButton( new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.FINISHED, delegate { EndSelection(); }, Color.green); endSelection.SetFont(gameType.GetHeaderFont()); // Untag as dialog so this isn't cleared away during hero selection endSelection.ApplyTag("heroselect"); // Add a title to the page DialogBox db = new DialogBox( new Vector2(8, 1), new Vector2(UIScaler.GetWidthUnits() - 16, 3), new StringKey("val", "SELECT", gameType.HeroesName()) ); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(gameType.GetHeaderFont()); db.ApplyTag("heroselect"); heroCanvas.heroSelection = new HeroSelection(); TextButton cancelSelection = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Destroyer.QuestSelect(); }, Color.red); cancelSelection.SetFont(gameType.GetHeaderFont()); // Untag as dialog so this isn't cleared away during hero selection cancelSelection.ApplyTag("heroselect"); }
// Return list of quests available in the user path unpackaged (editable) public static Dictionary <string, QuestData.Quest> GetUserUnpackedQuests() { Dictionary <string, QuestData.Quest> quests = new Dictionary <string, QuestData.Quest>(); // Read user application data for quests string dataLocation = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/Valkyrie"; mkDir(dataLocation); List <string> questDirectories = GetQuests(dataLocation); // go through all found quests foreach (string p in questDirectories) { // read quest QuestData.Quest q = new QuestData.Quest(p); // Check if valid and correct type if (q.valid && q.type.Equals(Game.Get().gameType.TypeName())) { quests.Add(p, q); } } return(quests); }
// Return a dictionary of all available quests public static Dictionary <string, QuestData.Quest> GetQuests(bool getHidden = false) { Dictionary <string, QuestData.Quest> quests = new Dictionary <string, QuestData.Quest>(); Game game = Game.Get(); // Look in the user application data directory string dataLocation = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData) + "/Valkyrie"; mkDir(dataLocation); CleanTemp(); // Get a list of quest directories (extract found packages) List <string> questDirectories = GetQuests(dataLocation); // Add packaged quests that have been extracted questDirectories.AddRange(GetQuests(Path.GetTempPath() + "Valkyrie")); // Go through all directories foreach (string p in questDirectories) { // load quest QuestData.Quest q = new QuestData.Quest(p); // Check quest is valid and of the right type if (q.valid && q.type.Equals(game.gameType.TypeName())) { // Is the quest hidden? if (!q.hidden || getHidden) { // Add quest to quest list quests.Add(p, q); } } } // Return list of available quests return(quests); }
public SaveData(int num = 0) { Game game = Game.Get(); if (!File.Exists(SaveFile(num))) { return; } try { if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie")) { Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie"); } if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie/Load")) { Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie/Load"); } Directory.Delete(Path.GetTempPath() + "/Valkyrie/Load", true); ZipFile zip = ZipFile.Read(SaveFile(num)); zip.ExtractAll(Path.GetTempPath() + "/Valkyrie/Load"); zip.Dispose(); image = ContentData.FileToTexture(Path.GetTempPath() + "/Valkyrie/Load/image.png"); // Check that quest in save is valid QuestData.Quest q = new QuestData.Quest(Path.GetTempPath() + "/Valkyrie/Load/quest"); if (!q.valid) { ValkyrieDebug.Log("Warning: Save " + num + " contains unsupported quest version." + System.Environment.NewLine); return; } DictionaryI18n tmpDict = LocalizationRead.selectDictionary("qst"); LocalizationRead.AddDictionary("qst", q.localizationDict); quest = q.name.Translate(); LocalizationRead.AddDictionary("qst", tmpDict); string data = File.ReadAllText(Path.GetTempPath() + "/Valkyrie/Load/save.ini"); IniData saveData = IniRead.ReadFromString(data); saveData.Get("Quest", "valkyrie"); if (VersionNewer(game.version, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Warning: Save " + num + " is from a future version." + System.Environment.NewLine); return; } if (!VersionNewerOrEqual(minValkyieVersion, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Warning: Save " + num + " is from an old unsupported version." + System.Environment.NewLine); return; } saveTime = System.DateTime.Parse(saveData.Get("Quest", "time")); valid = true; } catch (System.Exception e) { ValkyrieDebug.Log("Warning: Unable to open save file: " + SaveFile(num) + " " + e.Message); } }
// Load a saved game, does nothing if file does not exist public static void Load(int num = 0) { Game game = Game.Get(); try { if (File.Exists(SaveFile(num))) { if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie")) { Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie"); } if (!Directory.Exists(Path.GetTempPath() + "/Valkyrie/Load")) { Directory.CreateDirectory(Path.GetTempPath() + "/Valkyrie/Load"); } Directory.Delete(Path.GetTempPath() + "/Valkyrie/Load", true); ZipFile zip = ZipFile.Read(SaveFile(num)); zip.ExtractAll(Path.GetTempPath() + "/Valkyrie/Load"); zip.Dispose(); // Check that quest in save is valid QuestData.Quest q = new QuestData.Quest(Path.GetTempPath() + "/Valkyrie/Load/quest"); if (!q.valid) { ValkyrieDebug.Log("Error: save contains unsupported quest version." + System.Environment.NewLine); Destroyer.MainMenu(); return; } string data = File.ReadAllText(Path.GetTempPath() + "/Valkyrie/Load/save.ini"); IniData saveData = IniRead.ReadFromString(data); saveData.data["Quest"]["path"] = Path.GetTempPath() + "/Valkyrie/Load/quest/quest.ini"; saveData.Get("Quest", "valkyrie"); if (VersionNewer(game.version, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Error: save is from a future version." + System.Environment.NewLine); Destroyer.MainMenu(); return; } if (!VersionNewerOrEqual(minValkyieVersion, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Error: save is from an old unsupported version." + System.Environment.NewLine); Destroyer.MainMenu(); return; } Destroyer.Dialog(); // Restart contend data so we can select from save game.cd = new ContentData(game.gameType.DataDirectory()); // Check if we found anything if (game.cd.GetPacks().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(); } game.cd.LoadContentID(""); // Load the base content // Load content that the save game uses Dictionary <string, string> packs = saveData.Get("Packs"); foreach (KeyValuePair <string, string> kv in packs) { game.cd.LoadContentID(""); // Support for save games from 1.2 and older if (kv.Key.Equals("FA")) { game.cd.LoadContentID("FAI"); game.cd.LoadContentID("FAM"); game.cd.LoadContentID("FAT"); } if (kv.Key.Equals("CotW")) { game.cd.LoadContentID("CotWI"); game.cd.LoadContentID("CotWM"); game.cd.LoadContentID("CotWT"); } if (kv.Key.Equals("MoM1E")) { game.cd.LoadContentID("MoM1EI"); game.cd.LoadContentID("MoM1EM"); game.cd.LoadContentID("MoM1ET"); } else { game.cd.LoadContentID(kv.Key); } } // This loads the game new Quest(saveData); // Draw things on the screen game.heroCanvas.SetupUI(); game.heroCanvas.UpdateImages(); game.heroCanvas.UpdateStatus(); if (game.gameType.DisplayMorale()) { game.moraleDisplay = new MoraleDisplay(); } if (!game.gameType.DisplayHeroes()) { game.heroCanvas.Clean(); } // Create the menu button new MenuButton(); new LogButton(); new SkillButton(); new InventoryButton(); game.stageUI = new NextStageButton(); } } catch (System.Exception e) { ValkyrieDebug.Log("Error: Unable to open save file: " + SaveFile(num) + " " + e.Message); Application.Quit(); } }
public SaveData(int num = 0) { Game game = Game.Get(); if (!File.Exists(SaveFile(num))) { return; } try { if (!Directory.Exists(ContentData.TempValyriePath)) { Directory.CreateDirectory(ContentData.TempValyriePath); } string valkyrieLoadPath = Path.Combine(ContentData.TempValyriePath, "Preload"); if (!Directory.Exists(valkyrieLoadPath)) { Directory.CreateDirectory(valkyrieLoadPath); } ZipManager.Extract(valkyrieLoadPath, SaveFile(num), ZipManager.Extract_mode.ZIPMANAGER_EXTRACT_SAVE_INI_PIC); image = ContentData.FileToTexture(Path.Combine(valkyrieLoadPath, "image.png")); string data = File.ReadAllText(Path.Combine(valkyrieLoadPath, "save.ini")); IniData saveData = IniRead.ReadFromString(data); // when loading a quest, path should always be $TMP/load/quest/$subquest/quest.ini // Make sure it is when loading a quest saved for the first time, as in that case it is the original load path string questLoadPath = Path.GetDirectoryName(saveData.Get("Quest", "path")); string questOriginalPath = saveData.Get("Quest", "originalpath"); // loading a quest saved for the first time if (questLoadPath.Contains(questOriginalPath)) { questLoadPath = questLoadPath.Replace(questOriginalPath, ContentData.ValkyrieLoadQuestPath); } // use preload path rather than load questLoadPath = questLoadPath.Replace(ContentData.ValkyrieLoadPath, ContentData.ValkyriePreloadPath); QuestData.Quest q = new QuestData.Quest(questLoadPath); if (!q.valid) { ValkyrieDebug.Log("Warning: Save " + num + " contains unsupported quest version." + Environment.NewLine); return; } quest_name = saveData.Get("Quest", "questname"); if (VersionManager.VersionNewer(game.version, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Warning: Save " + num + " is from a future version." + Environment.NewLine); return; } if (!VersionManager.VersionNewerOrEqual(minValkyieVersion, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Warning: Save " + num + " is from an old unsupported version." + Environment.NewLine); return; } saveTime = DateTime.Parse(saveData.Get("Quest", "time")); valid = true; } catch (Exception e) { ValkyrieDebug.Log("Warning: Unable to open save file: " + SaveFile(num) + "\nException: " + e.ToString()); } }
// Load a saved game, does nothing if file does not exist public static void Load(int num = 0) { Game game = Game.Get(); try { if (File.Exists(SaveFile(num))) { if (!Directory.Exists(ContentData.TempValyriePath)) { Directory.CreateDirectory(ContentData.TempValyriePath); } string valkyrieLoadPath = Path.Combine(ContentData.TempValyriePath, "Load"); if (!Directory.Exists(valkyrieLoadPath)) { Directory.CreateDirectory(valkyrieLoadPath); } Directory.Delete(valkyrieLoadPath, true); ZipManager.Extract(valkyrieLoadPath, SaveFile(num), ZipManager.Extract_mode.ZIPMANAGER_EXTRACT_FULL); string savefile_content = File.ReadAllText(Path.Combine(valkyrieLoadPath, "save.ini")); IniData saveData = IniRead.ReadFromString(savefile_content); // when loading a quest, path should always be $TMP/load/quest/$subquest/quest.ini // Make sure it is when loading a quest saved for the first time, as in that case it is the original load path string questLoadPath = Path.GetDirectoryName(saveData.Get("Quest", "path")); string questOriginalPath = saveData.Get("Quest", "originalpath"); // loading a quest saved for the first time if (questLoadPath.Contains(questOriginalPath)) { questLoadPath = questLoadPath.Replace(questOriginalPath, ContentData.ValkyrieLoadQuestPath); } // Check that quest in save is valid QuestData.Quest q = new QuestData.Quest(questLoadPath); if (!q.valid) { ValkyrieDebug.Log("Error: save contains unsupported quest version." + Environment.NewLine); GameStateManager.MainMenu(); return; } saveData.data["Quest"]["path"] = Path.Combine(questLoadPath, "quest.ini"); if (VersionManager.VersionNewer(game.version, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Error: save is from a future version." + Environment.NewLine); GameStateManager.MainMenu(); return; } if (!VersionManager.VersionNewerOrEqual(minValkyieVersion, saveData.Get("Quest", "valkyrie"))) { ValkyrieDebug.Log("Error: save is from an old unsupported version." + Environment.NewLine); GameStateManager.MainMenu(); return; } Destroyer.Dialog(); // Load content that the save game uses Dictionary <string, string> packs = saveData.Get("Packs"); foreach (KeyValuePair <string, string> kv in packs) { // Support for save games from 1.2 and older if (kv.Key.Equals("FA")) { game.ContentLoader.LoadContentID("FAI"); game.ContentLoader.LoadContentID("FAM"); game.ContentLoader.LoadContentID("FAT"); } if (kv.Key.Equals("CotW")) { game.ContentLoader.LoadContentID("CotWI"); game.ContentLoader.LoadContentID("CotWM"); game.ContentLoader.LoadContentID("CotWT"); } if (kv.Key.Equals("MoM1E")) { game.ContentLoader.LoadContentID("MoM1EI"); game.ContentLoader.LoadContentID("MoM1EM"); game.ContentLoader.LoadContentID("MoM1ET"); } else { game.ContentLoader.LoadContentID(kv.Key); } } // This loads the game new Quest(saveData); // Draw things on the screen game.heroCanvas.SetupUI(); game.heroCanvas.UpdateImages(); game.heroCanvas.UpdateStatus(); if (game.gameType.DisplayMorale()) { game.moraleDisplay = new MoraleDisplay(); } if (!game.gameType.DisplayHeroes()) { game.heroCanvas.Clean(); } // Create the menu button new MenuButton(); new LogButton(); new SkillButton(); new InventoryButton(); game.stageUI = new NextStageButton(); } } catch (IOException e) { ValkyrieDebug.Log("Error: Unable to open save file: " + SaveFile(num) + " " + e.Message); Application.Quit(); } }
// Starts the provided quest public static void Start(QuestData.Quest quest) { ValkyrieDebug.Log("INFO: Moving to hero selection screen"); Destroyer.Destroy(); Game.Get().StartQuest(quest); }
// Select a quest public void Start(QuestData.Quest q) { ValkyrieDebug.Log("INFO: Start quest from details screen"); GameStateManager.Quest.Start(q); }
public QuestDetailsScreen(QuestData.Quest q) { Game game = Game.Get(); LocalizationRead.AddDictionary("qst", q.localizationDict); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading UIElement ui = new UIElement(); ui.SetLocation(2, 0.5f, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(q.name); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); // Draw Image if (q.image.Length > 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-20), 4, 8, 8); ui.SetImage(ContentData.FileToTexture(Path.Combine(q.path, q.image))); new UIElementBorder(ui); } // Draw Description ui = new UIElement(); float height = ui.GetStringHeight(q.description, 30); if (height > 25) { height = 25; } ui.SetLocation(UIScaler.GetHCenter(-7), 15 - (height / 2), 30, height); ui.SetText(q.description); new UIElementBorder(ui); // Draw authors ui = new UIElement(); height = ui.GetStringHeight(q.authors, 14); if (height > 25) { height = 25; } ui.SetLocation(UIScaler.GetHCenter(-23), 18.5f - (height / 2), 14, height); ui.SetText(q.authors); new UIElementBorder(ui); // Difficulty if (q.difficulty != 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-13), 27, 11, 1); ui.SetText(new StringKey("val", "DIFFICULTY")); string symbol = "*"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-13), 28, 11, 2); ui.SetText(symbol + symbol + symbol + symbol + symbol); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28, (1 - q.difficulty) * 6.9f, 2); ui.SetBGColor(new Color(0, 0, 0, 0.7f)); } // Duration if (q.lengthMax != 0) { ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(2), 27, 11, 1); ui.SetText(new StringKey("val", "DURATION")); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(2), 28, 4, 2); ui.SetText(q.lengthMin.ToString()); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(6.5f), 28, 2, 2); ui.SetText("-"); ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(9), 28, 4, 2); ui.SetText(q.lengthMax.ToString()); ui.SetFontSize(UIScaler.GetMediumFont()); } // DELETE button (only for archive, directory might be edited by user) if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie") { ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-8.5f), 0.5f, 8, 2); ui.SetText(CommonStringKeys.DELETE, Color.grey); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Delete(q); }); new UIElementBorder(ui, Color.grey); } ui = new UIElement(); ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Cancel); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2); ui.SetText(new StringKey("val", "START"), Color.green); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { Start(q); }); new UIElementBorder(ui, Color.green); }
public QuestDetailsScreen(QuestData.Quest q) { Game game = Game.Get(); LocalizationRead.scenarioDict = q.localizationDict; // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Heading DialogBox db = new DialogBox( new Vector2(2, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 4, 3), q.name); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); // Draw Image if (q.image.Length > 0) { Texture2D tex = ContentData.FileToTexture(Path.Combine(q.path, q.image)); Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1); db = new DialogBox(new Vector2(UIScaler.GetHCenter(-20), 4), new Vector2(8, 8), StringKey.NULL, Color.white, Color.white); db.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite; db.AddBorder(); } // Draw Description db = new DialogBox(Vector2.zero, new Vector2(30, 30), q.description); float height = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1; db.Destroy(); if (height > 25) { height = 25; } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-7), 15 - (height / 2)), new Vector2(30, height), q.description); db.AddBorder(); // Draw authors db = new DialogBox(Vector2.zero, new Vector2(14, 30), q.authors); height = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1; db.Destroy(); if (height > 25) { height = 25; } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-23), 18.5f - (height / 2)), new Vector2(14, height), q.authors); db.AddBorder(); // Difficulty if (q.difficulty != 0) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13), 27), new Vector2(11, 1), new StringKey("val", "DIFFICULTY")); string symbol = "*"; if (game.gameType is MoMGameType) { symbol = new StringKey("val", "ICON_SUCCESS_RESULT").Translate(); } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13), 28), new Vector2(11, 2), new StringKey(null, symbol + symbol + symbol + symbol + symbol, false)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10.95f) + (q.difficulty * 6.9f), 28), new Vector2((1 - q.difficulty) * 6.9f, 2), StringKey.NULL, Color.clear, new Color(0, 0, 0, 0.7f)); } // Duration if (q.lengthMax != 0) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(2), 27), new Vector2(11, 1), new StringKey("val", "DURATION")); db = new DialogBox(new Vector2(UIScaler.GetHCenter(2), 28f), new Vector2(4, 2), q.lengthMin); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(6.5f), 28f), new Vector2(2, 2), new StringKey(null, "-", false)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(9), 28f), new Vector2(4, 2), q.lengthMax); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); } TextButton tb = new TextButton( new Vector2(0.5f, UIScaler.GetBottom(-2.5f)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); tb = new TextButton( new Vector2(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f)), new Vector2(8, 2), new StringKey("val", "START"), delegate { Start(q); }, Color.green); tb.SetFont(game.gameType.GetHeaderFont()); }
// Select a quest public void Start(QuestData.Quest q) { Destroyer.Dialog(); Game.Get().StartQuest(q); }