예제 #1
0
        public void showOptions(ConversationNodeHolder options)
        {
            var optionsNode = options.getNode() as OptionConversationNode;

            if (optionsNode != null)
            {
                // Disable the UI interactivity
                uAdventureRaycaster.Instance.enabled = false;
                InventoryManager.Instance.Show       = false;

                // Enable blurred background
                blur = GameObject.Instantiate(Blur_Prefab);
                blur.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, Camera.main.transform.position.z + 1);

                // Order shuffeling when node is configured for random
                this.order = Enumerable.Range(0, optionsNode.getLineCount()).ToList();
                if (optionsNode.isRandom())
                {
                    this.order.Shuffle();
                }
                this.guioptions = options;
                this.guistate   = GUIState.ANSWERS_MENU;

                // Timeout option
                if (optionsNode.Timeout > 0 && ConditionChecker.check(optionsNode.TimeoutConditions))
                {
                    this.doTimeOut   = true;
                    this.elapsedTime = 0;
                }
                else
                {
                    this.doTimeOut = false;
                }
            }
        }
예제 #2
0
 public void showOptions(ConversationNodeHolder options)
 {
     if (options.getNode().getType() == ConversationNodeViewEnum.OPTION)
     {
         blur = GameObject.Instantiate(Blur_Prefab);
         blur.transform.position = new Vector3(Camera.main.transform.position.x, Camera.main.transform.position.y, Camera.main.transform.position.z + 1);
         this.guioptions         = options;
         this.guistate           = guiState.ANSWERS_MENU;
     }
 }
예제 #3
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;
            }
        }
예제 #4
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;
            }
        }
예제 #5
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;
            }
        }
예제 #6
0
파일: Game.cs 프로젝트: Victorma/uAdventure
        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;
            }
        }