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(); });
        }
    }
Exemple #2
0
    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();
    }
    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();
    }
Exemple #4
0
    public InfoDialog(Game.Monster m)
    {
        if (m == null)
        {
            Debug.Log("Warning: Invalid monster type requested.");
            return;
        }

        DialogBox db = new DialogBox(new Vector2(10, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 12), m.monsterData.info.Replace("\\n", "\n"));

        db.AddBorder();

        if (m.unique)
        {
            db = new DialogBox(new Vector2(12, 13f), new Vector2(UIScaler.GetWidthUnits() - 24, 2), m.uniqueTitle, Color.red);
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.AddBorder();
            db = new DialogBox(new Vector2(10, 15f), new Vector2(UIScaler.GetWidthUnits() - 20, 8), m.uniqueText.Replace("\\n", "\n"));
            db.AddBorder(Color.red);
            new TextButton(new Vector2(UIScaler.GetWidthUnits() - 21, 23.5f), new Vector2(10, 2), "Close", delegate { onClose(); });
        }
        else
        {
            new TextButton(new Vector2(UIScaler.GetWidthUnits() - 21, 13f), new Vector2(10, 2), "Close", delegate { onClose(); });
        }
    }
Exemple #5
0
    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);
    }
Exemple #6
0
    public static void Create()
    {
        Game game = Game.Get();

        if (GameObject.FindGameObjectWithTag("dialog") != null)
        {
            return;
        }

        // Menu border
        DialogBox db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 9), new Vector2(12, 13), "");

        db.AddBorder();
        db.SetFont(game.gameType.GetHeaderFont());

        TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 10), new Vector2(10, 2f), "Save", delegate { QuestEditor.Save(); }, Color.white);

        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());

        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 13), new Vector2(10, 2f), "Reload", delegate { QuestEditor.Reload(); }, Color.white);
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());

        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 16), new Vector2(10, 2f), "Main Menu", delegate { Destroyer.MainMenu(); }, Color.white);
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());

        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 19), new Vector2(10, 2f), "Cancel", delegate { Destroyer.Dialog(); }, Color.white);
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());
    }
    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);
    }
Exemple #8
0
    // 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(); });
    }
    public static void DrawMonsterHealth(Quest.Monster monster, UnityEngine.Events.UnityAction call)
    {
        int health = Mathf.RoundToInt(monster.monsterData.health) + Game.Get().quest.GetHeroCount();

        DialogBox db = new DialogBox(new Vector2(0.2f, 0.2f), new Vector2(2, 2),
                                     new StringKey((health).ToString(), false), Color.red);

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

        if (monster.damage == 0)
        {
            new TextButton(new Vector2(1f, 9), new Vector2(2, 2), CommonStringKeys.MINUS, delegate { MonsterDamageDec(monster, call); }, Color.grey);
        }
        else
        {
            new TextButton(new Vector2(1f, 9), new Vector2(2, 2), CommonStringKeys.MINUS, delegate { MonsterDamageDec(monster, call); }, Color.red);
        }

        db = new DialogBox(new Vector2(4f, 9), new Vector2(2, 2),
                           new StringKey((monster.damage).ToString(), false), Color.red);
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();

        if (monster.damage == health)
        {
            new TextButton(new Vector2(7f, 9), new Vector2(2, 2), CommonStringKeys.PLUS, delegate { MonsterDamageInc(monster, call); }, Color.grey);
            new TextButton(new Vector2(2, 11.5f), new Vector2(6, 2), DEFEATED, delegate { Defeated(monster); }, Color.red);
        }
        else
        {
            new TextButton(new Vector2(7f, 9), new Vector2(2, 2), CommonStringKeys.PLUS, delegate { MonsterDamageInc(monster, call); }, Color.red);
        }
    }
    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 static void DrawMonsterHealth(Quest.Monster monster, UnityEngine.Events.UnityAction call)
    {
        DialogBox db = new DialogBox(new Vector2(0.2f, 0.2f), new Vector2(2, 2), monster.GetHealth(), Color.red);

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

        if (monster.damage == 0)
        {
            new TextButton(new Vector2(1f, 9), new Vector2(2, 2), CommonStringKeys.MINUS, delegate { MonsterDamageDec(monster, call); }, Color.grey);
        }
        else
        {
            new TextButton(new Vector2(1f, 9), new Vector2(2, 2), CommonStringKeys.MINUS, delegate { MonsterDamageDec(monster, call); }, Color.red);
        }

        db = new DialogBox(new Vector2(4f, 9), new Vector2(2, 2), monster.damage, Color.red);
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();

        if (monster.damage == monster.GetHealth())
        {
            new TextButton(new Vector2(7f, 9), new Vector2(2, 2), CommonStringKeys.PLUS, delegate { MonsterDamageInc(monster, call); }, Color.grey);
            new TextButton(new Vector2(2, 11.5f), new Vector2(6, 2), DEFEATED, delegate { Defeated(monster); }, Color.red);
        }
        else
        {
            new TextButton(new Vector2(7f, 9), new Vector2(2, 2), CommonStringKeys.PLUS, delegate { MonsterDamageInc(monster, call); }, Color.red);
        }
    }
Exemple #12
0
    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 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(); });
    }
    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(); });
    }
Exemple #15
0
    public InfoDialog(Quest.Monster m)
    {
        if (m == null)
        {
            ValkyrieDebug.Log("Warning: Invalid monster type requested.");
            return;
        }

        // box with monster info
        DialogBox db = new DialogBox(
            new Vector2(10, 0.5f),
            new Vector2(UIScaler.GetWidthUnits() - 20, 12),
            m.monsterData.info);

        db.AddBorder();

        // Unique monsters have additional info
        if (m.unique && m.uniqueText.KeyExists())
        {
            db = new DialogBox(new Vector2(12, 13f), new Vector2(UIScaler.GetWidthUnits() - 24, 2),
                               m.uniqueTitle, Color.red);
            db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
            db.AddBorder();
            string uniqueText = EventManager.SymbolReplace(m.uniqueText.Translate().Replace("\\n", "\n"));
            db = new DialogBox(new Vector2(10, 15f), new Vector2(UIScaler.GetWidthUnits() - 20, 8),
                               new StringKey(null, uniqueText, false));
            db.AddBorder(Color.red);
            new TextButton(new Vector2(UIScaler.GetWidthUnits() - 21, 23.5f), new Vector2(10, 2), CommonStringKeys.CLOSE, delegate { onClose(); });
        }
        else
        {
            new TextButton(new Vector2(UIScaler.GetWidthUnits() - 21, 13f), new Vector2(10, 2), CommonStringKeys.CLOSE, delegate { onClose(); });
        }
    }
Exemple #16
0
    public void MonsterHealth()
    {
        int health = Mathf.RoundToInt(monster.monsterData.health) + Game.Get().quest.GetHeroCount();

        if (monster.damage == health)
        {
            new TextButton(new Vector2(1f, 10f), new Vector2(2, 2), "-", delegate { MonsterHealthDec(); }, Color.grey);
        }
        else
        {
            new TextButton(new Vector2(1f, 10f), new Vector2(2, 2), "-", delegate { MonsterHealthDec(); }, Color.red);
        }

        DialogBox db = new DialogBox(new Vector2(4f, 10f), new Vector2(2, 2), (health - monster.damage).ToString(), Color.red);

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

        if (monster.damage == 0)
        {
            new TextButton(new Vector2(7f, 10f), new Vector2(2, 2), "+", delegate { MonsterHealthInc(); }, Color.grey);
        }
        else
        {
            new TextButton(new Vector2(7f, 10f), new Vector2(2, 2), "+", delegate { MonsterHealthInc(); }, Color.red);
        }
    }
Exemple #17
0
    // 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(); });
    }
Exemple #18
0
    public static void Draw()
    {
        Game game = Game.Get();
        // Border around menu items
        DialogBox db = new DialogBox(new Vector2((UIScaler.GetWidthUnits() - 12) / 2, 6), new Vector2(12, 13), StringKey.NULL);

        db.AddBorder();

        TextButton tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 7), new Vector2(10, 2f), UNDO, delegate { Undo(); });

        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());

        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 10), new Vector2(10, 2f), SAVE, delegate { Save(); });
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());

        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 13), new Vector2(10, 2f), MAIN_MENU, delegate { Quit(); });
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());

        tb = new TextButton(new Vector2((UIScaler.GetWidthUnits() - 10) / 2, 16), new Vector2(10, 2f), CommonStringKeys.CANCEL, delegate { Destroyer.Dialog(); });
        tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
        tb.SetFont(game.gameType.GetHeaderFont());
    }
Exemple #19
0
    // 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(); });
    }
Exemple #20
0
        // 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());
        }
Exemple #21
0
    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(); });
        }
    }
Exemple #22
0
    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());
    }
Exemple #23
0
    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 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();
    }
    // 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();
    }
Exemple #26
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
        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);
        }
    }
Exemple #27
0
    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 SelectItem(UnityEngine.Events.UnityAction call)
    {
        Destroyer.Dialog();
        cancelCall = call;

        DialogBox db = new DialogBox(new Vector2(21, 0), new Vector2(20, 26), "");

        db.AddBorder();

        db = new DialogBox(new Vector2(21, 0), new Vector2(20, 1), title);

        float      offset = 2;
        TextButton tb     = null;

        if (items.Length <= 20)
        {
            foreach (string s in items)
            {
                string key = s;
                tb = new TextButton(new Vector2(21, offset), new Vector2(20, 1), key, delegate { SelectComponent(key); });
                tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
                offset += 1;
            }
            offset += 1;
            tb      = new TextButton(new Vector2(26.5f, offset), new Vector2(9, 1), "Cancel", call);
            tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
        }
        else
        {
            for (int i = indexOffset; i < (20 + indexOffset); i++)
            {
                if (items.Length > i)
                {
                    string key = items[i];
                    tb = new TextButton(new Vector2(21, offset), new Vector2(20, 1), key, delegate { SelectComponent(key); });
                    tb.button.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetSmallFont();
                }
                offset += 1;
            }
            offset += 1;
            tb      = new TextButton(new Vector2(22f, offset), new Vector2(1, 1), "<", delegate { PreviousPage(); });
            tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
            tb = new TextButton(new Vector2(39f, offset), new Vector2(1, 1), ">", delegate { NextPage(); });
            tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(0.03f, 0.0f, 0f);
            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
            offset += 1;
            tb      = new TextButton(new Vector2(26.5f, offset), new Vector2(9, 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();
        }
    }
Exemple #29
0
    // List of quests to copy
    public void Copy()
    {
        // Can copy all quests, not just user
        questList = QuestLoader.GetQuests();
        Game game = Game.Get();

        foreach (GameObject go in GameObject.FindGameObjectsWithTag("dialog"))
        {
            Object.Destroy(go);
        }

        // Header
        DialogBox db = new DialogBox(new Vector2(2, 1), new Vector2(UIScaler.GetWidthUnits() - 4, 3), "Select " + game.gameType.QuestName() + " To Copy");

        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetLargeFont();
        db.SetFont(Game.Get().gameType.GetHeaderFont());

        db = new DialogBox(new Vector2(1, 5f), new Vector2(UIScaler.GetWidthUnits() - 2f, 21f), "");
        db.AddBorder();
        db.background.AddComponent <UnityEngine.UI.Mask>();
        UnityEngine.UI.ScrollRect scrollRect = db.background.AddComponent <UnityEngine.UI.ScrollRect>();

        GameObject    scrollArea      = new GameObject("scroll");
        RectTransform scrollInnerRect = scrollArea.AddComponent <RectTransform>();

        scrollArea.transform.parent = db.background.transform;
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, (UIScaler.GetWidthUnits() - 3f) * UIScaler.GetPixelsPerUnit());
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, 1);

        scrollRect.content    = scrollInnerRect;
        scrollRect.horizontal = false;

        // List of quests
        int        offset = 5;
        TextButton tb;

        foreach (KeyValuePair <string, QuestData.Quest> q in questList)
        {
            string key = q.Key;
            tb = new TextButton(new Vector2(2, offset), new Vector2(UIScaler.GetWidthUnits() - 5, 1.2f), "  " + q.Value.name, delegate { Copy(key); }, Color.black, offset);
            tb.button.GetComponent <UnityEngine.UI.Text>().fontSize   = UIScaler.GetSmallFont();
            tb.button.GetComponent <UnityEngine.UI.Text>().material   = (Material)Resources.Load("Fonts/FontMaterial");
            tb.button.GetComponent <UnityEngine.UI.Text>().alignment  = TextAnchor.MiddleLeft;
            tb.background.GetComponent <UnityEngine.UI.Image>().color = Color.white;
            tb.background.transform.parent = scrollArea.transform;
            offset += 2;
        }
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, 0, (offset - 5) * UIScaler.GetPixelsPerUnit());

        // Back to edit selection
        tb = new TextButton(new Vector2(1, UIScaler.GetBottom(-3)), new Vector2(8, 2), "Back", delegate { CancelCopy(); }, Color.red);
        tb.SetFont(Game.Get().gameType.GetHeaderFont());
    }
Exemple #30
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(); });
        }
    }