// 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 Delete() { // Border UIElement ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6.5f), 1, 13, 4); new UIElementBorder(ui); // Heading ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6f), 1, 12, 1); ui.SetText(CommonStringKeys.CONFIRM); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-5.5f), 3, 6, 1); ui.SetText(CommonStringKeys.DELETE, Color.red); ui.SetButton(delegate { ConfirmDelete(); }); ui.SetBGColor(new Color(0.0f, 0.03f, 0f)); new UIElementBorder(ui, Color.red); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(1.5f), 3, 4, 1); ui.SetText(CommonStringKeys.CANCEL); ui.SetButton(delegate { Destroyer.Dialog(); }); ui.SetBGColor(new Color(0.03f, 0, 0f)); new UIElementBorder(ui); }
public void Update() { // Clean up everything marked as 'uiphase' foreach (GameObject go in GameObject.FindGameObjectsWithTag("uiphase")) { Object.Destroy(go); } StringKey phase; if (Game.Get().quest.phase == Quest.MoMPhase.horror) { phase = HORROR_STEP; } else if (Game.Get().quest.phase == Quest.MoMPhase.mythos) { phase = PHASE_MYTHOS; } else if (Game.Get().quest.phase == Quest.MoMPhase.monsters) { phase = MONSTER_STEP; } else { phase = PHASE_INVESTIGATOR; } DialogBox db; db = new DialogBox(new Vector2(UIScaler.GetHCenter(-6f), UIScaler.GetBottom(-2.5f)), new Vector2(16, 2), phase); db.SetFont(Game.Get().gameType.GetHeaderFont()); db.ApplyTag("uiphase"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); }
public void Update() { // Clean up everything marked as 'uiphase' foreach (GameObject go in GameObject.FindGameObjectsWithTag("uiphase")) { Object.Destroy(go); } DialogBox db; if (Game.Get().quest.phase == Quest.MoMPhase.horror) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-6f), UIScaler.GetBottom(-2.5f)), new Vector2(16, 2), "Horror Phase"); db.SetFont(Game.Get().gameType.GetHeaderFont()); } else if (Game.Get().quest.phase == Quest.MoMPhase.mythos) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-6f), UIScaler.GetBottom(-2.5f)), new Vector2(16, 2), "Mythos Phase"); db.SetFont(Game.Get().gameType.GetHeaderFont()); } else if (Game.Get().quest.phase == Quest.MoMPhase.monsters) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-6f), UIScaler.GetBottom(-2.5f)), new Vector2(16, 2), "Monster Phase"); db.SetFont(Game.Get().gameType.GetHeaderFont()); } else { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-6f), UIScaler.GetBottom(-2.5f)), new Vector2(16, 2), "Investigator Phase"); db.SetFont(Game.Get().gameType.GetHeaderFont()); } db.ApplyTag("uiphase"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); }
public void CreateMoveWindow() { if (monster.currentActivation.ad.move.fullKey.Length == 0) { activated(); return; } Destroyer.Dialog(); 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(); float offset = 2.5f; db = new DialogBox(new Vector2(10, offset), new Vector2(UIScaler.GetWidthUnits() - 20, 4), new StringKey(null, monster.currentActivation.move.Replace("\\n", "\n"), false)); db.AddBorder(); offset += 4.5f; new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), CommonStringKeys.FINISHED, delegate { activated(); }); MonsterDialogMoM.DrawMonster(monster); }
// Construct and display public SetWindow() { Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10f), 10f), new Vector2(20, 10f), ""); db.AddBorder(); if (game.quest.flags.Contains("#fire")) { new TextButton(new Vector2(UIScaler.GetHCenter(-8f), 11f), new Vector2(16, 2), "Clear Fire", delegate { ClearFire(); }); } else { new TextButton(new Vector2(UIScaler.GetHCenter(-8f), 11f), new Vector2(16, 2), "Set Fire", delegate { SetFire(); }); } if (game.quest.flags.Contains("#eliminated")) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-8f), 14f), new Vector2(16, 2), "Investigator Eliminated", Color.gray); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); } else { new TextButton(new Vector2(UIScaler.GetHCenter(-8f), 14f), new Vector2(16, 2), "Investigator Eliminated", delegate { Eliminate(); }); } new TextButton(new Vector2(UIScaler.GetHCenter(-3f), 17f), new Vector2(6, 2), "Close", delegate { Destroyer.Dialog(); }); }
public void AttackOptions() { // 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); } DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10f), 0.5f), new Vector2(20, 2), ATTACK_PROMPT); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); float offset = 3f; foreach (string type in attackType) { string tmpType = type; new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), new StringKey("val", tmpType), delegate { Attack(tmpType); }); offset += 2.5f; } if (monster.damage == monster.GetHealth()) { new TextButton(new Vector2(UIScaler.GetHCenter(-4f), offset), new Vector2(8, 2), CommonStringKeys.CANCEL, delegate {; }, Color.gray); } else { new TextButton(new Vector2(UIScaler.GetHCenter(-4f), offset), new Vector2(8, 2), CommonStringKeys.CANCEL, delegate { Destroyer.Dialog(); }); } MonsterDialogMoM.DrawMonster(monster); MonsterDialogMoM.DrawMonsterHealth(monster, delegate { AttackOptions(); }); }
public void DrawVarList() { UIElementScrollVertical scrollArea = new UIElementScrollVertical(); scrollArea.SetLocation(UIScaler.GetHCenter(2.5f), 0.5f, 16, 24.5f); new UIElementBorder(scrollArea); // List of vars float offset = 0.1f; valueUIE = new Dictionary <string, UIElementEditable>(); foreach (KeyValuePair <string, float> kv in Game.Get().quest.vars.vars) { string key = kv.Key; UIElement ui = new UIElement(scrollArea.GetScrollTransform()); ui.SetLocation(0, offset, 12, 1.2f); ui.SetBGColor(Color.white); ui.SetText(key, Color.black); ui.SetButton(delegate { UpdateValue(key); }); new UIElementBorder(ui); UIElementEditable uie = new UIElementEditable(scrollArea.GetScrollTransform()); uie.SetLocation(12.5f, offset, 2.5f, 1.2f); uie.SetBGColor(Color.white); uie.SetText(kv.Value.ToString(), Color.black); uie.SetSingleLine(); uie.SetButton(delegate { UpdateValue(key); }); new UIElementBorder(uie); valueUIE.Add(key, uie); offset += 1.4f; } scrollArea.SetScrollSize(offset); }
// Construct and display public NextStageButton() { if (Game.Get().gameType.DisplayHeroes()) { return; } TextButton tb = new TextButton( new Vector2(UIScaler.GetHCenter(10f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2), CommonStringKeys.TAB, delegate { Next(); }); // Untag as dialog so this isn't cleared away tb.ApplyTag("questui"); tb.SetFont(Game.Get().gameType.GetHeaderFont()); tb = new TextButton( new Vector2(UIScaler.GetHCenter(-14f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2), CommonStringKeys.LOG, delegate { Log(); }); // Untag as dialog so this isn't cleared away tb.ApplyTag("questui"); tb.SetFont(Game.Get().gameType.GetHeaderFont()); tb = new TextButton( new Vector2(UIScaler.GetHCenter(-10f), UIScaler.GetBottom(-2.5f)), new Vector2(4, 2), CommonStringKeys.SET, delegate { Set(); }); // Untag as dialog so this isn't cleared away tb.ApplyTag("questui"); tb.SetFont(Game.Get().gameType.GetHeaderFont()); Update(); }
public void CreateMoveWindow() { if (monster.currentActivation.ad.move.key.Length == 0) { activated(); return; } Destroyer.Dialog(); DialogBox db = new DialogBox(new Vector2(15, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 30, 2), monster.monsterData.name.Translate()); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); float offset = 2.5f; db = new DialogBox(new Vector2(10, offset), new Vector2(UIScaler.GetWidthUnits() - 20, 4), monster.currentActivation.move.Replace("\\n", "\n")); db.AddBorder(); offset += 4.5f; new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), "Finished", delegate { activated(); }); DrawMonsterIcon(); }
public void Draw(PuzzleImage.TilePosition screenPos, PuzzleImage.TilePosition imgPos, bool solved) { Game game = Game.Get(); // Create object GameObject gameObject = new GameObject("PuzzleTile"); gameObject.tag = "dialog"; gameObject.transform.parent = game.uICanvas.transform; RectTransform trans = gameObject.AddComponent <RectTransform>(); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, UIScaler.GetPixelsPerUnit() + (UIScaler.GetPixelsPerUnit() * screenPos.y * height), height * UIScaler.GetPixelsPerUnit()); trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetHCenter(-11.5f) * UIScaler.GetPixelsPerUnit()) + (UIScaler.GetPixelsPerUnit() * screenPos.x * width), width * UIScaler.GetPixelsPerUnit()); gameObject.AddComponent <CanvasRenderer>(); // Create the image UnityEngine.UI.Image image = gameObject.AddComponent <UnityEngine.UI.Image>(); image.sprite = imageSprite[imgPos.x][imgPos.y]; image.rectTransform.sizeDelta = new Vector2(width * UIScaler.GetPixelsPerUnit(), height * UIScaler.GetPixelsPerUnit()); if (solved) { return; } BlockSlider slider = gameObject.AddComponent <BlockSlider>(); slider.screenPos = screenPos; slider.win = this; }
// Construct and display public LogWindow() { Game game = Game.Get(); // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } // white background because font rendering is broken string log = ""; foreach (Quest.LogEntry e in game.quest.log) { log += e.GetEntry(); } log.Trim('\n'); DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28, 24.5f), log, Color.black, new Color(1, 1, 1, 0.9f)); db.AddBorder(); // This material works for the mask, but only renders in black db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial"); UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>(); scrollRect.content = db.textObj.GetComponent <RectTransform>(); scrollRect.horizontal = false; RectTransform textRect = db.textObj.GetComponent <RectTransform>(); textRect.sizeDelta = new Vector2(textRect.rect.width, db.textObj.GetComponent <UnityEngine.UI.Text>().preferredHeight); scrollRect.verticalNormalizedPosition = 0f; UnityEngine.UI.Mask mask = db.background.AddComponent <UnityEngine.UI.Mask>(); new TextButton(new Vector2(UIScaler.GetHCenter(-3f), 25f), new Vector2(6, 2), "Close", delegate { Destroyer.Dialog(); }); }
/// <summary> /// Draw the contents to the screen /// </summary> /// <param name="display">Text to display</param> private void Draw(string display) { // Create an object GameObject logo = new GameObject("logo"); // Mark it as dialog logo.tag = Game.DIALOG; logo.transform.SetParent(Game.Get().uICanvas.transform); RectTransform transBg = logo.AddComponent <RectTransform>(); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, UIScaler.GetHCenter(-3) * UIScaler.GetPixelsPerUnit(), 6 * UIScaler.GetPixelsPerUnit()); transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 8 * UIScaler.GetPixelsPerUnit(), 6 * UIScaler.GetPixelsPerUnit()); // 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); UnityEngine.UI.Image uiImage = logo.AddComponent <UnityEngine.UI.Image>(); uiImage.sprite = sprite; logo.AddComponent <SpritePulser>(); // Display message UIElement ui = new UIElement(); ui.SetLocation(2, 20, UIScaler.GetWidthUnits() - 4, 2); ui.SetText(display); ui.SetFontSize(UIScaler.GetMediumFont()); }
public void CreateMoveWindow() { if (monster.currentActivation.ad.move.fullKey.Length == 0) { activated(); return; } Destroyer.Dialog(); 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(); float offset = 2.5f; UIElement ui = new UIElement(); ui.SetLocation(10, offset, UIScaler.GetWidthUnits() - 20, 4); ui.SetText(monster.currentActivation.move.Replace("\\n", "\n")); new UIElementBorder(ui); // Add this to the log Game.Get().quest.log.Add(new Quest.LogEntry(monster.currentActivation.move.Replace("\n", "\\n"))); offset += 4.5f; new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), CommonStringKeys.FINISHED, delegate { activated(); }); MonsterDialogMoM.DrawMonster(monster); }
public void AttackOptions() { // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10f), 0.5f), new Vector2(20, 2), "Select Attack Type"); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); float offset = 3f; foreach (string type in attackType) { string tmpType = type; // Make first character upper case string nameType = System.Char.ToUpper(type[0]) + type.Substring(1); new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), nameType, delegate { Attack(tmpType); }); offset += 2.5f; } new TextButton(new Vector2(UIScaler.GetHCenter(-4f), offset), new Vector2(8, 2), "Cancel", delegate { Destroyer.Dialog(); }, Color.red); }
public void CreateAttackWindow() { Destroyer.Dialog(); // ability box - name header UIElement ui = new UIElement(); ui.SetLocation(15, 0.5f, UIScaler.GetWidthUnits() - 30, 2); ui.SetText(monster.monsterData.name); ui.SetFontSize(UIScaler.GetMediumFont()); new UIElementBorder(ui); float offset = 2.5f; ui = new UIElement(); ui.SetLocation(10, offset, UIScaler.GetWidthUnits() - 20, 4); ui.SetText(monster.currentActivation.masterActions.Replace("\\n", "\n")); new UIElementBorder(ui); // Add this to the log Game.Get().quest.log.Add(new Quest.LogEntry(monster.currentActivation.masterActions.Replace("\n", "\\n"))); offset += 4.5f; ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6f), offset, 12, 2); ui.SetText(CommonStringKeys.FINISHED); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(activated); new UIElementBorder(ui); MonsterDialogMoM.DrawMonster(monster); }
public void DrawButtons() { float offset = 3; for (int i = 0; i < eventData.buttons.Count; i++) { StringKey label = new StringKey(null, EventManager.OutputSymbolReplace(eventData.buttons[i].Translate()), false); Color colour = Color.white; string colorRGB = ColorUtil.FromName(eventData.buttonColors[i]); // Check format is valid if ((colorRGB.Length != 7) || (colorRGB[0] != '#')) { Game.Get().quest.log.Add(new Quest.LogEntry("Warning: Button color must be in #RRGGBB format or a known name", true)); } // Hexadecimal to float convert (0x00-0xFF -> 0.0-1.0) colour[0] = (float)System.Convert.ToInt32(colorRGB.Substring(1, 2), 16) / 255f; colour[1] = (float)System.Convert.ToInt32(colorRGB.Substring(3, 2), 16) / 255f; colour[2] = (float)System.Convert.ToInt32(colorRGB.Substring(5, 2), 16) / 255f; int tmp = i; UIElement ui = new UIElement(Game.SHOP); ui.SetLocation(UIScaler.GetHCenter(-17), offset, 10, 2); ui.SetText(label, colour); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { OnButton(tmp); }); new UIElementBorder(ui, colour); offset += 3; } }
// Construct and display public SetWindow() { Game game = Game.Get(); foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.DIALOG)) { Object.Destroy(go); } DialogBox db = new DialogBox(new Vector2(UIScaler.GetHCenter(-10f), 10f), new Vector2(20, 10f), StringKey.NULL); db.AddBorder(); if (game.quest.vars.GetValue("$fire") > 0) { new TextButton(new Vector2(UIScaler.GetHCenter(-8f), 11f), new Vector2(16, 2), CLEAR_FIRE, delegate { ClearFire(); }); } else { new TextButton(new Vector2(UIScaler.GetHCenter(-8f), 11f), new Vector2(16, 2), SET_FIRE, delegate { SetFire(); }); } if (game.quest.vars.GetValue("#eliminated") > 0) { db = new DialogBox(new Vector2(UIScaler.GetHCenter(-8f), 14f), new Vector2(16, 2), INVESTIGATOR_ELIMINATED, Color.gray); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); } else { new TextButton(new Vector2(UIScaler.GetHCenter(-8f), 14f), new Vector2(16, 2), INVESTIGATOR_ELIMINATED, delegate { Eliminate(); }); } new TextButton(new Vector2(UIScaler.GetHCenter(-3f), 17f), new Vector2(6, 2), CommonStringKeys.CLOSE, delegate { Destroyer.Dialog(); }); }
protected virtual void DrawItemList() { UIElementScrollVertical itemScrollArea = new UIElementScrollVertical(); itemScrollArea.SetLocation(UIScaler.GetHCenter(-3.5f), 2, 21, 25); new UIElementBorder(itemScrollArea); float offset = 0; foreach (SelectionItemTraits item in traitItems) { bool display = true; foreach (TraitGroup tg in traitData) { display &= tg.ActiveItem(item); } if (!display) { continue; } offset = DrawItem(item, itemScrollArea.GetScrollTransform(), offset); } itemScrollArea.SetScrollSize(offset); }
public void CreateWindow() { // Draw text UIElement ui = new UIElement(); float offset = ui.GetStringHeight(text, 28); if (offset < 4) { offset = 4; } ui.SetLocation(UIScaler.GetHCenter(-14f), 0.5f, 28, offset); ui.SetText(text); new UIElementBorder(ui); 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) { float length = ui.GetStringWidth(eb.GetLabel().Translate(), UIScaler.GetMediumFont()); if (length > buttonWidth) { buttonWidth = length; hOffset = UIScaler.GetHCenter(-length / 2); hOffsetCancel = UIScaler.GetHCenter(-4); offsetCancel = offset + (2.5f * buttons.Count); } } int num = 1; foreach (EventButton eb in buttons) { int numTmp = num++; ui = new UIElement(); ui.SetLocation(hOffset, offset, buttonWidth, 2); ui.SetText(eb.GetLabel(), eb.colour); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(delegate { onButton(numTmp); }); new UIElementBorder(ui, eb.colour); offset += 2.5f; } // Do we have a cancel button? if (eventData.qEvent.cancelable) { ui = new UIElement(); ui.SetLocation(hOffsetCancel, offsetCancel, 8, 2); ui.SetText(CommonStringKeys.CANCEL); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(onCancel); new UIElementBorder(ui); } }
public HorrorCheck(Quest.Monster m) { Game game = Game.Get(); List <HorrorData> horrors = new List <HorrorData>(); foreach (KeyValuePair <string, HorrorData> kv in game.cd.horrorChecks) { if (m.monsterData.sectionName.Equals("Monster" + kv.Value.monster)) { horrors.Add(kv.Value); } } // If a dialog window is open we force it closed (this shouldn't happen) foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog")) { Object.Destroy(go); } string text = horrors[Random.Range(0, horrors.Count)].text.Translate().Replace("{0}", m.monsterData.name.Translate()); DialogBox db = new DialogBox(new Vector2(10, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 8), text); db.AddBorder(); new TextButton(new Vector2(UIScaler.GetHCenter(-6f), 9f), new Vector2(12, 2), "Finished", delegate { Destroyer.Dialog(); }); }
protected void Draw(HorrorData horror, Quest.Monster m) { Game game = Game.Get(); // 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); } string text = horror.text.Translate().Replace("{0}", m.monsterData.name.Translate()); UIElement ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-14), 0.5f, 28, 8); ui.SetText(text); new UIElementBorder(ui); game.quest.log.Add(new Quest.LogEntry(text.Replace("\n", "\\n"))); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6f), 9, 12, 2); ui.SetText(CommonStringKeys.FINISHED); ui.SetFontSize(UIScaler.GetMediumFont()); ui.SetButton(Destroyer.Dialog); new UIElementBorder(ui); MonsterDialogMoM.DrawMonster(m, true); }
override 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(UIScaler.GetHCenter(-9f), 0.5f), new Vector2(18, 2), monster.monsterData.name); db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont(); db.AddBorder(); float offset = 2.5f; if (monster.currentActivation.effect.Length > 0) { // ability text db = new DialogBox(new Vector2(10, offset), new Vector2(UIScaler.GetWidthUnits() - 20, 4), monster.currentActivation.effect.Replace("\\n", "\n")); db.AddBorder(); offset += 4.5f; } new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), "Monster Attacks", delegate { CreateAttackWindow(); }); offset += 2.5f; new TextButton(new Vector2(UIScaler.GetHCenter(-6f), offset), new Vector2(12, 2), "Unable to Atack", delegate { activated(); }); DrawMonsterIcon(); }
public void Attack() { Destroyer.Dialog(); UIElement ui = new UIElement(); ui.SetLocation(10, 0.5f, UIScaler.GetWidthUnits() - 20, 8); ui.SetText(attackText); new UIElementBorder(ui); ui = new UIElement(); ui.SetLocation(UIScaler.GetHCenter(-6), 9, 12, 2); if (monster.damage == monster.GetHealth()) { ui.SetText(CommonStringKeys.FINISHED, Color.gray); new UIElementBorder(ui, Color.gray); } else { ui.SetText(CommonStringKeys.FINISHED); ui.SetButton(Destroyer.Dialog); new UIElementBorder(ui); } ui.SetFontSize(UIScaler.GetMediumFont()); MonsterDialogMoM.DrawMonster(monster); MonsterDialogMoM.DrawMonsterHealth(monster, delegate { Attack(); }); }
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 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()); } }
// 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(); }
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); } }
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); } }
protected override void DrawItemList() { UIElementScrollVertical itemScrollArea = new UIElementScrollVertical(); itemScrollArea.SetLocation(UIScaler.GetHCenter(-3.5f), 2, 21, 25); new UIElementBorder(itemScrollArea); List <SelectionItemTraits> toDisplay = new List <SelectionItemTraits>(traitItems.Values); if (alphaSort) { toDisplay = new List <SelectionItemTraits>(alphaTraitItems.Values); } if (reverseSort) { toDisplay.Reverse(); } toDisplay.InsertRange(0, alwaysOnTopTraitItems.Values); float offset = 0; float xOffset = 0; float yOffset = 4; foreach (SelectionItemTraits item in allItems) { if (!traitGroups.All(tg => tg.ActiveItem(item))) { continue; } if (spriteCache.ContainsKey(item.GetKey())) { if (20 - xOffset < spriteCache[item.GetKey()].width) { offset += yOffset; xOffset = 0; } xOffset = DrawItem(item.GetKey(), itemScrollArea.GetScrollTransform(), offset, xOffset, out yOffset); } else { if (xOffset > 0) { offset += yOffset; } xOffset = 0; offset = DrawItem(item, itemScrollArea.GetScrollTransform(), offset); } } if (xOffset != 0) { offset += yOffset; } itemScrollArea.SetScrollSize(offset); }