Пример #1
0
        void OnGUI()
        {
            float guiscale = Screen.width / 800f;

            style.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
            style.button.fontSize = Mathf.RoundToInt(guiscale * 20);
            style.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
            optionlabel.fontSize  = Mathf.RoundToInt(guiscale * 36);
            style.GetStyle("talk_player").fontSize = Mathf.RoundToInt(guiscale * 20);
            //float rectwith = guiscale * 330;

            switch (guistate)
            {
            case guiState.ANSWERS_MENU:
                GUILayout.BeginArea(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f));
                GUILayout.BeginVertical();
                OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

                GUILayout.Label(GUIManager.Instance.Last, optionlabel);
                for (int i = 0; i < options.getLineCount(); i++)
                {
                    ConversationLine ono = options.getLine(i);
                    if (ConditionChecker.check(options.getLineConditions(i)))
                    {
                        if (GUILayout.Button((string)ono.getText(), style.button))
                        {
                            GameObject.Destroy(blur);
                            guioptions.clicked(i);

                            /*Tracker.T ().Choice (GUIManager.Instance.Last, ono.getText ());
                             * Tracker.T ().RequestFlush ();*/
                            Interacted();
                        }
                    }
                    ;
                }
                GUILayout.EndVertical();
                GUILayout.EndArea();
                break;

            default: break;
            }
        }
Пример #2
0
        protected void OnGUI()
        {
            if (loadingScreen != null)
            {
                loadingScreen.OnGUI();
            }


            switch (guistate)
            {
            case GUIState.BOOK:
                if (ShowingBook)
                {
                    bookDrawer.Draw(new Rect(Vector2.zero, new Vector2(Screen.width, Screen.height)));
                }
                break;

            case GUIState.ANSWERS_MENU:

                using (new GUIUtil.SkinScope(skin))
                {
                    float guiscale         = Screen.width / 800f;
                    var   buttonImageWidth = (200f / 600f) * Screen.height;
                    skin.box.fontSize                          = Mathf.RoundToInt(guiscale * 20);
                    skin.button.fontSize                       = Mathf.RoundToInt(guiscale * 20);
                    skin.button.alignment                      = TextAnchor.MiddleCenter;
                    skin.button.imagePosition                  = ImagePosition.ImageAbove;
                    skin.button.stretchHeight                  = false;
                    skin.button.stretchWidth                   = true;
                    skin.label.fontSize                        = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("optionLabel").fontSize      = Mathf.RoundToInt(guiscale * 36);
                    skin.GetStyle("talk_player").fontSize      = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("emptyProgressBar").fontSize = Mathf.RoundToInt(guiscale * 20);
                    OptionConversationNode options = (OptionConversationNode)guioptions.getNode();
                    var areawidth = Screen.width * 0.8f;
                    using (new GUILayout.AreaScope(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, areawidth, Screen.height * 0.8f)))
                    {
                        using (new GUILayout.VerticalScope(GUILayout.ExpandWidth(true)))
                        {
                            var restWidth        = 1f;
                            var initedHorizontal = false;

                            if (options.isKeepShowing() && GUIManager.Instance.Line != null)
                            {
                                var text = GUIManager.Instance.Line.getText();
                                if (text[0] == '#')
                                {
                                    text = text.Remove(0, Mathf.Max(0, text.IndexOf(' ') + 1));
                                }

                                var textContent = new GUIContent(text);
                                var textRect    = GUILayoutUtility.GetRect(textContent, "optionLabel");

                                GUIUtil.DrawTextBorder(textRect, textContent, Color.black, "optionLabel");
                                GUIUtil.DrawText(textRect, textContent, ((GUIStyle)"optionLabel").normal.textColor, "optionLabel");

                                var resources = GUIManager.Instance.Line.getResources().Checked().FirstOrDefault();
                                if (resources != null)
                                {
                                    var image = resources.existAsset("image") ? Game.Instance.ResourceManager.getImage(resources.getAssetPath("image")) : null;
                                    if (image)
                                    {
                                        GUILayout.BeginHorizontal();
                                        initedHorizontal = true;
                                        restWidth        = 0.7f;
                                        var imageRatio  = image.width / (float)image.height;
                                        var imageWidth  = areawidth * 0.28f;
                                        var imageHeight = Mathf.Min(imageWidth / imageRatio, Screen.height * 0.45f);
                                        using (new GUILayout.VerticalScope(GUILayout.Width(areawidth * 0.3f)))
                                        {
                                            GUILayout.FlexibleSpace();
                                            GUILayout.Box(image, GUILayout.Width(imageWidth), GUILayout.Height(imageHeight));
                                            GUILayout.FlexibleSpace();
                                        }
                                    }
                                }
                            }

                            using (new GUILayout.VerticalScope(GUILayout.Width(areawidth * restWidth)))
                            {
                                if (options.Horizontal)
                                {
                                    GUILayout.FlexibleSpace();
                                }
                                var elementsLeft = options.getLineCount();
                                while (elementsLeft > 0)
                                {
                                    if (options.Horizontal)
                                    {
                                        GUILayout.BeginHorizontal();
                                        GUILayout.FlexibleSpace();
                                    }
                                    else
                                    {
                                        GUILayout.BeginVertical();
                                    }
                                    var start     = options.getLineCount() - elementsLeft;
                                    var amount    = options.MaxElemsPerRow > 0 ? options.MaxElemsPerRow : options.getLineCount();
                                    var end       = Mathf.Clamp(start + amount, 0, options.getLineCount());
                                    var eachWidth = (areawidth * restWidth / (end - start)) - 20;
                                    for (int i = start; i < end; i++)
                                    {
                                        ConversationLine ono = options.getLine(order[i]);
                                        var content          = new GUIContent(ono.getText());
                                        var resources        = ono.getResources().Checked().FirstOrDefault();
                                        auxLimitList.Clear();
                                        if (end - start > 1 && options.Horizontal)
                                        {
                                            auxLimitList.Add(GUILayout.Width(eachWidth));
                                        }

                                        if (resources != null && resources.existAsset("image") && !string.IsNullOrEmpty(resources.getAssetPath("image")))
                                        {
                                            var imagePath = resources.getAssetPath("image");
                                            var image     = ResourceManager.getImage(imagePath);
                                            if (image)
                                            {
                                                content.image = image;

                                                /*if (image.height > buttonImageWidth)
                                                 * {*/
                                                auxLimitList.Add(GUILayout.Height(buttonImageWidth - 20));
                                                //}
                                            }
                                        }

                                        if (ConditionChecker.check(options.getLineConditions(order[i])) && GUILayout.Button(content, auxLimitList.ToArray()))
                                        {
                                            OptionSelected(order[i]);
                                        }
                                    }
                                    elementsLeft = options.getLineCount() - end;
                                    if (options.Horizontal)
                                    {
                                        GUILayout.FlexibleSpace();
                                        GUILayout.EndHorizontal();
                                    }
                                    else
                                    {
                                        GUILayout.EndVertical();
                                    }

                                    if (doTimeOut)
                                    {
                                        if (Event.current.type == EventType.Repaint && elapsedTime > options.Timeout)
                                        {
                                            OptionSelected(options.getChildCount() - 1);
                                        }

                                        var timeLeft     = Mathf.Max(0, options.Timeout - elapsedTime);
                                        var timeLeftText = Mathf.Round(timeLeft * 10) / 10 + " s";
                                        GUILayout.FlexibleSpace();
                                        DrawProgressBar(GUILayoutUtility.GetRect(0, 0, "emptyProgressBar", GUILayout.ExpandWidth(true), GUILayout.Height(50)), timeLeftText, 1 - (elapsedTime / options.Timeout));
                                    }
                                }

                                if (initedHorizontal)
                                {
                                    GUILayout.EndHorizontal();
                                }

                                if (options.Horizontal)
                                {
                                    GUILayout.FlexibleSpace();
                                }
                            }
                        }
                    }
                }
                break;

            default: break;
            }
        }
Пример #3
0
        protected void OnGUI()
        {
            switch (guistate)
            {
            case GUIState.BOOK:
                if (ShowingBook)
                {
                    bookDrawer.Draw(new Rect(Vector2.zero, new Vector2(Screen.width, Screen.height)));
                }
                break;

            case GUIState.ANSWERS_MENU:

                using (new GUIUtil.SkinScope(skin))
                {
                    float guiscale = Screen.width / 800f;
                    skin.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
                    skin.button.fontSize = Mathf.RoundToInt(guiscale * 20);
                    skin.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("optionLabel").fontSize      = Mathf.RoundToInt(guiscale * 36);
                    skin.GetStyle("talk_player").fontSize      = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("emptyProgressBar").fontSize = Mathf.RoundToInt(guiscale * 20);

                    using (new GUILayout.AreaScope(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f)))
                    {
                        using (new GUILayout.VerticalScope())
                        {
                            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

                            if (options.isKeepShowing())
                            {
                                var text = GUIManager.Instance.Last;
                                if (text[0] == '#')
                                {
                                    text = text.Remove(0, Mathf.Max(0, text.IndexOf(' ') + 1));
                                }

                                var textContent = new GUIContent(text);
                                var textRect    = GUILayoutUtility.GetRect(textContent, "optionLabel");

                                GUIUtil.DrawTextBorder(textRect, textContent, Color.black, "optionLabel");
                                GUIUtil.DrawText(textRect, textContent, ((GUIStyle)"optionLabel").normal.textColor, "optionLabel");
                            }
                            foreach (var i in order)
                            {
                                ConversationLine ono = options.getLine(i);
                                if (ConditionChecker.check(options.getLineConditions(i)) && GUILayout.Button(ono.getText()))
                                {
                                    OptionSelected(i);
                                }
                            }

                            if (doTimeOut)
                            {
                                if (Event.current.type == EventType.Repaint && elapsedTime > options.Timeout)
                                {
                                    OptionSelected(options.getChildCount() - 1);
                                }

                                var timeLeft     = Mathf.Max(0, options.Timeout - elapsedTime);
                                var timeLeftText = Mathf.Round(timeLeft * 10) / 10 + " s";
                                GUILayout.FlexibleSpace();
                                DrawProgressBar(GUILayoutUtility.GetRect(0, 0, "emptyProgressBar", GUILayout.ExpandWidth(true), GUILayout.Height(50)), timeLeftText, 1 - (elapsedTime / options.Timeout));
                            }
                        }
                    }
                }
                break;

            default: break;
            }
        }
Пример #4
0
        protected void OnGUI()
        {
            switch (guistate)
            {
            case GUIState.BOOK:
                if (ShowingBook)
                {
                    bookDrawer.Draw(new Rect(Vector2.zero, new Vector2(Screen.width, Screen.height)));
                }
                break;

            case GUIState.ANSWERS_MENU:

                using (new GUIUtil.SkinScope(skin))
                {
                    float guiscale = Screen.width / 800f;
                    skin.box.fontSize                          = Mathf.RoundToInt(guiscale * 20);
                    skin.button.fontSize                       = Mathf.RoundToInt(guiscale * 20);
                    skin.button.alignment                      = TextAnchor.MiddleCenter;
                    skin.button.imagePosition                  = ImagePosition.ImageAbove;
                    skin.button.stretchHeight                  = false;
                    skin.button.stretchWidth                   = true;
                    skin.label.fontSize                        = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("optionLabel").fontSize      = Mathf.RoundToInt(guiscale * 36);
                    skin.GetStyle("talk_player").fontSize      = Mathf.RoundToInt(guiscale * 20);
                    skin.GetStyle("emptyProgressBar").fontSize = Mathf.RoundToInt(guiscale * 20);

                    using (new GUILayout.AreaScope(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f)))
                    {
                        using (new GUILayout.VerticalScope())
                        {
                            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

                            if (options.isKeepShowing())
                            {
                                var text = GUIManager.Instance.Last;
                                if (text[0] == '#')
                                {
                                    text = text.Remove(0, Mathf.Max(0, text.IndexOf(' ') + 1));
                                }

                                var textContent = new GUIContent(text);
                                var textRect    = GUILayoutUtility.GetRect(textContent, "optionLabel");

                                GUIUtil.DrawTextBorder(textRect, textContent, Color.black, "optionLabel");
                                GUIUtil.DrawText(textRect, textContent, ((GUIStyle)"optionLabel").normal.textColor, "optionLabel");
                            }
                            foreach (var i in order)
                            {
                                ConversationLine ono = options.getLine(i);
                                var content          = new GUIContent(ono.getText());
                                var resources        = ono.getResources().Checked().FirstOrDefault();
                                auxLimitList.Clear();

                                if (resources != null && resources.existAsset("image") && !string.IsNullOrEmpty(resources.getAssetPath("image")))
                                {
                                    var imagePath = resources.getAssetPath("image");
                                    var image     = ResourceManager.getImage(imagePath);
                                    if (image)
                                    {
                                        content.image = image;
                                        if (image.height > 240)
                                        {
                                            auxLimitList.Add(GUILayout.Height(240));
                                        }
                                    }
                                }

                                if (ConditionChecker.check(options.getLineConditions(i)) && GUILayout.Button(content, auxLimitList.ToArray()))
                                {
                                    OptionSelected(i);
                                }
                            }

                            if (doTimeOut)
                            {
                                if (Event.current.type == EventType.Repaint && elapsedTime > options.Timeout)
                                {
                                    OptionSelected(options.getChildCount() - 1);
                                }

                                var timeLeft     = Mathf.Max(0, options.Timeout - elapsedTime);
                                var timeLeftText = Mathf.Round(timeLeft * 10) / 10 + " s";
                                GUILayout.FlexibleSpace();
                                DrawProgressBar(GUILayoutUtility.GetRect(0, 0, "emptyProgressBar", GUILayout.ExpandWidth(true), GUILayout.Height(50)), timeLeftText, 1 - (elapsedTime / options.Timeout));
                            }
                        }
                    }
                }
                break;

            default: break;
            }
        }
Пример #5
0
    void OnGUI()
    {
        float guiscale = Screen.width / 800f;

        style.box.fontSize    = Mathf.RoundToInt(guiscale * 20);
        style.button.fontSize = Mathf.RoundToInt(guiscale * 20);
        style.label.fontSize  = Mathf.RoundToInt(guiscale * 20);
        optionlabel.fontSize  = Mathf.RoundToInt(guiscale * 36);
        //style.label.fontSize = Mathf.RoundToInt(guiscale * 20);
        style.GetStyle("talk_player").fontSize = Mathf.RoundToInt(guiscale * 20);

        float rectwith = guiscale * 330;

        switch (guistate)
        {
        case guiState.TALK_PLAYER:
            /*GUILayout.BeginArea (new Rect ((Screen.width/2)-rectwith/2, 50, rectwith, 400));
             * GUILayout.BeginHorizontal ();
             * GUILayout.Box (guitext,style.GetStyle("talk_player"));
             * GUILayout.EndHorizontal ();
             * GUILayout.EndArea ();*/
            break;

        case guiState.TALK_CHARACTER:
            /*GUIStyle current = new GUIStyle(style.box);
             * if (this.guitalkerObject != null) {
             * position = Camera.current.WorldToScreenPoint (this.guitalkerObject.transform.position);
             * Color tmp = Color.black;
             * NPC cha = data.getChapters () [current_chapter].getCharacter (guitalker);
             *
             *
             * ColorUtility.TryParseHtmlString(
             *  cha.getTextFrontColor()
             *  ,out tmp);
             *
             * current.normal.textColor = tmp;
             * current.normal.background = BorderGenerator.generateFor (cha);
             * }else
             * position = new Vector2(Screen.width/2,100);
             *
             * if(position.x <= rectwith/2)
             * position.x = rectwith/2;
             * else if(position.x >= (Screen.width - rectwith/2) )
             * position.x = (Screen.width - rectwith/2);
             *
             * GUILayout.BeginArea (
             * new Rect (position.x-rectwith/2,
             *  Screen.height
             *  - position.y
             *  - (this.guitalkerObject.GetComponent<CharacterMB>().getHeight())*guiscale/2
             *  - current.CalcHeight(new GUIContent(guitext),rectwith), rectwith, 400)
             * );
             * GUILayout.BeginHorizontal ();
             * GUILayout.Box (guitext,current);
             * GUILayout.EndHorizontal ();
             * GUILayout.EndArea ();*/
            break;

        case guiState.ANSWERS_MENU:
            GUILayout.BeginArea(new Rect(Screen.width * 0.1f, Screen.height * 0.1f, Screen.width * 0.8f, Screen.height * 0.8f));
            GUILayout.BeginVertical();
            OptionConversationNode options = (OptionConversationNode)guioptions.getNode();

            GUILayout.Label(guitext, optionlabel);
            for (int i = 0; i < options.getLineCount(); i++)
            {
                ConversationLine ono = options.getLine(i);
                if (ConditionChecker.check(options.getLineConditions(i)))
                {
                    if (GUILayout.Button((string)ono.getText(), style.button))
                    {
                        GameObject.Destroy(blur);
                        guioptions.clicked(i);
                        Interacted();
                    }
                }
                ;
            }
            GUILayout.EndVertical();
            GUILayout.EndArea();
            break;

        case guiState.LOADING_GAME:
            break;

        case guiState.NOTHING:
            /*if(loader_state == loaderState.LOADING){
             *  GUILayout.BeginArea (new Rect (Screen.width*0.1f, Screen.height*0.1f, Screen.width*0.8f, Screen.height*0.8f));
             *  GUILayout.BeginVertical ();
             *  GUILayout.Label ("Cargando",style.label);
             *
             *  if(totals != null){
             *      GUILayout.Box ("Personajes: " + this.characters.Count + " de " + totals["Characters"],style.box);
             *      GUILayout.Box ("Objetos: " + this.objects.Count + " de " + totals["Objects"],style.box);
             *      GUILayout.Box ("Objetos de Atrezzo: " + this.atrezzos.Count + " de " + totals["Atrezzos"],style.box);
             *      GUILayout.Box ("Estados Globales: " + this.global_states.Count + " de " + totals["Global-States"],style.box);
             *      GUILayout.Box ("Grafos de Conversacion: " + this.graph_conversations.Count + " de " + totals["Graph-conversations"],style.box);
             *      GUILayout.Box ("Macros: " + this.macros.Count + " de " + totals["Macros"],style.box);
             *
             *      GUILayout.Box ("Escenas: " + this.scenes.Count + " de " + totals["Scene"],style.box);
             *  }
             *
             *
             *  GUILayout.EndVertical ();
             *  GUILayout.EndArea ();
             * }*/
            break;

        case guiState.GAME_SELECTION:
        /*GUILayout.BeginArea (new Rect (Screen.width*0.1f, Screen.height*0.1f, Screen.width*0.8f, Screen.height*0.8f));
         * GUILayout.BeginVertical ();
         * string[] games = Directory.GetDirectories("Games/");
         *
         * GUILayout.Label("eAdventure Loader v0.1",style.label);
         * foreach(string game in games){
         *  if(GUILayout.Button (game.Split('/')[1],style.button)){
         *      this.selected_game = game + "/";
         *      //this.startLoad();
         *  };
         * }
         * GUILayout.EndVertical ();
         * GUILayout.EndArea ();
         * break;*/
        default: break;
        }
    }