public void Copy() { questList = QuestLoader.GetQuests(); foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select Quest To Copy"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); int offset = 5; foreach (KeyValuePair <string, QuestLoader.Quest> q in questList) { string key = q.Key; TextButton tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), " " + q.Value.name, delegate { Copy(key); }, Color.white, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 0.1f); offset += 2; } new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { CancelCopy(); }, Color.red); }
// This is called by 'start quest' on the main menu public void SelectQuest() { // Find any content packs at the location cd = new ContentData(gameType.DataDirectory()); // Check if we found anything if (cd.GetPacks().Count == 0) { ValkyrieDebug.Log("Error: Failed to find any content packs, please check that you have them present in: " + gameType.DataDirectory() + System.Environment.NewLine); Application.Quit(); } // Load configured packs cd.LoadContentID(""); Dictionary <string, string> packs = config.data.Get(gameType.TypeName() + "Packs"); if (packs != null) { foreach (KeyValuePair <string, string> kv in packs) { cd.LoadContentID(kv.Key); } } // Get a list of available quests Dictionary <string, QuestData.Quest> ql = QuestLoader.GetQuests(); // Pull up the quest selection page new QuestSelectionScreen(ql); }
// List of quests to copy public void Copy() { // Can copy all quests, not just user questList = QuestLoader.GetQuests(); Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Header DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName() + " To Copy"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); // List of quests // FIXME: requires paging TextButton tb; int offset = 5; foreach (KeyValuePair <string, QuestLoader.Quest> q in questList) { string key = q.Key; tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), " " + q.Value.name, delegate { Copy(key); }, Color.white, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0, 0.1f); offset += 2; } // Back to edit selection tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { CancelCopy(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
public void SelectQuest() { // In the build the content packs need to go into the build data dir, this is currently manual string contentLocation = Application.dataPath + "/valkyrie-contentpacks/"; if (Application.isEditor) { // If running through unity then we assume you are using the git content, with the project at the same level contentLocation = Application.dataPath + "/../../valkyrie-contentpacks/"; } // Find any content packs at the location cd = new ContentData(contentLocation); // Check if we found anything if (cd.GetPacks().Count == 0) { Debug.Log("Error: Failed to find any content packs, please check that you have them present in: " + contentLocation); } // In the future this is where you select which packs to load, for now we load everything. foreach (string pack in cd.GetPacks()) { cd.LoadContent(pack); } // Get a list of available quests Dictionary <string, QuestLoader.Quest> ql = QuestLoader.GetQuests(); // Pull up the quest selection page new QuestSelection(ql); }
// Return to quest selection public void Cancel() { Destroyer.Dialog(); // Get a list of available quests Dictionary <string, QuestData.Quest> ql = QuestLoader.GetQuests(); // Pull up the quest selection page new QuestSelectionScreen(ql); }
// --- Management of local quests, when offline --- public void LoadAllLocalQuests() { if (local_quests_data == null) { // Clean up temporary files UnloadLocalQuests(); // extract and load local quest local_quests_data = QuestLoader.GetQuests(); } }
// List of quests to copy public void Copy() { // Can copy all quests, not just user questList = QuestLoader.GetQuests(); Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Header DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName() + " To Copy"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), ""); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; // List of quests int offset = 5; TextButton tb; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), " " + q.Value.name, delegate { Copy(key); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; offset += 2; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); // Back to edit selection tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { CancelCopy(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
// List of quests to copy public void Copy() { // Can copy all quests, not just user questList = QuestLoader.GetQuests(true); Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Header UIElement ui = new UIElement(); ui.SetLocation(2, 1, UIScaler.GetWidthUnits() - 4, 3); ui.SetText(new StringKey("val", "SELECT_TO_COPY", game.gameType.QuestName())); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21); new UIElementBorder(scrollArea); // List of quests int offset = 0; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.AddDictionary("qst", q.Value.localizationDict); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(1, offset, UIScaler.GetWidthUnits() - 5, 1.2f); ui.SetText(new StringKey("val", "INDENT", q.Value.name), Color.black); ui.SetTextAlignment(TextAnchor.MiddleLeft); ui.SetButton(delegate { Copy(key); }); ui.SetBGColor(Color.white); offset += 2; } scrollArea.SetScrollSize(offset); // Back to edit selection ui = new UIElement(); ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2); ui.SetText(CommonStringKeys.BACK, Color.red); ui.SetFont(Game.Get().gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(CancelCopy); new UIElementBorder(ui, Color.red); }
public void StartMap() { inMap = true; endMap = false; time = Time.time + gameStats[(int)GameStats.Time]; if (playerStats[(int)PlayerStats.MAX_HP] > playerStats[(int)PlayerStats.HP]) { playerStats[(int)PlayerStats.HP]++; } gameStats[(int)GameStats.Day]++; // Make Quests int map = currentMap.GetID(); curQuests = questLoader.GetQuests(map, questCompletion[map]); }
// List of quests to copy public void Copy() { // Can copy all quests, not just user questList = QuestLoader.GetQuests(true); Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } // Header DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("val", "SELECT_TO_COPY", game.gameType.QuestName()) ); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(1, 5, UIScaler.GetWidthUnits() - 2f, 21); new UIElementBorder(scrollArea); // List of quests int offset = 5; TextButton tb; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), new StringKey("val", "INDENT", q.Value.name), delegate { Copy(key); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.SetParent(scrollArea.GetScrollTransform()); offset += 2; } scrollArea.SetScrollSize(offset - 5); // Back to edit selection tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { CancelCopy(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }
// This is called by 'start quest' on the main menu public void SelectQuest() { // Find any content packs at the location cd = new ContentData(gameType.DataDirectory()); // Check if we found anything if (cd.GetPacks().Count == 0) { Debug.Log("Error: Failed to find any content packs, please check that you have them present in: " + gameType.DataDirectory() + System.Environment.NewLine); Application.Quit(); } foreach (string pack in cd.GetEnabledPacks()) { cd.LoadContent(pack); } // Get a list of available quests Dictionary <string, QuestLoader.Quest> ql = QuestLoader.GetQuests(); // Pull up the quest selection page new QuestSelection(ql); }
// List of quests to copy public void Copy() { // Can copy all quests, not just user questList = QuestLoader.GetQuests(); Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // Header DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), new StringKey("val", "SELECT_TO_COPY", game.gameType.QuestName()) ); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(Game.Get().gameType.GetHeaderFont()); db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), StringKey.NULL); db.AddBorder(); db.background.AddComponent <UnityEngine.UI.Mask>(); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); GameObject scrollArea = new GameObject("scroll"); RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>(); scrollArea.transform.parent = db.background.transform; scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit()); scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1); GameObject scrollBarObj = new GameObject("scrollbar"); scrollBarObj.transform.parent = db.background.transform; RectTransform scrollBarRect = scrollBarObj.AddComponent <RectTransform>(); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 21 * UIScaler.GetPixelsPerUnit()); scrollBarRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit(), 1 * UIScaler.GetPixelsPerUnit()); UnityEngine.UI.Scrollbar scrollBar = scrollBarObj.AddComponent <UnityEngine.UI.Scrollbar>(); scrollBar.direction = UnityEngine.UI.Scrollbar.Direction.BottomToTop; scrollRect.verticalScrollbar = scrollBar; GameObject scrollBarHandle = new GameObject("scrollbarhandle"); scrollBarHandle.transform.parent = scrollBarObj.transform; //RectTransform scrollBarHandleRect = scrollBarHandle.AddComponent<RectTransform>(); scrollBarHandle.AddComponent <UnityEngine.UI.Image>(); scrollBarHandle.GetComponent <UnityEngine.UI.Image>().color = new Color(0.7f, 0.7f, 0.7f); scrollBar.handleRect = scrollBarHandle.GetComponent <RectTransform>(); scrollBar.handleRect.offsetMin = Vector2.zero; scrollBar.handleRect.offsetMax = Vector2.zero; scrollRect.content = scrollInnerRect; scrollRect.horizontal = false; // List of quests int offset = 5; TextButton tb; foreach (KeyValuePair <string, QuestData.Quest> q in questList) { string key = q.Key; LocalizationRead.scenarioDict = q.Value.localizationDict; tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), new StringKey("val", "INDENT", q.Value.name), delegate { Copy(key); }, Color.black, offset); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; tb.background.transform.parent = scrollArea.transform; offset += 2; } scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit()); // Back to edit selection tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), CommonStringKeys.BACK, delegate { CancelCopy(); }, Color.red); tb.SetFont(Game.Get().gameType.GetHeaderFont()); }