void Update() { if (!thisImage) { thisImage = gameObject.GetComponent<Image>(); } if (!scaler) { scaler = gameObject.GetComponentInParent<Canvas>().GetComponent<UIScaler>(); } else { if (scaleFactor != scaler.scaleFactor) { scaleFactor = scaler.scaleFactor; if (scaleFactor > 2f && sprite4x) thisImage.sprite = sprite4x; else if (scaleFactor > 1f && sprite2x) thisImage.sprite = sprite2x; else thisImage.sprite = sprite1x; } } }
public void CreateWindow() { // Draw text text = eventData.GetText(); DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28, 8), new StringKey(null, text, false)); float offset = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1; db.Destroy(); if (offset < 4) { offset = 4; } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28, offset), new StringKey(null, text, false)); db.AddBorder(); offset += 1f; // Determine button size float buttonWidth = 8; float hOffset = UIScaler.GetWidthUnits() - 19f; float hOffsetCancel = 11; float offsetCancel = offset; List <DialogWindow.EventButton> buttons = eventData.GetButtons(); foreach (EventButton eb in buttons) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28, offset), eb.GetLabel()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); float length = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredWidth / UIScaler.GetPixelsPerUnit()) + 1; if (length > buttonWidth) { buttonWidth = length; hOffset = UIScaler.GetHCenter(-length / 2); hOffsetCancel = UIScaler.GetHCenter(-4); offsetCancel = offset + (2.5f * buttons.Count); } db.Destroy(); } int num = 1; foreach (EventButton eb in buttons) { int numTmp = num++; new TextButton(new Vector2(hOffset, offset), new Vector2(buttonWidth, 2), eb.GetLabel(), delegate { onButton(numTmp); }, eb.colour); offset += 2.5f; } // Do we have a cancel button? if (eventData.qEvent.cancelable) { new TextButton(new Vector2(hOffsetCancel, offsetCancel), new Vector2(8f, 2), CommonStringKeys.CANCEL, delegate { onCancel(); }); } }
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 MenuButton() { TextButton qb = new TextButton(new Vector2(UIScaler.GetRight(-9), UIScaler.GetBottom(-3)), new Vector2(8, 2), "Menu", delegate { Menu(); }, Color.red); // Untag as dialog so this isn't cleared away qb.ApplyTag("questui"); }
public void DrawList() { localManifest = IniRead.ReadFromString(""); if (File.Exists(saveLocation() + "/manifest.ini")) { localManifest = IniRead.ReadFromIni(saveLocation() + "/manifest.ini"); } // Heading DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Download " + game.gameType.QuestName()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); db.SetFont(game.gameType.GetHeaderFont()); TextButton tb; // Start here int offset = 5; // Loop through all available quests // FIXME: this isn't paged Dictionary<string, Dictionary<string, string>> data; foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data) { string file = kv.Key + ".valkyrie"; // Size is 1.2 to be clear of characters with tails if (File.Exists(saveLocation() + "/" + file)) { int localVersion = 0; int remoteVersion = 0; int.TryParse(localManifest.Get(kv.Key, "version"), out localVersion); int.TryParse(remoteManifest.Get(kv.Key, "version"), out remoteVersion); if (localVersion < remoteVersion) { tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), " [Update] " + kv.Value["name"], delegate { Selection(file); }, Color.blue, 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); } else { db = new DialogBox(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), " " + kv.Value["name"], Color.grey); db.AddBorder(); db.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.05f, 0.05f, 0.05f); db.textObj.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; } } else { tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 4, 1.2f), " " + kv.Value["name"], delegate { Selection(file); }, 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; } tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Cancel(); }, Color.red); tb.SetFont(game.gameType.GetHeaderFont()); }
public override void CreateWindow() { Destroyer.Dialog(); Game game = Game.Get(); DrawMonster(monster); // In horror phase we do horror checks if (game.quest.phase == Quest.MoMPhase.horror) { UIElement ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-8f), 2, 16, 2); ui.SetText(HORROR_CHECK); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Horror); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-5f), 4.5f, 10, 2); ui.SetText(CommonStringKeys.CANCEL); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(OnCancel); new UIElementBorder(ui); } else { // In investigator phase we do attacks and evades DrawMonsterHealth(monster, delegate { CreateWindow(); }); UIElement ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-8f), 2, 16, 2); ui.SetText(new StringKey("val", "ACTION_X", ATTACK)); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Attack); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-8f), 4.5f, 16, 2); ui.SetText(EVADE); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Evade); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-5f), 7, 10, 2); if (monster.damage == monster.GetHealth()) { ui.SetText(CommonStringKeys.CANCEL, Color.gray); new UIElementBorder(ui, Color.gray); } else { ui.SetText(CommonStringKeys.CANCEL); ui.SetButton(OnCancel); new UIElementBorder(ui); } ui.SetFontSize(UIScaler.GetMediumFont()); } }
override public void Update() { base.Update(); CameraController.SetCamera(mPlaceComponent.location); Game game = Game.Get(); TextButton tb = new TextButton(new Vector2(0, 0), new Vector2(4, 1), CommonStringKeys.MPLACE, delegate { QuestEditorData.TypeSelect(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleRight; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(4, 0), new Vector2(15, 1), new StringKey(null, name.Substring("MPlace".Length), false), delegate { QuestEditorData.ListMPlace(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(19, 0), new Vector2(1, 1), CommonStringKeys.E, delegate { Rename(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); DialogBox db = new DialogBox(new Vector2(0, 2), new Vector2(4, 1), CommonStringKeys.POSITION); db.ApplyTag("editor"); tb = new TextButton(new Vector2(4, 2), new Vector2(1, 1), CommonStringKeys.POSITION_SNAP, delegate { GetPosition(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); StringKey rotateKey = new StringKey("val", "RIGHT"); if (mPlaceComponent.rotate) { rotateKey = new StringKey("val", "DOWN"); } tb = new TextButton(new Vector2(0, 4), new Vector2(8, 1), new StringKey("val", "ROTATE_TO", rotateKey), delegate { Rotate(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); StringKey mast = new StringKey("val", "MONSTER_MINION"); if (mPlaceComponent.master) { mast = new StringKey("val", "MONSTER_MASTER"); } tb = new TextButton(new Vector2(0, 6), new Vector2(8, 1), mast, delegate { MasterToggle(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); game.tokenBoard.AddHighlight(mPlaceComponent.location, "MonsterLoc", "editor"); }
public void CreateWindow() { // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // ability box - name header DialogBox db = new DialogBox(new Vector2(15, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 30, 2), monster.monsterData.name); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); // ability text string abiltiyText = monster.currentActivation.ability.Replace("\\n", "\n"); db = new DialogBox(new Vector2(10, 2.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 4), abiltiyText); db.AddBorder(); // Activation box string activationText = ""; // Create header if (master) { db = new DialogBox(new Vector2(15, 7f), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Master", Color.red); activationText = monster.currentActivation.masterActions.Replace("\\n", "\n"); } else { db = new DialogBox(new Vector2(15, 7f), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Minion"); activationText = monster.currentActivation.minionActions.Replace("\\n", "\n"); } db.AddBorder(); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); // Create ability text box db = new DialogBox(new Vector2(10, 9), new Vector2(UIScaler.GetWidthUnits() - 20, 7), activationText); if (master) { db.AddBorder(Color.red); } else { db.AddBorder(); } // Create finished button if (master) { new TextButton(new Vector2(15, 16.5f), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Masters Activated", delegate { activated(); }, Color.red); } else { new TextButton(new Vector2(15, 16.5f), new Vector2(UIScaler.GetWidthUnits() - 30, 2), "Minions Activated", delegate { activated(); }); } }
override public void Update() { base.Update(); CameraController.SetCamera(monsterComponent.location); Game game = Game.Get(); TextButton tb = new TextButton(new Vector2(0, 0), new Vector2(3, 1), CommonStringKeys.SPAWN, delegate { QuestEditorData.TypeSelect(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleRight; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(3, 0), new Vector2(16, 1), new StringKey(null, name.Substring("Spawn".Length), false), delegate { QuestEditorData.ListSpawn(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(19, 0), new Vector2(1, 1), CommonStringKeys.E, delegate { Rename(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); int offset = 1; DialogBox db = null; for (int heroes = 2; heroes < 5; heroes++) { int h = heroes; db = new DialogBox(new Vector2(0, offset), new Vector2(5, 1), new StringKey("val", "NUMBER_HEROS", heroes)); db.ApplyTag("editor"); tb = new TextButton(new Vector2(19, offset++), new Vector2(1, 1), CommonStringKeys.PLUS, delegate { MonsterPlaceAdd(h); }, Color.green); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); for (int i = 0; i < 8; i++) { if (monsterComponent.placement[heroes].Length > i) { int mSlot = i; string place = monsterComponent.placement[heroes][i]; tb = new TextButton(new Vector2(0, offset), new Vector2(1, 1), CommonStringKeys.MINUS, delegate { MonsterPlaceRemove(h, mSlot); }, Color.red); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); tb = new TextButton(new Vector2(1, offset), new Vector2(19, 1), new StringKey(null, place, false), delegate { QuestEditorData.SelectComponent(place); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); } offset++; } } game.tokenBoard.AddHighlight(monsterComponent.location, "MonsterLoc", "editor"); }
// Create window, call event on cancel public void EditText(UnityEngine.Events.UnityAction call) { Destroyer.Dialog(); cancelCall = call; // Border DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10), 1), new Vector2(20, 6), StringKey.NULL); db.AddBorder(); // Heading db = new DialogBox(new Vector2(UIScaler.GetHCenter(-9.5f), 1), new Vector2(19, 1), title); Game game = Game.Get(); GameObject textObj = new GameObject("textEdit"); GameObject inputObj = new GameObject("textInput"); textObj.tag = Game.DIALOG; inputObj.tag = Game.DIALOG; inputObj.transform.SetParent(game.uICanvas.transform); textObj.transform.SetParent(inputObj.transform); RectTransform transBg = inputObj.AddComponent <RectTransform>(); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 3 * UIScaler.GetPixelsPerUnit(), UIScaler.GetPixelsPerUnit()); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, UIScaler.GetHCenter(-9) * UIScaler.GetPixelsPerUnit(), 18 * UIScaler.GetPixelsPerUnit()); RectTransform transTx = textObj.AddComponent <RectTransform>(); transTx.SetParent(transBg); transTx.localScale = transBg.localScale; transTx.sizeDelta = transBg.sizeDelta; inputObj.AddComponent <CanvasRenderer>(); textObj.AddComponent <CanvasRenderer>(); UnityEngine.UI.Text uiText = textObj.AddComponent <UnityEngine.UI.Text>(); uiText.color = Color.white; uiText.font = game.gameType.GetFont(); uiText.material = uiText.font.material; uiText.fontSize = UIScaler.GetSmallFont(); iField = inputObj.AddComponent <PanCancelInputField>(); iField.textComponent = uiText; iField.text = value; TextButton tb = new TextButton(new Vector2(UIScaler.GetHCenter(-8), 5), new Vector2(6, 1), CommonStringKeys.OK, OKButton); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.0f, 0.03f, 0f); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb = new TextButton(new Vector2(UIScaler.GetHCenter(2), 5), new Vector2(6, 1), CommonStringKeys.CANCEL, cancelCall); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); }
// Create window, call event on cancel public void EditText(UnityEngine.Events.UnityAction call) { Destroyer.Dialog(); cancelCall = call; // Border DialogBox db = new DialogBox(new Vector2(21, 0), new Vector2(20, 6), ""); db.AddBorder(); // Heading db = new DialogBox(new Vector2(21, 0), new Vector2(20, 1), title); Game game = Game.Get(); GameObject textObj = new GameObject("textEdit"); GameObject inputObj = new GameObject("textInput"); textObj.tag = "dialog"; inputObj.tag = "dialog"; inputObj.transform.parent = game.uICanvas.transform; textObj.transform.parent = inputObj.transform; RectTransform transBg = inputObj.AddComponent <RectTransform>(); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 2 * UIScaler.GetPixelsPerUnit(), UIScaler.GetPixelsPerUnit()); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 22 * UIScaler.GetPixelsPerUnit(), 18 * UIScaler.GetPixelsPerUnit()); RectTransform transTx = textObj.AddComponent <RectTransform>(); transTx.SetParent(transBg); transTx.localScale = transBg.localScale; transTx.sizeDelta = transBg.sizeDelta; inputObj.AddComponent <CanvasRenderer>(); textObj.AddComponent <CanvasRenderer>(); UnityEngine.UI.Text uiText = textObj.AddComponent <UnityEngine.UI.Text>(); iField = inputObj.AddComponent <UnityEngine.UI.InputField>(); uiText.color = Color.white; uiText.font = game.gameType.GetFont(); uiText.material = uiText.font.material; uiText.fontSize = UIScaler.GetSmallFont(); iField.textComponent = uiText; iField.text = value; TextButton tb = new TextButton(new Vector2(23f, 4), new Vector2(6, 1), "OK", OKButton); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.0f, 0.03f, 0f); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb = new TextButton(new Vector2(31f, 4), new Vector2(6, 1), "Cancel", cancelCall); tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); }
public void CreateWindow() { Destroyer.Dialog(); Game.Get().cc.panDisable = true; DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28f, 22f), StringKey.NULL); db.AddBorder(); // Puzzle goes here db = new DialogBox(new Vector2(UIScaler.GetHCenter(10f), 8f), new Vector2(3f, 2f), new StringKey("val", "X_COLON", CommonStringKeys.SKILL)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(10f), 10f), new Vector2(3f, 2f), new StringKey(null, EventManager.SymbolReplace(questPuzzle.skill), false)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); bool solved = puzzle.Solved(); foreach (KeyValuePair <PuzzleImage.TilePosition, PuzzleImage.TilePosition> kv in puzzle.state) { Draw(kv.Key, kv.Value, solved); } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13f), 20f), new Vector2(6f, 2f), new StringKey("val", "X_COLON", CommonStringKeys.MOVES)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(-6f), 20f), new Vector2(3f, 2f), puzzle.moves - previousMoves); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(-3f), 20f), new Vector2(10f, 2f), new StringKey("val", "X_COLON", CommonStringKeys.TOTAL_MOVES)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(7f), 20f), new Vector2(3f, 2f), puzzle.moves); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); if (solved) { new TextButton(new Vector2(UIScaler.GetHCenter(-13f), 23.5f), new Vector2(8f, 2), CommonStringKeys.CLOSE, delegate {; }, Color.grey); new TextButton( new Vector2(UIScaler.GetHCenter(5f), 23.5f), new Vector2(8f, 2), eventData.GetButtons()[0].GetLabel(), delegate { Finished(); }); } else { new TextButton(new Vector2(UIScaler.GetHCenter(-13f), 23.5f), new Vector2(8f, 2), CommonStringKeys.CLOSE, delegate { Close(); }); new TextButton( new Vector2(UIScaler.GetHCenter(5f), 23.5f), new Vector2(8f, 2), eventData.GetButtons()[0].GetLabel(), delegate {; }, Color.grey); } }
// 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()); }
public void CreateWindow() { Destroyer.Dialog(); DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28f, 22f), ""); db.AddBorder(); // Puzzle goes here GameObject background = new GameObject("puzzleContent"); background.tag = "dialog"; RectTransform transBg = background.AddComponent <RectTransform>(); background.transform.SetParent(Game.Get().uICanvas.transform); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, UIScaler.GetPixelsPerUnit() * 2.5f, 18f * UIScaler.GetPixelsPerUnit()); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, UIScaler.GetHCenter(-12f) * UIScaler.GetPixelsPerUnit(), 24f * UIScaler.GetPixelsPerUnit()); DrawSlideFrame(background.transform); foreach (PuzzleSlide.Block b in puzzle.puzzle) { CreateBlock(b, transBg, b.target); } db = new DialogBox(new Vector2(UIScaler.GetHCenter(7f), 3f), new Vector2(6f, 2f), "Skill:"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(8.5f), 5f), new Vector2(3f, 2f), EventManager.SymbolReplace(questPuzzle.skill)); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(7f), 12.5f), new Vector2(6f, 2f), "Moves:"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(8.5f), 14.5f), new Vector2(3f, 2f), (puzzle.moves - lastMoves).ToString()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(7f), 17f), new Vector2(6f, 2f), "Total Moves:"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db = new DialogBox(new Vector2(UIScaler.GetHCenter(8.5f), 19f), new Vector2(3f, 2f), puzzle.moves.ToString()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); if (puzzle.Solved()) { new TextButton(new Vector2(UIScaler.GetHCenter(-13f), 23.5f), new Vector2(8f, 2), "Close", delegate {; }, Color.grey); new TextButton(new Vector2(UIScaler.GetHCenter(5f), 23.5f), new Vector2(8f, 2), eventData.GetButtons()[0].label, delegate { Finished(); }); } else { new TextButton(new Vector2(UIScaler.GetHCenter(-13f), 23.5f), new Vector2(8f, 2), "Close", delegate { Close(); }); new TextButton(new Vector2(UIScaler.GetHCenter(5f), 23.5f), new Vector2(8f, 2), eventData.GetButtons()[0].label, delegate {; }, Color.grey); } }
// 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); }); }
// Update redraws the selection UI virtual public void Update() { Clean(); // Back button is common to all components TextButton tb = new TextButton(new Vector2(0, 29), new Vector2(3, 1), "Back", delegate { QuestEditorData.Back(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); }
public override void SetScrollSize(float size) { float width = size * UIScaler.GetPixelsPerUnit(); if (width < scrollBar.GetComponent <RectTransform>().rect.width) { width = scrollBar.GetComponent <RectTransform>().rect.width; } scrollArea.GetComponent <RectTransform>().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, width); }
public virtual void SetScrollSize(float size) { float height = size * UIScaler.GetPixelsPerUnit(); if (height < scrollBar.GetComponent <RectTransform>().rect.height) { height = scrollBar.GetComponent <RectTransform>().rect.height; } scrollArea.GetComponent <RectTransform>().SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, height); }
public MoraleDisplay() { Game game = Game.Get(); md = new DialogBox(new Vector2(0.75f, 0.5f), new Vector2(3, 3), game.quest.morale.ToString(), Color.red); md.textObj.tag = "questui"; md.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont(); md.background.tag = "questui"; md.AddBorder(); }
public void Activation() { DialogBox db = new DialogBox(new Vector2(0, 1), new Vector2(20, 1), new StringKey("val", "X_COLON", ABILITY)); db.ApplyTag("editor"); abilityDBE = new DialogBoxEditable( new Vector2(0, 2), new Vector2(20, 8), activationComponent.ability.Translate(), delegate { UpdateAbility(); }); abilityDBE.ApplyTag("editor"); abilityDBE.AddBorder(); db = new DialogBox(new Vector2(0, 10), new Vector2(15, 1), new StringKey("val", "X_COLON", MONSTER_MASTER)); db.ApplyTag("editor"); TextButton tb = null; if (activationComponent.masterFirst) { tb = new TextButton(new Vector2(15, 10), new Vector2(5, 1), FIRST, delegate { ToggleMasterFirst(); }); } else { tb = new TextButton(new Vector2(15, 10), new Vector2(5, 1), NOT_FIRST, delegate { ToggleMasterFirst(); }); } tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); masterActionsDBE = new DialogBoxEditable( new Vector2(0, 11), new Vector2(20, 8), activationComponent.masterActions.Translate(true), delegate { UpdateMasterActions(); }); masterActionsDBE.ApplyTag("editor"); masterActionsDBE.AddBorder(); db = new DialogBox(new Vector2(0, 19), new Vector2(15, 1), new StringKey("val", "X_COLON", MONSTER_MINION)); db.ApplyTag("editor"); if (activationComponent.minionFirst) { tb = new TextButton(new Vector2(15, 19), new Vector2(5, 1), FIRST, delegate { ToggleMinionFirst(); }); } else { tb = new TextButton(new Vector2(15, 19), new Vector2(5, 1), NOT_FIRST, delegate { ToggleMinionFirst(); }); } tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); minionActionsDBE = new DialogBoxEditable( new Vector2(0, 20), new Vector2(20, 8), activationComponent.minionActions.Translate(true), delegate { UpdateMinionActions(); }); minionActionsDBE.ApplyTag("editor"); minionActionsDBE.AddBorder(); }
public void NextButton(bool disabled, int heroId, int offset) { if (disabled) { new TextButton(new Vector2(UIScaler.GetRight(-8), 19), new Vector2(2, 4), "\\/", delegate { noAction(); }, Color.gray); } else { new TextButton(new Vector2(UIScaler.GetRight(-8), 19), new Vector2(2, 4), "\\/", delegate { RenderPage(heroId, offset + 1); }); } }
// 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()); }
override public void Update() { base.Update(); Game game = Game.Get(); CameraController.SetCamera(tokenComponent.location); TextButton tb = new TextButton(new Vector2(0, 0), new Vector2(4, 1), CommonStringKeys.TOKEN, delegate { QuestEditorData.TypeSelect(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleRight; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(4, 0), new Vector2(15, 1), new StringKey(null, name.Substring("Token".Length), false), delegate { QuestEditorData.ListToken(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(19, 0), new Vector2(1, 1), CommonStringKeys.E, delegate { Rename(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); DialogBox db = new DialogBox(new Vector2(0, 2), new Vector2(4, 1), CommonStringKeys.POSITION); db.ApplyTag("editor"); tb = new TextButton(new Vector2(4, 2), new Vector2(1, 1), CommonStringKeys.POSITION_SNAP, delegate { GetPosition(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); tb = new TextButton(new Vector2(5, 2), new Vector2(1, 1), CommonStringKeys.POSITION_FREE, delegate { GetPosition(false); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); tb = new TextButton(new Vector2(0, 4), new Vector2(8, 1), new StringKey("val", "ROTATION", new StringKey(null, tokenComponent.rotation.ToString(), false)), delegate { Rotate(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); tb = new TextButton(new Vector2(0, 6), new Vector2(8, 1), new StringKey(null, tokenComponent.tokenName, false), delegate { Type(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); tb = new TextButton(new Vector2(0, 8), new Vector2(8, 1), CommonStringKeys.EVENT, delegate { QuestEditorData.SelectAsEvent(name); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); game.quest.ChangeAlpha(tokenComponent.sectionName, 1f); }
public NextStageButton() { if (Game.Get().gameType.DisplayHeroes()) { return; } TextButton qb = new TextButton(new Vector2(UIScaler.GetRight(-5), UIScaler.GetBottom(-3)), new Vector2(4, 2), "->", delegate { Next(); }); // Untag as dialog so this isn't cleared away qb.ApplyTag("questui"); }
// 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); }
public void Update() { Destroyer.Dialog(); selected = new List <string>(); Dictionary <string, string> setPacks = game.config.data.Get(game.gameType.TypeName() + "Packs"); if (setPacks != null) { foreach (KeyValuePair <string, string> kv in setPacks) { selected.Add(kv.Key); } } // Name. We should replace this with a banner DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 2), "Select Expansion Content"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); float x = 1; float y = 4; foreach (ContentData.ContentPack cp in game.cd.allPacks) { if (cp.id.Length > 0) { string id = cp.id; Texture2D tex = ContentData.FileToTexture(cp.image); Sprite sprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), Vector2.zero, 1); if (selected.Contains(id)) { TextButton tb = new TextButton(new Vector2(x, y), new Vector2(6, 6), "", delegate { Unselect(id); }); tb.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite; tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white; } else { TextButton tb = new TextButton(new Vector2(x, y), new Vector2(6, 6), "", delegate { Select(id); }, new Color(0.3f, 0.3f, 0.3f)); tb.background.GetComponent <UnityEngine.UI.Image>().sprite = sprite; tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.3f, 0.3f, 0.3f); } x += 7; if (x > UIScaler.GetRight(-7)) { x = 1; y += 7; } } } new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); }, Color.red); }
public void Update() { Destroyer.Dialog(); Game game = Game.Get(); UIElement ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-18), 1, 36, 23); new UIElementBorder(ui); // Add a title to the page ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6), 1, 12, 3); ui.SetText(new StringKey("val", "ITEMS")); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetFontSize(UIScaler.GetLargeFont()); UIElementScrollHorizontal scrollArea = new UIElementScrollHorizontal(); scrollArea.SetLocation(UIScaler.GetHCenter(-17), 5, 34, 14); new UIElementBorder(scrollArea); float xOffset = 1; foreach (string s in game.quest.itemInspect.Keys) { string tmp = s; var itemData = game.cd.Get <ItemData>(s); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(xOffset, 9, 8, 3); ui.SetButton(delegate { Inspect(tmp); }); ui.SetText(itemData.name, Color.black); ui.SetBGColor(Color.white); Texture2D itemTex = ContentData.FileToTexture(itemData.image); Sprite itemSprite = Sprite.Create(itemTex, new Rect(0, 0, itemTex.width, itemTex.height), Vector2.zero, 1, 0, SpriteMeshType.FullRect); ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(xOffset, 1, 8, 8); ui.SetButton(delegate { Inspect(tmp); }); ui.SetImage(itemSprite); xOffset += 9; } scrollArea.SetScrollSize(xOffset); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-4f), 24.5f, 8, 2); ui.SetText(CommonStringKeys.CLOSE); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.Dialog); new UIElementBorder(ui); }
public static void Draw() { Game game = Game.Get(); // Border around menu items UIElement ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 6, 12, 13); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 7, 10, 2); ui.SetText(UNDO); ui.SetBGColor(new Color(0.03f, 0.0f, 0f)); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetButton(delegate { Undo(); }); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 10, 10, 2); ui.SetText(SAVE); ui.SetBGColor(new Color(0.03f, 0.0f, 0f)); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetButton(delegate { Save(); }); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 13, 10, 2); if (game.testMode) { ui.SetText(new StringKey("val", "EDITOR")); ui.SetButton(delegate { Editor(); }); } else { ui.SetText(MAIN_MENU); ui.SetButton(delegate { Quit(); }); } ui.SetBGColor(new Color(0.03f, 0.0f, 0f)); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetFont(game.gameType.GetHeaderFont()); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 16, 10, 2); ui.SetText(CommonStringKeys.CANCEL); ui.SetBGColor(new Color(0.03f, 0.0f, 0f)); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetFont(game.gameType.GetHeaderFont()); ui.SetButton(delegate { Destroyer.Dialog(); }); new UIElementBorder(ui); }
public static void DrawMonsterHealth(Quest.Monster monster, UnityEngine.Events.UnityAction call) { UIElement ui = new UIElement(); ui.SetLocation(0.2f, 0.2f, 2, 2); ui.SetText(monster.GetHealth().ToString(), Color.red); ui.SetFontSize(UIScaler.GetMediumFont()); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(1, 9, 2, 2); if (monster.damage == 0) { ui.SetText(CommonStringKeys.MINUS, Color.grey); new UIElementBorder(ui, Color.grey); } else { ui.SetText(CommonStringKeys.MINUS, Color.red); new UIElementBorder(ui, Color.red); ui.SetButton(delegate { MonsterDamageDec(monster, call); }); } ui.SetFontSize(UIScaler.GetMediumFont()); ui = new UIElement(); ui.SetLocation(4, 9, 2, 2); ui.SetText(monster.damage.ToString(), Color.red); ui.SetFontSize(UIScaler.GetMediumFont()); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(7, 9, 2, 2); if (monster.damage == monster.GetHealth()) { ui.SetText(CommonStringKeys.PLUS, Color.grey); new UIElementBorder(ui, Color.grey); UIElement defui = new UIElement(); defui.SetLocation(2, 11.5f, 6, 2); defui.SetText(DEFEATED); defui.SetFontSize(UIScaler.GetMediumFont()); defui.SetButton(delegate { Defeated(monster); }); new UIElementBorder(defui, Color.red); } else { ui.SetText(CommonStringKeys.PLUS, Color.red); new UIElementBorder(ui, Color.red); ui.SetButton(delegate { MonsterDamageInc(monster, call); }); } ui.SetFontSize(UIScaler.GetMediumFont()); }
public void CreateQuotaWindow() { // Draw text DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28, 8), new StringKey(null, text, false)); float offset = (db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight / UIScaler.GetPixelsPerUnit()) + 1; db.Destroy(); if (offset < 4) { offset = 4; } db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28, offset), new StringKey(null, text, false)); db.AddBorder(); offset += 1; if (quota == 0) { new TextButton(new Vector2(11, offset), new Vector2(2f, 2f), CommonStringKeys.MINUS, delegate {; }, Color.grey); } else { new TextButton(new Vector2(11, offset), new Vector2(2f, 2f), CommonStringKeys.MINUS, delegate { quotaDec(); }, Color.white); } db = new DialogBox(new Vector2(14, offset), new Vector2(2f, 2f), quota); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); if (quota >= 10) { new TextButton(new Vector2(17, offset), new Vector2(2f, 2f), CommonStringKeys.PLUS, delegate {; }, Color.grey); } else { new TextButton(new Vector2(17, offset), new Vector2(2f, 2f), CommonStringKeys.PLUS, delegate { quotaInc(); }, Color.white); } // Only one button, action depends on quota new TextButton( new Vector2(UIScaler.GetWidthUnits() - 19, offset), new Vector2(8f, 2), eventData.GetButtons()[0].GetLabel(), delegate { onQuota(); }, Color.white); // Do we have a cancel button? if (eventData.qEvent.cancelable) { new TextButton(new Vector2(UIScaler.GetHCenter(-4f), offset + 2.5f), new Vector2(8f, 2), CommonStringKeys.CANCEL, delegate { onCancel(); }); } }
override public void Update() { base.Update(); CameraController.SetCamera(mPlaceComponent.location); Game game = Game.Get(); TextButton tb = new TextButton(new Vector2(0, 0), new Vector2(4, 1), "MPlace", delegate { QuestEditorData.TypeSelect(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleRight; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(4, 0), new Vector2(15, 1), name.Substring("MPlace".Length), delegate { QuestEditorData.ListMPlace(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.button.GetComponent <UnityEngine.UI.Text>().alignment = TextAnchor.MiddleLeft; tb.ApplyTag("editor"); tb = new TextButton(new Vector2(19, 0), new Vector2(1, 1), "E", delegate { Rename(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); DialogBox db = new DialogBox(new Vector2(0, 2), new Vector2(4, 1), "Position"); db.ApplyTag("editor"); tb = new TextButton(new Vector2(4, 2), new Vector2(1, 1), "><", delegate { GetPosition(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); string r = "Right"; if (mPlaceComponent.rotate) { r = "Down"; } tb = new TextButton(new Vector2(0, 4), new Vector2(8, 1), "Rotate: " + r, delegate { Rotate(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); string mast = "Minion"; if (mPlaceComponent.master) { mast = "Master"; } tb = new TextButton(new Vector2(0, 6), new Vector2(8, 1), mast, delegate { MasterToggle(); }); tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont(); tb.ApplyTag("editor"); game.tokenBoard.AddHighlight(mPlaceComponent.location, "MonsterLoc", "editor"); }