Ejemplo n.º 1
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
        TextButton tb   = null;
        float      hPos = UIScaler.GetHCenter(-13f);

        if (!puzzle.Solved())
        {
            for (int i = 1; i <= questPuzzle.puzzleAltLevel; i++)
            {
                int tmp = i;
                tb = new TextButton(new Vector2(hPos, 1.5f), new Vector2(2f, 2), i.ToString(), delegate { GuessAdd(tmp); }, Color.black);
                tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(1, 1, 1, (float)0.9);
                hPos += 2.5f;
            }
            hPos = UIScaler.GetHCenter(-13f);
            for (int i = 1; i <= questPuzzle.puzzleLevel; i++)
            {
                if (guess.Count >= i)
                {
                    int tmp = i - 1;
                    tb = new TextButton(new Vector2(hPos, 4f), new Vector2(2f, 2f), guess[tmp].ToString(), delegate { GuessRemove(tmp); }, Color.black);
                    tb.background.GetComponent <UnityEngine.UI.Image>().color = new Color(1, 1, 1, (float)0.9);
                }
                else
                {
                    db = new DialogBox(new Vector2(hPos, 4f), new Vector2(2f, 2), "", Color.white);
                    db.AddBorder();
                }
                hPos += 2.5f;
            }
        }

        new TextButton(new Vector2(UIScaler.GetHCenter(), 2.75f), new Vector2(5f, 2f), "Guess", delegate { Guess(); });

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

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(8f), 4f), new Vector2(3f, 2f), EventManager.SymbolReplace(questPuzzle.skill));
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();

        // Guesses window
        db = new DialogBox(new Vector2(UIScaler.GetHCenter(-13.5f), 6.5f), new Vector2(27, 13f), "");
        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.Top, 0, (1 + (puzzle.guess.Count * 2.5f)) * UIScaler.GetPixelsPerUnit());
        scrollInnerRect.SetInsetAndSizeFromParentEdge(RectTransform.Edge.Left, 0, 27 * UIScaler.GetPixelsPerUnit());

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

        float vPos = 7f;

        foreach (PuzzleCode.CodeGuess g in puzzle.guess)
        {
            hPos = UIScaler.GetHCenter(-13f);
            foreach (int i in g.guess)
            {
                db = new DialogBox(new Vector2(hPos, vPos), new Vector2(2f, 2f), i.ToString(), Color.black, new Color(1, 1, 1, 0.9f));
                db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial");
                db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
                db.background.transform.parent = scrollArea.transform;
                db.AddBorder();
                hPos += 2.5f;
            }

            hPos = UIScaler.GetHCenter();
            for (int i = 0; i < g.CorrectSpot(); i++)
            {
                db = new DialogBox(new Vector2(hPos, vPos), new Vector2(2f, 2f), "", Color.black, new Color(1, 1, 1, 0.9f));
                db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial");
                db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
                db.background.transform.parent = scrollArea.transform;
                db.AddBorder();
                hPos += 2.5f;
            }
            for (int i = 0; i < g.CorrectType(); i++)
            {
                db = new DialogBox(new Vector2(hPos, vPos), new Vector2(2f, 2f), "", Color.black, new Color(1, 1, 1, 0.9f));
                db.textObj.GetComponent <UnityEngine.UI.Text>().material = (Material)Resources.Load("Fonts/FontMaterial");
                db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
                db.background.transform.parent = scrollArea.transform;
                db.AddBorder();
                hPos += 2.5f;
            }
            vPos += 2.5f;
        }
        scrollRect.verticalNormalizedPosition = 0f;

        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.guess.Count - 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.guess.Count.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);
        }
    }
Ejemplo n.º 2
0
    public void CreateWindow()
    {
        Destroyer.Dialog();
        UIElement ui = new UIElement();

        ui.SetLocation(UIScaler.GetHCenter(-14f), 0.5f, 28, 22);
        new UIElementBorder(ui);

        // Puzzle goes here
        float hPos = UIScaler.GetHCenter(-13f);

        if (!puzzle.Solved())
        {
            for (int i = 1; i <= questPuzzle.puzzleAltLevel; i++)
            {
                int tmp = i;
                ui = new UIElement();
                ui.SetLocation(hPos, 1.5f, 2, 2);
                ui.SetText(buttons[i].label, Color.black);
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetButton(delegate { GuessAdd(tmp); });
                ui.SetImage(buttons[i].image);
                ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                hPos += 2.5f;
            }
            hPos = UIScaler.GetHCenter(-13f);
            for (int i = 1; i <= questPuzzle.puzzleLevel; i++)
            {
                if (guess.Count >= i)
                {
                    int tmp = i - 1;
                    ui = new UIElement();
                    ui.SetLocation(hPos, 4, 2, 2);
                    ui.SetText(buttons[guess[tmp]].label, Color.black);
                    ui.SetFontSize(UIScaler.GetMediumFont());
                    ui.SetButton(delegate { GuessRemove(tmp); });
                    ui.SetImage(buttons[guess[tmp]].image);
                    ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                }
                else
                {
                    ui = new UIElement();
                    ui.SetLocation(hPos, 4, 2, 2);
                    new UIElementBorder(ui);
                }
                hPos += 2.5f;
            }
        }

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(), 2.75f, 5, 2);
        ui.SetText(PUZZLE_GUESS);
        ui.SetFontSize(UIScaler.GetMediumFont());
        ui.SetButton(Guess);
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(6.5f), 1.5f, 6, 2);
        ui.SetText(new StringKey("val", "X_COLON", CommonStringKeys.SKILL));
        ui.SetFontSize(UIScaler.GetMediumFont());

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(8), 4, 3, 2);
        ui.SetText(EventManager.OutputSymbolReplace(questPuzzle.skill));
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui);

        // Guesses window
        UIElementScrollVertical scrollArea = new UIElementScrollVertical();

        scrollArea.SetLocation(UIScaler.GetHCenter(-13.5f), 6.5f, 27, 13f);
        new UIElementBorder(scrollArea);
        scrollArea.SetScrollSize(1 + (puzzle.guess.Count * 2.5f));

        float vPos = 0.5f;

        foreach (PuzzleCode.CodeGuess g in puzzle.guess)
        {
            hPos = 0.5f;
            foreach (int i in g.guess)
            {
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(hPos, vPos, 2, 2);
                ui.SetText(buttons[i].label, Color.black);
                ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetImage(buttons[i].image);
                new UIElementBorder(ui);
                hPos += 2.5f;
            }

            hPos = 13.25f;
            for (int i = 0; i < g.CorrectSpot(); i++)
            {
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(hPos, vPos, 2, 2);
                ui.SetText(ICON_SUCCESS_RESULT, Color.black);
                ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                ui.SetFontSize(UIScaler.GetMediumFont());
                new UIElementBorder(ui);
                hPos += 2.5f;
            }
            for (int i = 0; i < g.CorrectType(); i++)
            {
                ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(hPos, vPos, 2, 2);
                ui.SetText(ICON_INVESTIGATION_RESULT, Color.black);
                ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                ui.SetFontSize(UIScaler.GetMediumFont());
                new UIElementBorder(ui);
                hPos += 2.5f;
            }
            vPos += 2.5f;
        }
        scrollArea.SetScrollPosition(1 + (puzzle.guess.Count * 2.5f) * UIScaler.GetPixelsPerUnit());

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-11f), 20f, 6, 2);
        ui.SetText(new StringKey("val", "X_COLON", CommonStringKeys.MOVES));
        ui.SetFontSize(UIScaler.GetMediumFont());

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-5), 20, 3, 2);
        ui.SetText((puzzle.guess.Count - previousMoves).ToString());
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-2f), 20f, 10, 2);
        ui.SetText(new StringKey("val", "X_COLON", CommonStringKeys.TOTAL_MOVES));
        ui.SetFontSize(UIScaler.GetMediumFont());

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(8), 20, 3, 2);
        ui.SetText(puzzle.guess.Count.ToString());
        ui.SetFontSize(UIScaler.GetMediumFont());
        new UIElementBorder(ui);

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(-13), 23.5f, 8, 2);
        if (puzzle.Solved())
        {
            ui.SetText(CommonStringKeys.CLOSE, Color.grey);
            new UIElementBorder(ui, Color.grey);
        }
        else
        {
            ui.SetText(CommonStringKeys.CLOSE);
            new UIElementBorder(ui);
            ui.SetButton(Close);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());

        ui = new UIElement();
        ui.SetLocation(UIScaler.GetHCenter(5), 23.5f, 8, 2);
        if (!puzzle.Solved())
        {
            ui.SetText(eventData.GetButtons()[0].GetLabel(), Color.grey);
            new UIElementBorder(ui, Color.grey);
        }
        else
        {
            ui.SetText(eventData.GetButtons()[0].GetLabel());
            new UIElementBorder(ui);
            ui.SetButton(Finished);
        }
        ui.SetFontSize(UIScaler.GetMediumFont());
    }
Ejemplo n.º 3
0
    public void CreateWindow()
    {
        Destroyer.Dialog();
        DialogBox db = new DialogBox(
            new Vector2(UIScaler.GetHCenter(-14f), 0.5f), new Vector2(28f, 22f), StringKey.NULL);

        db.AddBorder();

        // Puzzle goes here
        TextButton tb   = null;
        float      hPos = UIScaler.GetHCenter(-13f);

        if (!puzzle.Solved())
        {
            for (int i = 1; i <= questPuzzle.puzzleAltLevel; i++)
            {
                int tmp = i;
                tb = new TextButton(
                    new Vector2(hPos, 1.5f), new Vector2(2f, 2), buttons[i].label, delegate { GuessAdd(tmp); }, Color.black);
                tb.background.GetComponent <UnityEngine.UI.Image>().color  = new Color(1, 1, 1, (float)0.9);
                tb.background.GetComponent <UnityEngine.UI.Image>().sprite = buttons[i].image;
                hPos += 2.5f;
            }
            hPos = UIScaler.GetHCenter(-13f);
            for (int i = 1; i <= questPuzzle.puzzleLevel; i++)
            {
                if (guess.Count >= i)
                {
                    int tmp = i - 1;
                    tb = new TextButton(
                        new Vector2(hPos, 4f), new Vector2(2f, 2f), buttons[guess[tmp]].label,
                        delegate { GuessRemove(tmp); }, Color.black);
                    tb.background.GetComponent <UnityEngine.UI.Image>().color  = new Color(1, 1, 1, (float)0.9);
                    tb.background.GetComponent <UnityEngine.UI.Image>().sprite = buttons[guess[tmp]].image;
                }
                else
                {
                    db = new DialogBox(new Vector2(hPos, 4f), new Vector2(2f, 2), StringKey.NULL, Color.white);
                    db.AddBorder();
                }
                hPos += 2.5f;
            }
        }

        new TextButton(new Vector2(UIScaler.GetHCenter(), 2.75f), new Vector2(5f, 2f), PUZZLE_GUESS, delegate { Guess(); });

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(6.5f), 1.5f), new Vector2(6f, 2f),
                           new StringKey("val", "X_COLON", CommonStringKeys.SKILL));
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(8f), 4f), new Vector2(3f, 2f),
                           new StringKey(null, EventManager.OutputSymbolReplace(questPuzzle.skill), false));
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();

        // Guesses window
        UIElementScrollVertical scrollArea = new UIElementScrollVertical();

        scrollArea.SetLocation(UIScaler.GetHCenter(-13.5f), 6.5f, 27, 13f);
        new UIElementBorder(scrollArea);
        scrollArea.SetScrollSize(1 + (puzzle.guess.Count * 2.5f));

        float vPos = 0.5f;

        foreach (PuzzleCode.CodeGuess g in puzzle.guess)
        {
            hPos = 0.5f;
            foreach (int i in g.guess)
            {
                UIElement ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(hPos, vPos, 2, 2);
                ui.SetText(buttons[i].label, Color.black);
                ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                ui.SetFontSize(UIScaler.GetMediumFont());
                ui.SetImage(buttons[i].image);
                new UIElementBorder(ui);
                hPos += 2.5f;
            }

            hPos = 13.25f;
            for (int i = 0; i < g.CorrectSpot(); i++)
            {
                UIElement ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(hPos, vPos, 2, 2);
                ui.SetText(ICON_SUCCESS_RESULT, Color.black);
                ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                ui.SetFontSize(UIScaler.GetMediumFont());
                new UIElementBorder(ui);
                hPos += 2.5f;
            }
            for (int i = 0; i < g.CorrectType(); i++)
            {
                UIElement ui = new UIElement(scrollArea.GetScrollTransform());
                ui.SetLocation(hPos, vPos, 2, 2);
                ui.SetText(ICON_INVESTIGATION_RESULT, Color.black);
                ui.SetBGColor(new Color(1, 1, 1, 0.9f));
                ui.SetFontSize(UIScaler.GetMediumFont());
                new UIElementBorder(ui);
                hPos += 2.5f;
            }
            vPos += 2.5f;
        }
        scrollArea.SetScrollPosition(1 + (puzzle.guess.Count * 2.5f) * UIScaler.GetPixelsPerUnit());

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(-11f), 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(-5f), 20f), new Vector2(3f, 2f), puzzle.guess.Count - previousMoves);
        db.textObj.GetComponent <UnityEngine.UI.Text>().fontSize = UIScaler.GetMediumFont();
        db.AddBorder();

        db = new DialogBox(new Vector2(UIScaler.GetHCenter(-2f), 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(8f), 20f), new Vector2(3f, 2f), puzzle.guess.Count);
        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), 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);
        }
    }