Beispiel #1
0
        // 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>();


            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());

            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(Destroyer.MainMenu);
            ui.SetBGColor(new Color(0, 0.03f, 0f));
            new UIElementBorder(ui);
        }
Beispiel #2
0
    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 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);
    }
Beispiel #4
0
    // Construct and display
    public SetWindow()
    {
        Game game = Game.Get();

        foreach (GameObject go in GameObject.FindGameObjectsWithTag(Game.SETWINDOW))
        {
            Object.Destroy(go);
        }

        UIElement ui = new UIElement(Game.SETWINDOW);

        ui.SetLocation(UIScaler.GetHCenter(-10), 10, 20, 10);
        new UIElementBorder(ui);

        ui = new UIElement(Game.SETWINDOW);
        ui.SetLocation(UIScaler.GetHCenter(-8), 11, 16, 2);
        if (game.quest.vars.GetValue("$fire") > 0)
        {
            ui.SetText(CLEAR_FIRE);
            ui.SetButton(ClearFire);
        }
        else
        {
            ui.SetText(SET_FIRE);
            ui.SetButton(SetFire);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui);

        ui = new UIElement(Game.SETWINDOW);
        ui.SetLocation(UIScaler.GetHCenter(-8), 14, 16, 2);
        if (game.quest.vars.GetValue("#eliminated") > 0)
        {
            ui.SetText(INVESTIGATOR_ELIMINATED, Color.gray);
            ui.SetButton(Uneliminate);
            new UIElementBorder(ui, Color.gray);
        }
        else
        {
            ui.SetText(INVESTIGATOR_ELIMINATED);
            ui.SetButton(Eliminate);
            new UIElementBorder(ui);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());

        ui = new UIElement(Game.SETWINDOW);
        ui.SetLocation(UIScaler.GetHCenter(-3), 17, 6, 2);
        ui.SetText(CommonStringKeys.CLOSE);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Destroyer.SetWindow);
        new UIElementBorder(ui);
    }
Beispiel #5
0
    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(); });
        }
    }
Beispiel #6
0
    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());
    }
Beispiel #7
0
        /// <summary>
        /// Method to create language UI elements in the screen
        /// </summary>
        /// <param name="game">current game</param>
        private void CreateLanguageElements()
        {
            // Select langauge text
            UIElement ui = new UIElement();

            ui.SetLocation((0.25f * UIScaler.GetWidthUnits()) - 11, 2, 18, 2);
            ui.SetText(CHOOSE_LANG);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());

            // The list of languages is determined by FFG languages for MoM
            // In D2E there is an additional language
            // It can change in future

            string[] langs = "English,Spanish,French,German,Italian,Portuguese,Polish,Russian,Chinese,Korean,Czech".Split(','); // Japanese removed to fit into screen
            // For now, the languages below are available.
            HashSet <string> enabled_langs = new HashSet <string>("English,Spanish,French,Italian,German,Portuguese,Polish,Russian,Chinese,Korean".Split(','));

            //The first button in the list of buttons should start in this vertical coordinate
            float verticalStart = UIScaler.GetVCenter(-2f) - langs.Length;

            for (int i = 0; i < langs.Length; i++)
            {
                int position = i + 1;
                // Need current index in order to delegate not point to loop for variable
                string currentLanguage = langs[i];

                ui = new UIElement();
                ui.SetLocation((0.25f * UIScaler.GetWidthUnits()) - 6, verticalStart + (2f * position), 8, 1.8f);
                if (!enabled_langs.Contains(currentLanguage))
                {
                    ui.SetText(currentLanguage, Color.red);
                    new UIElementBorder(ui, Color.red);
                }
                else
                {
                    ui.SetButton(delegate { SelectLang(currentLanguage); });
                    if (currentLanguage == game.currentLang)
                    {
                        ui.SetText(currentLanguage);
                        new UIElementBorder(ui);
                    }
                    else
                    {
                        ui.SetText(currentLanguage, Color.grey);
                        new UIElementBorder(ui, Color.grey);
                    }
                }
                ui.SetFontSize(UIScaler.GetMediumFont());
            }
        }
Beispiel #8
0
    public static void Create()
    {
        Game game = Game.Get();

        if (GameObject.FindGameObjectWithTag(Game.DIALOG) != null)
        {
            return;
        }

        // Menu border
        UIElement ui = new UIElement();

        ui.SetLocation((UIScaler.GetWidthUnits() - 12) / 2, 9, 12, 13);
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 10, 10, 2);
        ui.SetText(SAVE);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(QuestEditor.Save);
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 13, 10, 2);
        ui.SetText(RELOAD);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(delegate { QuestEditor.Reload(game.quest.originalPath); });
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 16, 10, 2);
        ui.SetText(MAIN_MENU);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(GameStateManager.MainMenu);
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 19, 10, 2);
        ui.SetText(CommonStringKeys.CANCEL);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(Destroyer.Dialog);
        new UIElementBorder(ui);
    }
Beispiel #9
0
        /// <summary>
        /// Method to create language UI elements in the screen
        /// </summary>
        /// <param name="game">current game</param>
        private void CreateLanguageElements()
        {
            // Select langauge text
            UIElement ui = new UIElement();

            ui.SetLocation((0.25f * UIScaler.GetWidthUnits()) - 9, 4, 18, 2);
            ui.SetText(CHOOSE_LANG);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());

            // The list of languages is determined by FFG languages for MoM
            // In D2E there is an additional language
            // It can change in future

            string[] langs = DictionaryI18n.FFG_LANGS.Split(',');
            // For now, English and Spanish languages available.
            HashSet <string> enabled_langs = new HashSet <string> ("English,Spanish,French,Italian,German,Portuguese".Split(','));

            //The first button in the list of buttons should start in this vertical coordinate
            float verticalStart = UIScaler.GetVCenter(-1f) - ((langs.Length - 1) * 1f);

            for (int i = 1; i < langs.Length; i++)
            {
                int position = i;
                // Need current index in order to delegate not point to loop for variable
                string currentLanguage = langs[position];

                ui = new UIElement();
                ui.SetLocation((0.25f * UIScaler.GetWidthUnits()) - 4, verticalStart + (2f * position), 8, 1.8f);
                if (!enabled_langs.Contains(currentLanguage))
                {
                    ui.SetText(currentLanguage, Color.red);
                    new UIElementBorder(ui, Color.red);
                }
                else
                {
                    ui.SetButton(delegate { SelectLang(currentLanguage); });
                    if (currentLanguage == game.currentLang)
                    {
                        ui.SetText(currentLanguage);
                        new UIElementBorder(ui);
                    }
                    else
                    {
                        ui.SetText(currentLanguage, Color.grey);
                        new UIElementBorder(ui, Color.grey);
                    }
                }
                ui.SetFontSize(UIScaler.GetMediumFont());
            }
        }
Beispiel #10
0
        /// <summary>
        /// Method to create language UI elements in the screen
        /// </summary>
        /// <param name="game">current game</param>
        private void CreateLanguageElements()
        {
            // Select langauge text
            DialogBox dbLanguage = new DialogBox(
                new Vector2(((0.25f * UIScaler.GetWidthUnits()) - 9), 4),
                new Vector2(18, 2),
                CHOOSE_LANG
                );

            dbLanguage.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            dbLanguage.SetFont(game.gameType.GetHeaderFont());

            // The list of languages is determined by FFG languages for MoM
            // In D2E there is an additional language
            // It can change in future

            string[] langs = DictionaryI18n.FFG_LANGS.Split(',');
            // For now, English and Spanish languages available.
            HashSet <string> enabled_langs = new HashSet <string> ("English,Spanish".Split(','));

            //The first button in the list of buttons should start in this vertical coordinate
            float verticalStart = UIScaler.GetVCenter(-1f) - ((langs.Length - 1) * 1f);

            languageTextButtons = new TextButton[langs.Length];
            for (int i = 1; i < langs.Length; i++)
            {
                int position = i;
                // Need current index in order to delegate not point to loop for variable
                string currentLanguage = langs[position];
                Color  currentColor    = Color.gray;

                if (currentLanguage == game.currentLang)
                {
                    selectedIndex = position;
                    currentColor  = Color.white;
                }
                languageTextButtons[position] = new TextButton(
                    new Vector2((0.25f * UIScaler.GetWidthUnits()) - 4, verticalStart + (2f * position)),
                    new Vector2(8, 1.8f),
                    new StringKey(currentLanguage, false),
                    delegate { SelectLang(position); },
                    currentColor
                    );

                if (!enabled_langs.Contains(currentLanguage))
                {
                    languageTextButtons[position].setColor(Color.red);
                    languageTextButtons[position].setActive(false);
                }
            }
        }
Beispiel #11
0
    public static void Create()
    {
        Game game = Game.Get();

        if (GameObject.FindGameObjectWithTag(Game.DIALOG) != null)
        {
            return;
        }

        // Menu border
        UIElement ui = new UIElement();

        ui.SetLocation((UIScaler.GetWidthUnits() - 20) / 2, 9, 20, 13);
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 18) / 2, 10, 18, 2);
        ui.SetText(VALIDATE_SCENARIO, Color.grey);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(Validate_Scenario);
        new UIElementBorder(ui, Color.grey);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 18) / 2, 13, 18, 2);
        ui.SetText(OPTIMIZE_LOCALIZATION, Color.grey);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(Optimize_Localization);
        new UIElementBorder(ui, Color.grey);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 18) / 2, 16, 18, 2);
        ui.SetText(REORDER_COMPONENTS);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(delegate { new ReorderComponents(); });
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation((UIScaler.GetWidthUnits() - 10) / 2, 19, 10, 2);
        ui.SetText(CommonStringKeys.CANCEL);
        ui.SetFont(game.gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetBGColor(new Color(0.03f, 0.0f, 0f));
        ui.SetButton(Destroyer.Dialog);
        new UIElementBorder(ui);
    }
Beispiel #12
0
    // 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);
    }
Beispiel #13
0
        /// <summary>
        /// Method to create UI elements in the screen
        /// </summary>
        /// <param name="game">current game</param>
        private void CreateElements()
        {
            // Options screen text
            DialogBox dbTittle = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Options");

            dbTittle.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
            dbTittle.SetFont(game.gameType.GetHeaderFont());

            // Select langauge text
            DialogBox dbLanguage = new DialogBox(new Vector2(2, 4), new Vector2(UIScaler.GetWidthUnits() - 4, 2), "Choose Language");

            dbLanguage.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            dbLanguage.SetFont(game.gameType.GetHeaderFont());

            // The list of languages is determined by FFG languages for MoM
            // In D2E there is an additional language
            // It can change in future

            string[] langs = DictionaryI18n.FFG_LANGS.Split(',');

            //The first button in the list of buttons should start in this vertical coordinate
            float verticalStart = UIScaler.GetVCenter(-1f) - ((langs.Length - 1) * 1f);

            languageTextButtons = new TextButton[langs.Length];
            for (int i = 1; i < langs.Length; i++)
            {
                int position = i;
                // Need current index in order to delegate not point to loop for variable
                string currentLanguage = langs[position];
                Color  currentColor    = Color.gray;

                if (currentLanguage == game.currentLang)
                {
                    selectedIndex = position;
                    currentColor  = Color.white;
                }
                languageTextButtons[position] = new TextButton(
                    new Vector2(UIScaler.GetHCenter() - 4, verticalStart + (2f * position)),
                    new Vector2(8, 1.8f),
                    currentLanguage,
                    delegate { SelectLang(position); },
                    currentColor
                    );
            }

            // Button for back to main menu
            TextButton tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); }, Color.red);

            tb.SetFont(game.gameType.GetHeaderFont());
        }
Beispiel #14
0
    // Internal function to create button from constructors
    void createButton(Vector2 location, Vector2 size, string text, UnityEngine.Events.UnityAction call, Color colour, int id)
    {
        // Create objects
        button     = new GameObject("button" + text + id);
        background = new GameObject("buttonBg" + text + id);
        border     = new RectangleBorder(background.transform, colour, size);

        // Mark it as dialog (this can be changed with applytag)
        button.tag     = "dialog";
        background.tag = "dialog";

        Game game = Game.Get();

        background.transform.parent = game.uICanvas.transform;

        RectTransform transBg = background.AddComponent <RectTransform>();

        transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, location.y * UIScaler.GetPixelsPerUnit(), size.y * UIScaler.GetPixelsPerUnit());
        transBg.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, location.x * UIScaler.GetPixelsPerUnit(), size.x * UIScaler.GetPixelsPerUnit());

        button.transform.parent = background.transform;

        RectTransform transBt = button.AddComponent <RectTransform>();

        transBt.SetParent(transBg);

        transBt.localPosition = Vector2.zero;
        transBt.localScale    = transBg.localScale;
        transBt.sizeDelta     = transBg.sizeDelta;

        button.AddComponent <CanvasRenderer>();
        background.AddComponent <CanvasRenderer>();

        UnityEngine.UI.Image uiImage = background.AddComponent <UnityEngine.UI.Image>();
        // Background is partially transparent black
        uiImage.color = new Color(0, 0, 0, (float)0.9);

        UnityEngine.UI.Button uiButton = background.AddComponent <UnityEngine.UI.Button>();
        uiButton.interactable = true;
        uiButton.onClick.AddListener(call);

        uiText           = button.AddComponent <UnityEngine.UI.Text>();
        uiText.color     = colour;
        uiText.text      = text;
        uiText.alignment = TextAnchor.MiddleCenter;
        uiText.font      = game.gameType.GetFont();
        uiText.material  = uiText.font.material;
        // Default to medium font size
        uiText.fontSize = UIScaler.GetMediumFont();
    }
Beispiel #15
0
        public void DrawAwareness(float offset)
        {
            if (m.monsterData.awareness == 0)
            {
                return;
            }
            UIElement ui = new UIElement(Game.MONSTERS);

            ui.SetLocation(UIScaler.GetRight(-2.25f), offset, 2, 2);
            ui.SetText(m.monsterData.awareness.ToString(), Color.green);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(MonsterDiag);
            new UIElementBorder(ui, Color.green);
        }
Beispiel #16
0
    override public void CreateWindow(bool singleStep = false)
    {
        // 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);
        }

        // ability box - name header
        UIElement ui = new UIElement();

        ui.SetLocation(UIScaler.GetHCenter(-9f), 0.5f, 18, 2);
        ui.SetText(monster.monsterData.name);
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui);

        float offset = 2.5f;

        if (monster.currentActivation.effect.Length > 0)
        {
            // ability text
            string textKey = monster.currentActivation.effect.Replace("\\n", "\n");
            // Add this to the log
            Game.Get().quest.log.Add(new Quest.LogEntry(textKey.Replace("\n", "\\n")));
            ui = new UIElement();
            ui.SetLocation(10, offset, UIScaler.GetWidthUnits() - 20, 4);
            ui.SetText(textKey);
            new UIElementBorder(ui);
            offset += 4.5f;
        }

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-9f), offset, 18, 2);
        ui.SetText(MONSTER_ATTACKS);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(CreateAttackWindow);
        new UIElementBorder(ui);

        offset += 2.5f;

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-9f), offset, 18, 2);
        ui.SetText(monster.currentActivation.ad.moveButton);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(CreateMoveWindow);
        new UIElementBorder(ui);

        MonsterDialogMoM.DrawMonster(monster);
    }
Beispiel #17
0
    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

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(10f), 8f), new Vector2(3f, 2f), "Skill:");
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(10f), 10f), new Vector2(3f, 2f), EventManager.SymbolReplace(questPuzzle.skill));
        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(-11f), 20f), new Vector2(6f, 2f), "Moves:");
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(-5f), 20f), new Vector2(3f, 2f), (puzzle.moves - previousMoves).ToString());
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(-2f), 20f), new Vector2(10f, 2f), "Total Moves:");
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(8f), 20f), new Vector2(3f, 2f), puzzle.moves.ToString());
        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), "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);
        }
    }
Beispiel #18
0
        // Create the about dialog
        public void About()
        {
            // This will destroy all, because we shouldn't have anything left at the main menu
            Destroyer.Destroy();

            Sprite    bannerSprite;
            Texture2D newTex = Resources.Load("sprites/banner") as Texture2D;

            GameObject banner = new GameObject("banner");

            banner.tag = "dialog";

            banner.transform.parent = Game.Get().uICanvas.transform;

            RectTransform trans = banner.AddComponent <RectTransform>();

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 1 * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, (UIScaler.GetWidthUnits() - 18f) * UIScaler.GetPixelsPerUnit() / 2f, 18f * UIScaler.GetPixelsPerUnit());
            banner.AddComponent <CanvasRenderer>();


            UnityEngine.UI.Image image = banner.AddComponent <UnityEngine.UI.Image>();
            bannerSprite = Sprite.Create(newTex, new Rect(0, 0, newTex.width, newTex.height), Vector2.zero, 1);
            image.sprite = bannerSprite;
            image.rectTransform.sizeDelta = new Vector2(18f * UIScaler.GetPixelsPerUnit(), 7f * UIScaler.GetPixelsPerUnit());

            DialogBox db = new DialogBox(
                new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 10f),
                new Vector2(30, 6),
                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();

            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());
        }
Beispiel #19
0
    public void DrawGold()
    {
        UIElement ui = new UIElement(Game.SHOP);

        ui.SetLocation(UIScaler.GetHCenter(-16), 24, 5, 2);
        ui.SetText(new StringKey("val", "GOLD"));
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetFont(game.gameType.GetHeaderFont());
        new UIElementBorder(ui);

        ui = new UIElement(Game.SHOP);
        ui.SetLocation(UIScaler.GetHCenter(-11), 24, 3, 2);
        ui.SetText(Mathf.RoundToInt(game.quest.vars.GetValue("$%gold")).ToString());
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui);
    }
Beispiel #20
0
    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);
        }

        UIElement ui = new UIElement();

        ui.SetLocation(UIScaler.GetHCenter(-10), 0.5f, 20, 2);
        ui.SetText(ATTACK_PROMPT);
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui);

        float offset = 3f;

        foreach (string type in monster.monsterData.GetAttackTypes())
        {
            string tmpType = type;
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetHCenter(-6f), offset, 12, 2);
            ui.SetText(new StringKey("val", tmpType));
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(delegate { Attack(tmpType); });
            new UIElementBorder(ui);
            offset += 2.5f;
        }

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-4f), offset, 8, 2);
        if (monster.damage == monster.GetHealth())
        {
            ui.SetText(CommonStringKeys.CANCEL, Color.gray);
            new UIElementBorder(ui, Color.gray);
        }
        else
        {
            ui.SetText(CommonStringKeys.CANCEL);
            ui.SetButton(Destroyer.Dialog);
            new UIElementBorder(ui);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());

        MonsterDialogMoM.DrawMonster(monster);
        MonsterDialogMoM.DrawMonsterHealth(monster, delegate { AttackOptions(); });
    }
Beispiel #21
0
        private void CreateEditorTransparencyElements()
        {
            Game game = Game.Get();

            // Select language text
            UIElement ui = new UIElement(Game.DIALOG);

            ui.SetLocation(UIScaler.GetHCenter() - 8, 5, 16, 2);
            ui.SetText(SET_EDITOR_ALPHA);
            ui.SetTextAlignment(TextAnchor.MiddleCenter);
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());

            Texture2D SampleTex    = ContentData.FileToTexture(game.cd.images[IMG_LOW_EDITOR_TRANSPARENCY].image);
            Sprite    SampleSprite = Sprite.Create(SampleTex, new Rect(0, 0, SampleTex.width, SampleTex.height), Vector2.zero, 1);

            ui = new UIElement(Game.DIALOG);
            ui.SetLocation(UIScaler.GetHCenter() - 3, 8, 6, 6);
            ui.SetButton(delegate { UpdateEditorTransparency(0.2f); });
            ui.SetImage(SampleSprite);
            if (game.editorTransparency == 0.2f)
            {
                new UIElementBorder(ui, Color.white);
            }

            SampleTex    = ContentData.FileToTexture(game.cd.images[IMG_MEDIUM_EDITOR_TRANSPARENCY].image);
            SampleSprite = Sprite.Create(SampleTex, new Rect(0, 0, SampleTex.width, SampleTex.height), Vector2.zero, 1);
            ui           = new UIElement(Game.DIALOG);
            ui.SetLocation(UIScaler.GetHCenter() - 3, 15, 6, 6);
            ui.SetButton(delegate { UpdateEditorTransparency(0.3f); });
            ui.SetImage(SampleSprite);
            if (game.editorTransparency == 0.3f)
            {
                new UIElementBorder(ui, Color.white);
            }

            SampleTex    = ContentData.FileToTexture(game.cd.images[IMG_HIGH_EDITOR_TRANSPARENCY].image);
            SampleSprite = Sprite.Create(SampleTex, new Rect(0, 0, SampleTex.width, SampleTex.height), Vector2.zero, 1);
            ui           = new UIElement(Game.DIALOG);
            ui.SetLocation(UIScaler.GetHCenter() - 3, 22, 6, 6);
            ui.SetButton(delegate { UpdateEditorTransparency(0.4f); });
            ui.SetImage(SampleSprite);
            if (game.editorTransparency == 0.4f)
            {
                new UIElementBorder(ui, Color.white);
            }
        }
Beispiel #22
0
    /// <summary>
    /// Parse the downloaded remote manifest and start download of individual quest files
    /// </summary>
    public void DownloadManifest_callback(string data, bool error)
    {
        if (error)
        {
            // Hide loading screen
            Destroyer.Dialog();

            // draw error message
            float     error_string_width = 0;
            UIElement ui = new UIElement();
            if (data == "ERROR NETWORK")
            {
                StringKey ERROR_NETWORK = new StringKey("val", "ERROR_NETWORK");
                ui.SetText(ERROR_NETWORK, Color.red);
                error_string_width = ui.GetStringWidth(ERROR_NETWORK, UIScaler.GetMediumFont());
            }
            else
            {
                StringKey ERROR_HTTP = new StringKey("val", "ERROR_HTTP", game.stats.error_download_description);
                ui.SetText(ERROR_HTTP, Color.red);
                error_string_width = ui.GetStringWidth(ERROR_HTTP, UIScaler.GetMediumFont());
            }
            ui.SetLocation(UIScaler.GetHCenter() - (error_string_width / 2f), UIScaler.GetVCenter(), error_string_width, 2.4f);
            ui.SetTextAlignment(TextAnchor.MiddleCenter);
            ui.SetFontSize(UIScaler.GetLargeFont());
            ui.SetBGColor(Color.clear);

            // draw return button
            ui = new UIElement();
            ui.SetLocation(1, UIScaler.GetBottom(-3), 8, 2);
            ui.SetText(CommonStringKeys.BACK, Color.red);
            ui.SetButton(delegate { Cancel(); });
            ui.SetFont(game.gameType.GetHeaderFont());
            ui.SetFontSize(UIScaler.GetMediumFont());
            new UIElementBorder(ui, Color.red);

            return;
        }

        IniData remoteManifest = IniRead.ReadFromString(data);

        foreach (KeyValuePair <string, Dictionary <string, string> > kv in remoteManifest.data)
        {
            remoteQuests.Add(new RemoteQuest(kv));
        }
        DownloadQuestFiles();
    }
Beispiel #23
0
    public InfoDialog(Quest.Monster m)
    {
        if (m == null)
        {
            ValkyrieDebug.Log("Warning: Invalid monster type requested.");
            return;
        }

        // box with monster info
        UIElement ui = new UIElement();

        ui.SetLocation(10, 0.5f, UIScaler.GetWidthUnits() - 20, 12);
        ui.SetText(m.monsterData.info);
        new UIElementBorder(ui);

        // Unique monsters have additional info
        if (m.unique && m.uniqueText.KeyExists())
        {
            ui = new UIElement();
            ui.SetLocation(12, 13, UIScaler.GetWidthUnits() - 24, 2);
            ui.SetText(m.uniqueTitle, Color.red);
            ui.SetFontSize(UIScaler.GetMediumFont());
            new UIElementBorder(ui, Color.red);

            string uniqueText = EventManager.OutputSymbolReplace(m.uniqueText.Translate().Replace("\\n", "\n"));
            ui = new UIElement();
            ui.SetLocation(10, 15, UIScaler.GetWidthUnits() - 20, 8);
            ui.SetText(uniqueText);
            new UIElementBorder(ui, Color.red);

            ui = new UIElement();
            ui.SetLocation(UIScaler.GetWidthUnits() - 21, 23.5f, 10, 2);
            ui.SetText(CommonStringKeys.CLOSE);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(onClose);
            new UIElementBorder(ui);
        }
        else
        {
            ui = new UIElement();
            ui.SetLocation(UIScaler.GetWidthUnits() - 21, 13, 10, 2);
            ui.SetText(CommonStringKeys.CLOSE);
            ui.SetFontSize(UIScaler.GetMediumFont());
            ui.SetButton(onClose);
            new UIElementBorder(ui);
        }
    }
Beispiel #24
0
        public void CheckForNewValkyrieVersion()
        {
            StringKey NEW_VERSION_AVAILABLE = new StringKey("val", "NEW_VERSION_AVAILABLE");

            if (VersionManager.VersionNewer(Game.Get().version, VersionManager.online_version))
            {
                float     string_width = 0f;
                UIElement ui           = new UIElement();
                ui.SetText(NEW_VERSION_AVAILABLE, Color.green);
                string_width = ui.GetStringWidth(NEW_VERSION_AVAILABLE, UIScaler.GetMediumFont());
                ui.SetLocation(UIScaler.GetRight() - 3 - string_width, UIScaler.GetBottom(-3), string_width + 2, 2);
                ui.SetText(NEW_VERSION_AVAILABLE, Color.green);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { GotoWebBrowser(VersionManager.GetlatestReleaseURL()); });
                ui.SetBGColor(new Color(0, 0.03f, 0f));
                new UIElementBorder(ui, Color.green);
            }
        }
Beispiel #25
0
    public void CreateWindow()
    {
        float offset = ((hero.id - 0.9f) * (HeroCanvas.heroSize + 0.5f)) + HeroCanvas.offsetStart;
        // Has this hero been activated?
        UIElement ui = new UIElement();

        ui.SetLocation(HeroCanvas.heroSize + 0.5f, offset, 10, 2);
        if (hero.activated || (GameObject.FindGameObjectWithTag(Game.ACTIVATION) != null))
        {
            ui.SetText(END_TURN, Color.gray);
            new UIElementBorder(ui, Color.gray);
        }
        else
        {
            ui.SetText(END_TURN);
            ui.SetButton(activated);
            new UIElementBorder(ui);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());

        // Is this hero defeated?
        ui = new UIElement();
        ui.SetLocation(HeroCanvas.heroSize + 0.5f, offset + 2.5f, 10, 2);
        new UIElementBorder(ui);
        if (hero.defeated)
        {
            ui.SetText(RECOVER);
            ui.SetButton(restored);
        }
        else
        {
            ui.SetText(KO);
            ui.SetButton(defeated);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());

        ui = new UIElement();
        ui.SetLocation(HeroCanvas.heroSize + 0.5f, offset + 5, 10, 2);
        ui.SetText(CommonStringKeys.CANCEL);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(onCancel);
        new UIElementBorder(ui);
    }
Beispiel #26
0
    public void DrawGold()
    {
        DialogBox db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-16), 24f),
            new Vector2(5, 2),
            new StringKey("val", "GOLD"));

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.SetFont(game.gameType.GetHeaderFont());
        db.AddBorder();
        db.ApplyTag(Game.SHOP);

        db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-11), 24f),
            new Vector2(3, 2),
            Mathf.RoundToInt(game.quest.vars.GetValue("$%gold")));
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();
        db.ApplyTag(Game.SHOP);
    }
Beispiel #27
0
    public void GuessAdd(int symbolType)
    {
        if (guess.Count >= questPuzzle.puzzleLevel)
        {
            return;
        }
        float hPos = UIScaler.GetHCenter(-13f) + (guess.Count * 2.5f);

        guess.Add(symbolType);

        int       tmp = guess.Count - 1;
        UIElement ui  = new UIElement();

        ui.SetLocation(hPos, 4, 2, 2);
        ui.SetText(buttons[symbolType].label, Color.black);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(delegate { GuessRemove(tmp); });
        ui.SetImage(buttons[symbolType].image);
        ui.SetBGColor(new Color(1, 1, 1, 0.9f));
    }
Beispiel #28
0
    public void About()
    {
        // This will destroy all, because we shouldn't have anything left at the main menu
        Destroyer.Destroy();

        // Name.  We should replace this with a banner
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Valkyrie");

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();

        db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 8f), new Vector2(30, 6), "Valkyrie is a game master helper tool inspired by Fantasy Flight Games' Descent: Road to Legend.  Most images used are imported from FFG applications are are copyright FFG and other rights holders.");
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 30f) / 2, 16f), new Vector2(30, 5), "Valkyrie uses DotNetZip-For-Unity and has code derived from Unity Studio.");
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        TextButton tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { Destroyer.MainMenu(); });

        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0, 0.03f, 0f);
    }
        // Import content
        public void Import(string type)
        {
            Destroyer.Destroy();

            // 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(CONTENT_IMPORTING);
            ui.SetFontSize(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) ;
        }
Beispiel #30
0
    // This is called when a quest is selected
    public void StartQuest(QuestData.Quest q)
    {
        if (Path.GetExtension(Path.GetFileName(q.path)) == ".valkyrie")
        {
            // extract the full package
            QuestLoader.ExtractSinglePackageFull(ContentData.DownloadPath() + Path.DirectorySeparatorChar + Path.GetFileName(q.path));
        }

        // Fetch all of the quest data and initialise the quest
        quest = new Quest(q);

        // Draw the hero icons, which are buttons for selection
        heroCanvas.SetupUI();

        // Add a finished button to start the quest
        UIElement ui = new UIElement(Game.HEROSELECT);

        ui.SetLocation(UIScaler.GetRight(-8.5f), UIScaler.GetBottom(-2.5f), 8, 2);
        ui.SetText(CommonStringKeys.FINISHED, Color.green);
        ui.SetFont(gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(EndSelection);
        new UIElementBorder(ui, Color.green);

        // Add a title to the page
        ui = new UIElement(Game.HEROSELECT);
        ui.SetLocation(8, 1, UIScaler.GetWidthUnits() - 16, 3);
        ui.SetText(new StringKey("val", "SELECT", gameType.HeroesName()));
        ui.SetFont(gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetLargeFont());

        heroCanvas.heroSelection = new HeroSelection();

        ui = new UIElement(Game.HEROSELECT);
        ui.SetLocation(0.5f, UIScaler.GetBottom(-2.5f), 8, 2);
        ui.SetText(CommonStringKeys.BACK, Color.red);
        ui.SetFont(gameType.GetHeaderFont());
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Destroyer.QuestSelect);
        new UIElementBorder(ui, Color.red);
    }