Esempio n. 1
0
    /// <summary>
    /// Scales str's fontSize [0, 9].
    /// </summary>
    /// <returns>True if button was clicked.</returns>
    public static bool pulseBtn(string str, int fontSize, float x, float y, EZOpt?opt = null)
    {
        EZOpt e = opt ?? new EZOpt();

        GUIObject g       = getGUIObject(str, fontSize, x, y, e);
        bool      isHover = checkMouse(g, e.hoverColor, e.activeColor) == 1;

        if (!isHover)
        {
            float pp = Mathf.PingPong(Time.time, 0.9f);
            pp       *= 10;
            fontSize += (int)pp;

            g = getGUIObject(str, fontSize, x, y, e);
        }
        else
        {
            fontSize += 9;              // make text fullsize on hover

            g = getGUIObject(str, fontSize, x, y, e);

            if (e.activeColor != null && Input.GetMouseButton(0))
            {
                g.style.normal.textColor = (Color)e.activeColor;
            }
            else
            {
                g.style.normal.textColor = (Color)e.hoverColor;
            }
        }

        addDropShadow(g, e);

        return(GUI.Button(g.rect, g.cnt, g.style));
    }
Esempio n. 2
0
    public static bool placeWindow(string str, int fontSize, float x, float y, int height, GUI.WindowFunction cb, Color bgColor, EZOpt?opt = null)
    {
        EZOpt     e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        GUI.backgroundColor = bgColor;
        //GUI.contentColor = e.color ?? Color.white;

        GUIStyle style = new GUIStyle(GUI.skin.window);

        style.fontSize         = g.style.fontSize;
        style.normal.textColor = g.style.normal.textColor;

        style.onActive.textColor  = style.normal.textColor;
        style.active.textColor    = style.normal.textColor;
        style.onActive.background = style.onNormal.background;
        style.active.background   = style.onNormal.background;


        GUI.Window(0, new Rect(x, y, height, height), cb, str, style);        //, g.style);

        EZButton b = placeBtn("Close", 25, x + height, y, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), new Color(0.1f, 0.1f, 0.1f)));

        return(b.btn);
    }
Esempio n. 3
0
    void windowCallback(int windowID)
    {
        EZOpt e = new EZOpt();
        e.leftJustify = true;

        EZGUI.placeTxt("Username: freeCode", 28, 20, 100, e);
        EZGUI.placeTxt("# Kills: 100", 28, 20, 140, e);
        EZGUI.placeTxt("Perk: Invisibility", 28, 20, 180, e);
    }
Esempio n. 4
0
    void OnGUI()
    {
        if(gs != gameState.leaderboard && gs != gameState.highscore){
            return;
        }

        EZGUI.init();

        float startX = 222 + 30;
        float startY = 265;

        EZGUI.drawBox(startX - 30, 90, 1500, 900, new Color(0.09f, 0.09f, 0.09f, 0.44f));

        EZOpt e = new EZOpt();
        e.dropShadow = new Color(0.1f, 0.1f, 0.1f);
        e.leftJustify = false;

        e.font = GLOBAL.spookyMagic;

        if(gs == gameState.leaderboard){
            EZGUI.placeTxt("Leaderboard", 50, EZGUI.HALFW, 190, e);
            e.font = arial;
            e.leftJustify = true;

            if(PhotonNetwork.playerList.Length > 0) {
                printPlayers(startX, startY, e);
            }
            else {
                e.color = new Color(0.95f, 0.95f, 0.95f);
                EZGUI.placeTxt("-No Entries-", 35, startX, startY, e);
            }

            e.color = new Color(0.95f, 0.95f, 0.95f);
            if(GLOBAL.gameOver){
                e.leftJustify = false;
                EZGUI.pulseTxt("Press \"x\" to continue", 36, EZGUI.HALFW, 990 - 28, e);
            }
            else {
                EZGUI.placeTxt("Press \"□\" for high scores", 36, startX, 990 - 100, e);
                EZGUI.placeTxt("Press \"△\" for start screen", 36, startX, 990 - 60, e);
                EZGUI.placeTxt("Press \"○\" to quit game", 36, startX, 990 - 20, e);
            }
        }
        else {//if(gs == gameState.highscore)
            EZGUI.placeTxt("High Scores", 50, EZGUI.HALFW, 190, e);
            e.font = arial;
            e.leftJustify = true;

            printHighScores(startX + 75, startY, e);

            e.color = new Color(0.95f, 0.95f, 0.95f);
            e.leftJustify = false;

            EZGUI.pulseTxt("Press \"x\" for start screen", 36, EZGUI.HALFW + 300, EZGUI.HALFH - 100, e);
            EZGUI.placeTxt("Press \"○\" for leaderboard", 36, EZGUI.HALFW + 300, EZGUI.HALFH - 50, e);
        }
    }
Esempio n. 5
0
    /// <summary>
    /// Draws str with center at (x, y).
    /// </summary>
    public static void placeTxt(string str, int fontSize, float x, float y, EZOpt?opt = null)
    {
        EZOpt     e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        addDropShadow(g, e);

        GUI.Label(g.rect, g.cnt, g.style);
    }
Esempio n. 6
0
    void OnGUI()
    {
        EZGUI.init();

        if(EZGUI.placeBtn("Back", 45, 85, 85, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), drp)).btn || Input.GetKeyDown(KeyCode.Backspace)) {
            Application.LoadLevel("title");
        }

        int fSize = 43;

        //--- Label
        EZOpt titleOpt = new EZOpt(Color.green, drp);
        titleOpt.italic = true;
        titleOpt.bold = true;
        EZGUI.placeTxt("GUI.Label", fSize, 250, 300, titleOpt);

        EZOpt lblOpt = new EZOpt(Color.green, drp);
        EZGUI.placeTxt("Place Text", fSize, 250, 400, lblOpt);
        EZGUI.flashTxt("Flash Text", fSize, 250, 500, lblOpt);
        EZGUI.blinkTxt("Blink Text", fSize, 250, 600, lblOpt);
        EZGUI.pulseTxt("Pulse Text", fSize, 250, 700, lblOpt);

        //--- Button
        titleOpt.color = Color.red;
        EZGUI.placeTxt("GUI.Button", fSize, 650, 300, titleOpt);

        EZOpt btnOpt = new EZOpt(Color.red, Color.yellow, btnActive, drp);
        EZGUI.placeBtn("Place Button", fSize, 650, 400, btnOpt);
        EZGUI.flashBtn("Flash Button", fSize, 650, 500, btnOpt);
        EZGUI.blinkBtn("Blink Button", fSize, 650, 600, btnOpt);
        EZGUI.pulseBtn("Pulse Button", fSize, 650, 700, btnOpt);

        //--- Wrap
        titleOpt.leftJustify = true;
        titleOpt.color = new Color(0.8f, 0.8f, 0.8f);
        EZGUI.placeTxt("wrapTxt()", fSize, 920, 300, titleOpt);

        EZGUI.wrapTxt("By specifying a width, the text will wrap automatically when over a certain width.  NOTE: text is left justified and top aligned.",
            fSize,
            920,
            350,
            400,
            new EZOpt((Color)titleOpt.color, drp)
        );

        //--- Window
        EZGUI.placeTxt("GUI.Window", fSize, 1600, 300, new EZOpt(Color.cyan, drp));

        if(windowClosed){
            windowOpen = EZGUI.placeBtn("Open Window", fSize, 1600, 500, new EZOpt(Color.cyan, new Color(0, 0.9f, 0.9f), new Color(0, 0.8f, 0.8f), drp)).btn;
        }

        if(windowOpen) {
            windowClosed = EZGUI.placeWindow("Player Info", 30, 1450, 375, 300, windowCallback, Color.black, new EZOpt(Color.cyan));
        }
    }
Esempio n. 7
0
    void windowCallback(int windowID)
    {
        EZOpt e = new EZOpt();

        e.leftJustify = true;

        EZGUI.placeTxt("Username: freeCode", 28, 20, 100, e);
        EZGUI.placeTxt("# Kills: 100", 28, 20, 140, e);
        EZGUI.placeTxt("Perk: Invisibility", 28, 20, 180, e);
    }
Esempio n. 8
0
    /// <summary>
    /// Draws str with center at (x, y).
    /// </summary>
    /// <returns>True if button was clicked.</returns>
    public static EZButton placeBtn(string str, int fontSize, float x, float y, EZOpt?opt = null)
    {
        EZOpt     e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        int cm = checkMouse(g, e.hoverColor, e.activeColor);

        addDropShadow(g, e);

        return(new EZButton(GUI.Button(g.rect, g.cnt, g.style), cm == 1, cm == 2));
    }
Esempio n. 9
0
    void instructions()
    {
        if(EZGUI.pulseBtn("Back", 52, 85, 85, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), drp)) || Input.GetKeyDown(KeyCode.Backspace)) {
            state = select;
        }

        EZOpt opt = new EZOpt();
        opt.leftJustify = true;

        EZGUI.placeTxt("Pressing Back will activate the \"Back\" button.", 42, 50, EZGUI.HALFH - 100, opt);
        EZGUI.placeTxt("Pressing Enter will activate the will activate the \"Press Start\" button.", 42, 50, EZGUI.HALFH, opt);
    }
Esempio n. 10
0
    void OnGUI()
    {
        if(delayTimer < delayTimerInit){
            EZGUI.init();

            EZOpt e = new EZOpt(Color.red, new Color(0.1f, 0.1f, 0.1f));
            e.dropShadowX = e.dropShadowY = 1;
            e.font = GLOBAL.spookyMagic;

            EZGUI.placeTxt("cooldown " + (delayTimerInit/cooldownResolution - (delayTimer / cooldownResolution)) + "s", 25, EZGUI.FULLW - 170, 130, e);
            EZGUI.drawBox(EZGUI.FULLW - 225, 130, 200 * ((float)(delayTimerInit - delayTimer) / (float)delayTimerInit), 20, new Color(1f, 0f, 0f, 1f));
        }
    }
Esempio n. 11
0
    void instructions()
    {
        if (EZGUI.pulseBtn("Back", 52, 85, 85, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), drp)) || Input.GetKeyDown(KeyCode.Backspace))
        {
            state = select;
        }

        EZOpt opt = new EZOpt();

        opt.leftJustify = true;

        EZGUI.placeTxt("Pressing Back will activate the \"Back\" button.", 42, 50, EZGUI.HALFH - 100, opt);
        EZGUI.placeTxt("Pressing Enter will activate the will activate the \"Press Start\" button.", 42, 50, EZGUI.HALFH, opt);
    }
Esempio n. 12
0
    /// <summary>
    /// Fades str in and out.
    /// </summary>
    public static void blinkTxt(string str, int fontSize, float x, float y, EZOpt?opt = null)
    {
        EZOpt     e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        Color c = g.style.normal.textColor;

        c.a = Mathf.PingPong(Time.time, 1);
        g.style.normal.textColor = c;

        addDropShadow(g, e);

        GUI.Label(g.rect, g.cnt, g.style);
    }
Esempio n. 13
0
    /// <summary>
    /// Turns str's alpha value on and off.
    /// </summary>
    /// <returns>True if button was clicked.</returns>
    public static bool flashBtn(string str, int fontSize, float x, float y, EZOpt?opt = null)
    {
        EZOpt     e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        Color c = g.style.normal.textColor;

        c.a = (Time.time % 2 < 1) ? 1 : 0;
        g.style.normal.textColor = c;

        checkMouse(g, e.hoverColor, e.activeColor);
        addDropShadow(g, e);

        return(GUI.Button(g.rect, g.cnt, g.style));
    }
Esempio n. 14
0
    /// <summary>
    /// Scales str's fontSize [0, 9].
    /// </summary>
    public static void pulseTxt(string str, int fontSize, float x, float y, EZOpt?opt = null)
    {
        EZOpt e = opt ?? new EZOpt();

        float pp = Mathf.PingPong(Time.time, 0.9f);

        pp       *= 10;
        fontSize += (int)pp;

        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        addDropShadow(g, e);

        GUI.Label(g.rect, g.cnt, g.style);
    }
Esempio n. 15
0
    static void addDropShadow(GUIObject g, EZOpt e)
    {
        if (e.dropShadow != null && g.style.normal.textColor.a != 0)
        {
            Color prevColor = g.style.normal.textColor;

            Color ds = (Color)e.dropShadow;
            ds.a = prevColor.a;
            g.style.normal.textColor = ds;

            GUI.Label(new Rect(g.rect.x + e.dropShadowX, g.rect.y + e.dropShadowY, g.rect.width, g.rect.height), g.cnt, g.style);

            g.style.normal.textColor = prevColor;
        }
    }
Esempio n. 16
0
    void select()
    {
        EZOpt opt = new EZOpt(Color.white, Color.green, new Color(0,0.9f, 0), drp);

        if(EZGUI.placeBtn("Campaign", 55, EZGUI.HALFW, EZGUI.HALFH - 100, opt).btn) {
            Application.LoadLevel("main");
        }

        if(EZGUI.placeBtn("Instructions", 55, EZGUI.HALFW, EZGUI.HALFH, opt).btn) {
            state = instructions;
        }

        if(EZGUI.placeBtn("Back", 55, EZGUI.HALFW, EZGUI.HALFH + 100, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), drp)).btn || Input.GetKeyDown(KeyCode.Backspace)) {
            state = start;
        }
    }
    void OnGUI()
    {
        EZGUI.init();
        EZOpt e = new EZOpt(Color.cyan, new Color(0.1f, 0.1f, 0.1f));
        e.font = GLOBAL.spookyMagic;
        e.dropShadowX = 1;

        // forcefield is active
        if(spellDurationLeft > 0){
            EZGUI.drawBox(0, 0, EZGUI.FULLW, EZGUI.FULLH, new Color(0, 0.9f + Mathf.PingPong(Time.time/2, 0.1f), 0, 0.175f));
            EZGUI.placeTxt("time remaining: " + spellDurationLeft + "s", 25, EZGUI.FULLW - 230, 130, e);
            EZGUI.drawBox(EZGUI.FULLW - 225, 130, 200 * ((SPELL_DURATION - spellDurationLeft) / SPELL_DURATION), 20, (Color)e.color);
        }
        else if(!canFire && cooldownTimeLeft != COOLDOWN_TIME){
            e.color = Color.red;
            EZGUI.placeTxt("cooldown: " + cooldownTimeLeft + "s", 25, EZGUI.FULLW - 170, 130, e);
            EZGUI.drawBox(EZGUI.FULLW - 225, 130, 200 * ((COOLDOWN_TIME - cooldownTimeLeft) / COOLDOWN_TIME), 20, (Color)e.color);
        }
    }
Esempio n. 18
0
    void select()
    {
        EZOpt opt = new EZOpt(Color.white, Color.green, new Color(0, 0.9f, 0), drp);

        if (EZGUI.placeBtn("Campaign", 55, EZGUI.HALFW, EZGUI.HALFH - 100, opt).btn)
        {
            Application.LoadLevel("main");
        }

        if (EZGUI.placeBtn("Instructions", 55, EZGUI.HALFW, EZGUI.HALFH, opt).btn)
        {
            state = instructions;
        }

        if (EZGUI.placeBtn("Back", 55, EZGUI.HALFW, EZGUI.HALFH + 100, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), drp)).btn || Input.GetKeyDown(KeyCode.Backspace))
        {
            state = start;
        }
    }
    void OnGUI()
    {
        EZGUI.init();

        for(int i = 0; i < PlayerThingsToDisplay.Count; i++)
        {
            List<string> currentThingList = PlayerThingsToDisplay[i]();

            for(int j = 0; j < currentThingList.Count; j++)
            {
                string thingToDisplay = currentThingList[j];
                //GUI.Label(new Rect(10, i * 20 + j * 20 + 200, 999, 20), thingToDisplay);
                EZOpt e = new EZOpt(Color.white, new Color(0.1f, 0.1f, 0.1f));
                e.leftJustify = true;
                e.dropShadowX = e.dropShadowY = 1;
                EZGUI.placeTxt(thingToDisplay, 23, 10, i * 31 + j * 31 + 33, e);
            }
        }
    }
Esempio n. 20
0
    /// <summary>
    /// Str will wrap to fit in width.  NOTE: text is left justified and top aligned (this includes placement)
    /// </summary>
    public static void wrapTxt(string str, int fontSize, float x, float y, float width, EZOpt?opt = null)
    {
        EZOpt     e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        GUIStyle style = new GUIStyle(GUI.skin.label);

        style.fontSize         = g.style.fontSize;
        style.normal.textColor = g.style.normal.textColor;


        // drop shadow
        if (e.dropShadow != null)
        {
            GUIStyle drpStyle = new GUIStyle(style);
            drpStyle.normal.textColor = (Color)e.dropShadow;

            GUI.Label(new Rect(x + e.dropShadowX, y + e.dropShadowY, width, FULLH), str, drpStyle);
        }

        GUI.Label(new Rect(x, y, width, FULLH), str, style);
    }
Esempio n. 21
0
    static GUIObject getGUIObject(string str, int fontSize, float x, float y, EZOpt e)
    {
        GUIObject gObj = new GUIObject();

        gObj.cnt = new GUIContent(str);

        gObj.style = new GUIStyle();
        if (e.font)
        {
            gObj.style.font = e.font;
        }

        gObj.style.fontSize         = fontSize;
        gObj.style.normal.textColor = e.color ?? Color.white;

        gObj.size = gObj.style.CalcSize(gObj.cnt);
        gObj.rect = new Rect(x - gObj.size.x / 2, y - gObj.size.y, gObj.size.x, gObj.size.y);

        if (e.leftJustify)
        {
            gObj.rect.x += gObj.rect.width / 2;
        }

        if (e.italic && e.bold)
        {
            gObj.style.fontStyle = FontStyle.BoldAndItalic;
        }
        else if (e.italic)
        {
            gObj.style.fontStyle = FontStyle.Italic;
        }
        else if (e.bold)
        {
            gObj.style.fontStyle = FontStyle.Bold;
        }

        return(gObj);
    }
Esempio n. 22
0
    void printHighScores(float startX, float startY, EZOpt e)
    {
        int lineHeight = 41;

        EZOpt titleOpt = e;
        titleOpt.color = Color.cyan;

        //--- best individual
        EZGUI.placeTxt("-Best Individual Score-", 35, startX, startY, titleOpt);

        string bestIndividualName = PlayerPrefs.GetString("BestIndividualName");
        if(String.IsNullOrEmpty(bestIndividualName)) {
            e.color = new Color(0.95f, 0.95f, 0.95f);
            EZGUI.placeTxt("-No Entry-", 35, startX + 100, startY + 240 + lineHeight*2, e);
        }
        else {
            EZGUI.placeTxt(bestIndividualName, 35, startX, startY + lineHeight, e);

            EZGUI.placeTxt(PlayerPrefs.GetInt("BestIndividualPoints") + " points", 35, startX + 50, startY + lineHeight*2, e);
            EZGUI.placeTxt(PlayerPrefs.GetInt("BestIndividualTeamPoints") + " team points", 35, startX + 50, startY + lineHeight*3, e);
            EZGUI.placeTxt(PlayerPrefs.GetInt("BestIndividualNum") + "th wave reached", 35, startX + 50, startY + lineHeight*4, e);
        }

        //--- best team
        EZGUI.placeTxt("-Best Team Score-", 35, startX, startY + 240, titleOpt);

        int bestTeam = PlayerPrefs.GetInt("BestTeam");
        //if(String.IsNullOrEmpty(bestTeam)){
        //	e.color = new Color(0.95f, 0.95f, 0.95f);
        //	EZGUI.placeTxt("-No Entry-", 35, startX + 50, startY + 240 + lineHeight, e);
        //}
        //else {
            EZGUI.placeTxt("Team Score: " + bestTeam + " points", 35, startX + 50, startY + 240 + lineHeight, e);
        //}

        // player 0
        string t0 = PlayerPrefs.GetString("BestTeamName_0");
        int t0Num = PlayerPrefs.GetInt("BestTeamScore_0");
        if(String.IsNullOrEmpty(t0)) {
            e.color = new Color(0.95f, 0.95f, 0.95f);
            EZGUI.placeTxt("-No Entry-", 35, startX + 100, startY + 240 + lineHeight*2, e);
        }
        else {
            EZGUI.placeTxt(t0 + ": " + t0Num + " points", 35, startX + 100, startY + 240 + lineHeight*2, e);
        }

        // player 1
        string t1 = PlayerPrefs.GetString("BestTeamName_1");
        int t1Num = PlayerPrefs.GetInt("BestTeamScore_1");
        if(String.IsNullOrEmpty(t1)) {
            e.color = new Color(0.95f, 0.95f, 0.95f);
            EZGUI.placeTxt("-No Entry-", 35, startX + 100, startY + 240 + lineHeight*3, e);
        }
        else {
            EZGUI.placeTxt(t1 + ": " + t1Num + " points", 35, startX + 100, startY + 240 + lineHeight*3, e);
        }

        // player 2
        string t2 = PlayerPrefs.GetString("BestTeamName_2");
        int t2Num = PlayerPrefs.GetInt("BestTeamScore_2");
        if(String.IsNullOrEmpty(t2)){
            e.color = new Color(0.95f, 0.95f, 0.95f);
            EZGUI.placeTxt("-No Entry-", 35, startX + 100, startY + 240 + lineHeight*4, e);
        }
        else {
            EZGUI.placeTxt(t2 + ": " + t2Num + " points", 35, startX + 100, startY + 240 + lineHeight*4, e);
        }

        // player 3
        string t3 = PlayerPrefs.GetString("BestTeamName_3");
        int t3Num = PlayerPrefs.GetInt("BestTeamScore_3");
        if(String.IsNullOrEmpty(t3)){
            e.color = new Color(0.95f, 0.95f, 0.95f);
            EZGUI.placeTxt("-No Entry-", 35, startX + 100, startY + 240 + lineHeight*5, e);
        }
        else {
            EZGUI.placeTxt(t3 + ": " + t3Num + " points", 35, startX + 100, startY + 240 + lineHeight*5, e);
        }

        //--- longest wave
        EZGUI.placeTxt("-Longest Wave Reached-", 35, startX, startY + 540, titleOpt);

        string longestWaveName = PlayerPrefs.GetString("LongestWaveName");
        int longestWaveNum = PlayerPrefs.GetInt("LongestWaveNum");
        if(String.IsNullOrEmpty(longestWaveName)){
            e.color = new Color(0.95f, 0.95f, 0.95f);
            EZGUI.placeTxt("-No Entry-", 35, startX + 50, startY + 540 + lineHeight, e);
        }
        else {
            EZGUI.placeTxt(longestWaveName + ": wave " + longestWaveNum + " reached", 35, startX + 50, startY + 540 + lineHeight, e);
        }
    }
    void OnGUI()
    {
        EZGUI.init();

        float startX = 222 + 30;
        float startY = 265;

        EZGUI.drawBox(-10, -10, 2000, 200, new Color(0, 0, 0, 1));
        EZGUI.drawBox(-10, -180 + EZGUI.FULLH, 2000, 200, new Color(0, 0, 0, 1));

        EZOpt e = new EZOpt();
        e.dropShadow = new Color(0.1f, 0.1f, 0.1f);
        e.leftJustify = false;

        e.font = SpookyMagic;

        EZGUI.placeTxt("Press \"Start\" to skip", 23, EZGUI.FULLW - 230, 100, e);
        EZGUI.placeTxt(message, 50, EZGUI.HALFW, EZGUI.FULLH - 60, e);
    }
Esempio n. 24
0
    static GUIObject getGUIObject(string str, int fontSize, float x, float y, EZOpt e)
    {
        GUIObject gObj = new GUIObject();

        gObj.cnt = new GUIContent(str);

        gObj.style = new GUIStyle();
        if(e.font) {
            gObj.style.font = e.font;
        }

        gObj.style.fontSize = fontSize;
        gObj.style.normal.textColor = e.color ?? Color.white;

        gObj.size = gObj.style.CalcSize(gObj.cnt);
        gObj.rect = new Rect(x - gObj.size.x/2, y - gObj.size.y, gObj.size.x, gObj.size.y);

        if(e.leftJustify){
            gObj.rect.x += gObj.rect.width/2;
        }

        if(e.italic && e.bold) {
            gObj.style.fontStyle = FontStyle.BoldAndItalic;
        }
        else if(e.italic) {
            gObj.style.fontStyle = FontStyle.Italic;
        }
        else if(e.bold) {
            gObj.style.fontStyle = FontStyle.Bold;
        }

        return gObj;
    }
Esempio n. 25
0
    void OnGUI()
    {
        EZGUI.init();

        EZOpt e = new EZOpt();
        e.font = spookyMagic;

        // title
        EZGUI.placeTxt("Defend Thy Kingdom", 90, EZGUI.HALFW, 220, e);

        // cta text
        EZGUI.drawBox(675, 440, 575, 180, new Color(0.3f, 0.3f, 0.3f, 0.6f));
        EZGUI.placeTxt("Enter your name: ", 45, EZGUI.HALFW, EZGUI.HALFH, e);

        e.hoverColor = Color.green;
        e.activeColor = new Color(0, 0.9f, 0);
        EZButton ezb = EZGUI.placeBtn("Press \"□\" for Credits", 40, EZGUI.HALFW, EZGUI.HALFW, e);
        if(ezb.btn) {
            initCredits();
        }

        // input box
        GUIStyle gs = new GUIStyle(GUI.skin.textField);
        gs.font = e.font;
        gs.fontSize = 27;
        gs.padding = new RectOffset(8, 5, 3, 4);

        if(!hitStart){
            BETWEEN_SCENES.player_name = GUI.TextField(new Rect(EZGUI.HALFW - 236, EZGUI.HALFH - 4, 350, 50), BETWEEN_SCENES.player_name, 18, gs);
        }
        else {
            e.color = Color.green;
            e.leftJustify = true;
            EZGUI.placeTxt(BETWEEN_SCENES.player_name, gs.fontSize, EZGUI.HALFW - 228, EZGUI.HALFH + 47, e);
        }
        e.leftJustify = false;

        // start button
        EZGUI.drawBox(EZGUI.HALFW + 135, EZGUI.HALFH - 4, 100, 50, btnColor);
        e.color = new Color(0.2f, 0.2f, 0.2f);

        if(!hitStart) {
            e.hoverColor = new Color(0.1f, 0.1f, 0.4f);
            e.activeColor = new Color(0f, 0f, 0.5f);
        }

        EZButton b = EZGUI.placeBtn("Start", 29, EZGUI.HALFW + 185, EZGUI.HALFH + 52, e);

        if(!hitStart){
            if(b.btn){
                initStartGame();
            }
            else if(b.hover){
                btnColor = new Color(0.95f, 0.95f, 0.95f, 0.85f);
            }
            else if(b.active){
                btnColor = new Color(0.93f, 0.93f, 0.93f, 0.85f);
            }
            else {
                btnColor = btnColorInit;
            }
        }
        else {
            btnColor = btnColorInit;
        }

        if(BETWEEN_SCENES.jeremyEasterEgg || BETWEEN_SCENES.isaiahEasterEgg){
            e.color = Color.red;
            EZGUI.placeTxt("Cheat Code unlocked!", 34, EZGUI.FULLW - 300, EZGUI.FULLH - 200, e);
        }
    }
Esempio n. 26
0
    void OnGUI()
    {
        EZGUI.init();

        if (EZGUI.placeBtn("Back", 45, 85, 85, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), drp)).btn || Input.GetKeyDown(KeyCode.Backspace))
        {
            Application.LoadLevel("title");
        }

        int fSize = 43;

        //--- Label
        EZOpt titleOpt = new EZOpt(Color.green, drp);

        titleOpt.italic = true;
        titleOpt.bold   = true;
        EZGUI.placeTxt("GUI.Label", fSize, 250, 300, titleOpt);

        EZOpt lblOpt = new EZOpt(Color.green, drp);

        EZGUI.placeTxt("Place Text", fSize, 250, 400, lblOpt);
        EZGUI.flashTxt("Flash Text", fSize, 250, 500, lblOpt);
        EZGUI.blinkTxt("Blink Text", fSize, 250, 600, lblOpt);
        EZGUI.pulseTxt("Pulse Text", fSize, 250, 700, lblOpt);

        //--- Button
        titleOpt.color = Color.red;
        EZGUI.placeTxt("GUI.Button", fSize, 650, 300, titleOpt);

        EZOpt btnOpt = new EZOpt(Color.red, Color.yellow, btnActive, drp);

        EZGUI.placeBtn("Place Button", fSize, 650, 400, btnOpt);
        EZGUI.flashBtn("Flash Button", fSize, 650, 500, btnOpt);
        EZGUI.blinkBtn("Blink Button", fSize, 650, 600, btnOpt);
        EZGUI.pulseBtn("Pulse Button", fSize, 650, 700, btnOpt);

        //--- Wrap
        titleOpt.leftJustify = true;
        titleOpt.color       = new Color(0.8f, 0.8f, 0.8f);
        EZGUI.placeTxt("wrapTxt()", fSize, 920, 300, titleOpt);

        EZGUI.wrapTxt("By specifying a width, the text will wrap automatically when over a certain width.  NOTE: text is left justified and top aligned.",
                      fSize,
                      920,
                      350,
                      400,
                      new EZOpt((Color)titleOpt.color, drp)
                      );

        //--- Window
        EZGUI.placeTxt("GUI.Window", fSize, 1600, 300, new EZOpt(Color.cyan, drp));

        if (windowClosed)
        {
            windowOpen = EZGUI.placeBtn("Open Window", fSize, 1600, 500, new EZOpt(Color.cyan, new Color(0, 0.9f, 0.9f), new Color(0, 0.8f, 0.8f), drp)).btn;
        }

        if (windowOpen)
        {
            windowClosed = EZGUI.placeWindow("Player Info", 30, 1450, 375, 300, windowCallback, Color.black, new EZOpt(Color.cyan));
        }
    }
Esempio n. 27
0
    /// <summary>
    /// Scales str's fontSize [0, 9].
    /// </summary>
    public static void pulseTxt(string str, int fontSize, float x, float y, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();

        float pp = Mathf.PingPong(Time.time, 0.9f);
        pp *= 10;
        fontSize += (int)pp;

        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        addDropShadow(g, e);

        GUI.Label(g.rect, g.cnt, g.style);
    }
Esempio n. 28
0
    /// <summary>
    /// Scales str's fontSize [0, 9].
    /// </summary>
    /// <returns>True if button was clicked.</returns>
    public static bool pulseBtn(string str, int fontSize, float x, float y, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();

        GUIObject g = getGUIObject(str, fontSize, x, y, e);
        bool isHover = checkMouse(g, e.hoverColor, e.activeColor) == 1;

        if(!isHover){
            float pp = Mathf.PingPong(Time.time, 0.9f);
            pp *= 10;
            fontSize += (int)pp;

            g = getGUIObject(str, fontSize, x, y, e);
        }
        else {
            fontSize += 9;  // make text fullsize on hover

            g = getGUIObject(str, fontSize, x, y, e);

            if(e.activeColor != null && Input.GetMouseButton(0)) {
                g.style.normal.textColor = (Color)e.activeColor;
            }
            else {
                g.style.normal.textColor = (Color)e.hoverColor;
            }
        }

        addDropShadow(g, e);

        return GUI.Button(g.rect, g.cnt, g.style);
    }
Esempio n. 29
0
    public static bool placeWindow(string str, int fontSize, float x, float y, int height, GUI.WindowFunction cb, Color bgColor, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        GUI.backgroundColor = bgColor;
        //GUI.contentColor = e.color ?? Color.white;

        GUIStyle style = new GUIStyle(GUI.skin.window);
        style.fontSize = g.style.fontSize;
        style.normal.textColor = g.style.normal.textColor;

        style.onActive.textColor = style.normal.textColor;
        style.active.textColor = style.normal.textColor;
        style.onActive.background = style.onNormal.background;
        style.active.background = style.onNormal.background;

        GUI.Window(0, new Rect(x, y, height, height), cb, str, style);//, g.style);

        EZButton b = placeBtn("Close", 25, x + height, y, new EZOpt(Color.white, Color.red, new Color(0.9f, 0, 0), new Color(0.1f, 0.1f, 0.1f)));
        return b.btn;
    }
Esempio n. 30
0
    /// <summary>
    /// Draws str with center at (x, y).
    /// </summary>
    /// <returns>True if button was clicked.</returns>
    public static EZButton placeBtn(string str, int fontSize, float x, float y, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        int cm = checkMouse(g, e.hoverColor, e.activeColor);
        addDropShadow(g, e);

        return new EZButton(GUI.Button(g.rect, g.cnt, g.style), cm == 1, cm == 2);
    }
Esempio n. 31
0
    /// <summary>
    /// Turns str's alpha value on and off.
    /// </summary>
    /// <returns>True if button was clicked.</returns>
    public static bool flashBtn(string str, int fontSize, float x, float y, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        Color c = g.style.normal.textColor;
        c.a = (Time.time % 2 < 1) ? 1 : 0;
        g.style.normal.textColor = c;

        checkMouse(g, e.hoverColor, e.activeColor);
        addDropShadow(g, e);

        return GUI.Button(g.rect, g.cnt, g.style);
    }
Esempio n. 32
0
    /// <summary>
    /// Fades str in and out.
    /// </summary>
    public static void blinkTxt(string str, int fontSize, float x, float y, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        Color c = g.style.normal.textColor;
        c.a = Mathf.PingPong(Time.time, 1);
        g.style.normal.textColor = c;

        addDropShadow(g, e);

        GUI.Label(g.rect, g.cnt, g.style);
    }
Esempio n. 33
0
    void printPlayers(float startX, float startY, EZOpt e)
    {
        float lineHeight = 41;
        float padBot = 172;

        int teamScore = 0;

        for(int i=0; i < PhotonNetwork.playerList.Length; ++i) {
            PhotonPlayer p = PhotonNetwork.playerList[i];

            bool isYourWizard = (GLOBAL.myWizard != null && p == GLOBAL.myWizard.GetComponent<PhotonView>().owner);

            // Name
            e.leftJustify = true;
            e.color = Color.white;
            if(isYourWizard){
                EZGUI.placeTxt(BETWEEN_SCENES.player_name, 35, startX, startY + (i * padBot), e);
            }
            else {
                EZGUI.placeTxt(p.name, 35, startX, startY + (i * padBot), e);
            }

            // Health
            e.color = new Color(0.85f, 0.85f, 0.85f);
            if(p.customProperties.ContainsKey("Health")){
                float tempHealth = (int)p.customProperties["Health"];
                EZGUI.placeTxt("health: ", 35, startX + 50, startY + (i*padBot) + lineHeight, e);

                if(tempHealth > 0){
                    EZGUI.drawBox(startX + 164, startY + (i * padBot) + 14, 1.7f * tempHealth, 20, Color.red);
                }
            }

            // Score
            int yourScore = (int)p.customProperties["Score"];
            teamScore += yourScore;
            EZGUI.placeTxt("points: " + yourScore.ToString(), 35, startX + 50, startY + (i*padBot) + lineHeight*2, e);

            // Ability Name
            e.leftJustify = false;
            if(p.customProperties.ContainsKey("Ability")) {
                string abilityName = (string)p.customProperties["Ability"];

                if(abilityName == "none"){
                    EZGUI.placeTxt("no base ability chosen", 35, EZGUI.HALFW, startY + lineHeight + (i * padBot), e);
                }
                else{
                    e.color = Color.white;
                    EZGUI.placeTxt(abilityName, 35, EZGUI.HALFW, startY + lineHeight + (i * padBot), e);
                }
            }
            else{
                EZGUI.placeTxt("no base ability chosen", 35, EZGUI.HALFW, startY + lineHeight/2 + (i * padBot), e);
            }

            // Active Player Indicator
            if(isYourWizard) {
                e.color = new Color(0, 0.9f, 0);
                EZGUI.placeTxt("(you)", 40, 1530, startY + lineHeight + (i * padBot), e);
            }
        }

        e.color = new Color(0.85f, 0.85f, 0.85f);
        EZGUI.placeTxt("Team Score: " + teamScore.ToString(), 35, 1530, 990 - 28, e);
    }
Esempio n. 34
0
    /// <summary>
    /// Str will wrap to fit in width.  NOTE: text is left justified and top aligned (this includes placement)
    /// </summary>
    public static void wrapTxt(string str, int fontSize, float x, float y, float width, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);

        GUIStyle style = new GUIStyle(GUI.skin.label);
        style.fontSize = g.style.fontSize;
        style.normal.textColor = g.style.normal.textColor;

        // drop shadow
        if(e.dropShadow != null) {
            GUIStyle drpStyle = new GUIStyle(style);
            drpStyle.normal.textColor = (Color)e.dropShadow;

            GUI.Label(new Rect(x + e.dropShadowX, y + e.dropShadowY, width, FULLH), str, drpStyle);
        }

        GUI.Label(new Rect(x, y, width, FULLH), str, style);
    }
Esempio n. 35
0
    static void addDropShadow(GUIObject g, EZOpt e)
    {
        if(e.dropShadow != null && g.style.normal.textColor.a != 0){
            Color prevColor = g.style.normal.textColor;

            Color ds = (Color)e.dropShadow;
            ds.a = prevColor.a;
            g.style.normal.textColor = ds;

            GUI.Label(new Rect(g.rect.x + e.dropShadowX, g.rect.y + e.dropShadowY, g.rect.width, g.rect.height), g.cnt, g.style);

            g.style.normal.textColor = prevColor;
        }
    }
Esempio n. 36
0
    /// <summary>
    /// Draws str with center at (x, y).
    /// </summary>
    public static void placeTxt(string str, int fontSize, float x, float y, EZOpt? opt=null)
    {
        EZOpt e = opt ?? new EZOpt();
        GUIObject g = getGUIObject(str, fontSize, x, y, e);
        addDropShadow(g, e);

        GUI.Label(g.rect, g.cnt, g.style);
    }
Esempio n. 37
0
    void OnGUI()
    {
        if(gameOver){
            EZGUI.init();
            EZOpt e = new EZOpt(Color.red, new Color(0.1f, 0.1f, 0.1f));
            e.leftJustify = true;
            e.dropShadowX = e.dropShadowY = 3;

            EZGUI.placeTxt(gameOverTxt, 35, 230, 73, e);
        }
    }