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(); });
    }
Beispiel #2
0
    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);
        }
    }
Beispiel #3
0
 public static void MonsterDamageInc(Quest.Monster monster, UnityEngine.Events.UnityAction call)
 {
     monster.damage += 1;
     if (monster.damage > monster.GetHealth())
     {
         monster.damage = monster.GetHealth();
     }
     call();
 }
Beispiel #4
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 #5
0
    public void Draw()
    {
        Destroyer.Dialog();
        UIElement ui = new UIElement();

        ui.SetLocation(10, 0.5f, UIScaler.GetWidthUnits() - 20, 8);
        ui.SetText(text);
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-6f), 9, 12, 2);
        if (m.damage == m.GetHealth())
        {
            ui.SetText(CommonStringKeys.FINISHED, Color.grey);
            new UIElementBorder(ui, Color.grey);
        }
        else
        {
            ui.SetText(CommonStringKeys.FINISHED);
            ui.SetButton(Destroyer.Dialog);
            new UIElementBorder(ui);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());

        MonsterDialogMoM.DrawMonster(m);
        MonsterDialogMoM.DrawMonsterHealth(m, delegate { Draw(); });
    }
Beispiel #6
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(); });
    }
    public void Draw()
    {
        Destroyer.Dialog();
        DialogBox db = new DialogBox(new Vector2(10, 0.5f), new Vector2(UIScaler.GetWidthUnits() - 20, 8),
                                     new StringKey(null, text, false));

        db.AddBorder();

        if (m.damage == m.GetHealth())
        {
            new TextButton(new Vector2(UIScaler.GetHCenter(-6f), 9f), new Vector2(12, 2), CommonStringKeys.FINISHED, delegate {; }, Color.gray);
        }
        else
        {
            new TextButton(new Vector2(UIScaler.GetHCenter(-6f), 9f), new Vector2(12, 2), CommonStringKeys.FINISHED, delegate { Destroyer.Dialog(); });
        }

        MonsterDialogMoM.DrawMonster(m);
        MonsterDialogMoM.DrawMonsterHealth(m, delegate { Draw(); });
    }
Beispiel #8
0
    public void Draw()
    {
        Destroyer.Dialog();
        UIElement ui = new UIElement();

        ui.SetLocation(10, 0.5f, UIScaler.GetWidthUnits() - 20, 8);
        ui.SetText(text);
        new UIElementBorder(ui);

        if (m.damage == m.GetHealth())
        {
            new TextButton(new Vector2(UIScaler.GetHCenter(-6f), 9f), new Vector2(12, 2), CommonStringKeys.FINISHED, delegate {; }, Color.gray);
        }
        else
        {
            new TextButton(new Vector2(UIScaler.GetHCenter(-6f), 9f), new Vector2(12, 2), CommonStringKeys.FINISHED, delegate { Destroyer.Dialog(); });
        }

        MonsterDialogMoM.DrawMonster(m);
        MonsterDialogMoM.DrawMonsterHealth(m, delegate { Draw(); });
    }
Beispiel #9
0
        // Draw monster if in scroll range (offset is scroll position)
        public void Draw(int offset)
        {
            float top_position_y = 4.3f; //3.75
            float offset_y       = 4.4f; // 4.5

            // Check if in scroll range
            if (index < offset)
            {
                return;
            }
            if (index > offset + 4)
            {
                return;
            }

            GameObject mImg = new GameObject("monsterImg" + m.monsterData.name);

            mImg.tag = Game.MONSTERS;
            mImg.transform.SetParent(game.uICanvas.transform);

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

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (top_position_y + ((index - offset) * offset_y)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            mImg.AddComponent <CanvasRenderer>();

            icon        = mImg.AddComponent <UnityEngine.UI.Image>();
            icon.sprite = iconSprite;
            icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

            UnityEngine.UI.Button button = mImg.AddComponent <UnityEngine.UI.Button>();
            button.interactable = true;
            button.onClick.AddListener(delegate { MonsterDiag(); });

            iconFrame = null;
            if (game.gameType is D2EGameType)
            {
                icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f, monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f);
                GameObject mImgFrame = new GameObject("monsterFrame" + m.monsterData.name);
                mImgFrame.tag = Game.MONSTERS;
                mImgFrame.transform.SetParent(game.uICanvas.transform);

                RectTransform transFrame = mImgFrame.AddComponent <RectTransform>();
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (top_position_y + ((index - offset) * offset_y)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                mImgFrame.AddComponent <CanvasRenderer>();

                iconFrame        = mImgFrame.AddComponent <UnityEngine.UI.Image>();
                iconFrame.sprite = frameSprite;
                iconFrame.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

                UnityEngine.UI.Button buttonFrame = mImgFrame.AddComponent <UnityEngine.UI.Button>();
                buttonFrame.interactable = true;
                buttonFrame.onClick.AddListener(delegate { MonsterDiag(); });

                if (m.GetHealth() != 0)
                {
                    UIElement ui = new UIElement(Game.MONSTERS);
                    ui.SetLocation(UIScaler.GetRight(-2.25f), 5.75f + ((index - offset) * offset_y), 2, 2);
                    ui.SetText(m.GetHealth().ToString(), Color.red);
                    ui.SetFontSize(UIScaler.GetMediumFont());
                    ui.SetButton(MonsterDiag);
                    new UIElementBorder(ui, Color.red);
                }
            }
            else
            {
                // MoM
                if (game.quest.phase == Quest.MoMPhase.investigator)
                {
                    DrawAwareness(top_position_y + ((index - offset) * offset_y));
                }
                else
                {
                    DrawHorror(top_position_y + ((index - offset) * offset_y));
                }
            }

            iconDupe = null;
            if (duplicateSprite != null)
            {
                GameObject mImgDupe = new GameObject("monsterDupe" + m.monsterData.name);
                mImgDupe.tag = Game.MONSTERS;
                mImgDupe.transform.SetParent(game.uICanvas.transform);

                RectTransform dupeFrame = mImgDupe.AddComponent <RectTransform>();
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, ((monsterSize / 2f) + top_position_y + ((index - offset) * offset_y)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 2.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                mImgDupe.AddComponent <CanvasRenderer>();

                iconDupe        = mImgDupe.AddComponent <UnityEngine.UI.Image>();
                iconDupe.sprite = duplicateSprite;
                iconDupe.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() / 2f, monsterSize * UIScaler.GetPixelsPerUnit() / 2f);

                UnityEngine.UI.Button buttonDupe = mImgDupe.AddComponent <UnityEngine.UI.Button>();
                buttonDupe.interactable = true;
                buttonDupe.onClick.AddListener(delegate { MonsterDiag(); });
            }

            Update();
        }
Beispiel #10
0
        // Draw monster if in scroll range (offset is scroll position)
        public void Draw(int offset)
        {
            // Check if in scroll range
            if (index < offset)
            {
                return;
            }
            if (index > offset + 4)
            {
                return;
            }

            GameObject mImg = new GameObject("monsterImg" + m.monsterData.name);

            mImg.tag = Game.MONSTERS;
            mImg.transform.SetParent(game.uICanvas.transform);

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

            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            trans.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
            mImg.AddComponent <CanvasRenderer>();

            icon        = mImg.AddComponent <UnityEngine.UI.Image>();
            icon.sprite = iconSprite;
            icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

            UnityEngine.UI.Button button = mImg.AddComponent <UnityEngine.UI.Button>();
            button.interactable = true;
            button.onClick.AddListener(delegate { MonsterDiag(); });

            iconFrame = null;
            if (game.gameType is D2EGameType)
            {
                icon.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f, monsterSize * UIScaler.GetPixelsPerUnit() * 0.83f);
                GameObject mImgFrame = new GameObject("monsterFrame" + m.monsterData.name);
                mImgFrame.tag = Game.MONSTERS;
                mImgFrame.transform.SetParent(game.uICanvas.transform);

                RectTransform transFrame = mImgFrame.AddComponent <RectTransform>();
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, (3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                transFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());
                mImgFrame.AddComponent <CanvasRenderer>();

                iconFrame        = mImgFrame.AddComponent <UnityEngine.UI.Image>();
                iconFrame.sprite = frameSprite;
                iconFrame.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit());

                UnityEngine.UI.Button buttonFrame = mImgFrame.AddComponent <UnityEngine.UI.Button>();
                buttonFrame.interactable = true;
                buttonFrame.onClick.AddListener(delegate { MonsterDiag(); });

                if (m.GetHealth() != 0)
                {
                    TextButton tb = new TextButton(
                        new Vector2(UIScaler.GetRight(-2.25f), 5.75f + ((index - offset) * 4.5f)), new Vector2(2, 2),
                        new StringKey(null, m.GetHealth().ToString(), false),
                        delegate { MonsterDiag(); }, Color.red);
                    tb.ApplyTag(Game.MONSTERS);
                }
            }

            iconDupe = null;
            if (duplicateSprite != null)
            {
                GameObject mImgDupe = new GameObject("monsterDupe" + m.monsterData.name);
                mImgDupe.tag = Game.MONSTERS;
                mImgDupe.transform.SetParent(game.uICanvas.transform);

                RectTransform dupeFrame = mImgDupe.AddComponent <RectTransform>();
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Top, ((monsterSize / 2f) + 3.75f + ((index - offset) * 4.5f)) * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                dupeFrame.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Right, 0.25f * UIScaler.GetPixelsPerUnit(), monsterSize * UIScaler.GetPixelsPerUnit() / 2f);
                mImgDupe.AddComponent <CanvasRenderer>();

                iconDupe        = mImgDupe.AddComponent <UnityEngine.UI.Image>();
                iconDupe.sprite = duplicateSprite;
                iconDupe.rectTransform.sizeDelta = new Vector2(monsterSize * UIScaler.GetPixelsPerUnit() / 2f, monsterSize * UIScaler.GetPixelsPerUnit() / 2f);

                UnityEngine.UI.Button buttonDupe = mImgDupe.AddComponent <UnityEngine.UI.Button>();
                buttonDupe.interactable = true;
                buttonDupe.onClick.AddListener(delegate { MonsterDiag(); });
            }

            Update();
        }