Esempio n. 1
0
    internal void OnGUI()
    {
        // You'd want this to be called by a MouseMove event, but it's not supported in game,
        // and in any case, we probably need to keep updating because of potential object movement.
        if (contextMenu == null)
        {
            UpdateMouseSelection();
        }

        GUI.depth = 0;
        var e = Event.current;

        switch (e.type)
        {
        case EventType.MouseDown:
            //typingPromptStartTime = Time.time;
            contextMenu = MakeMenu(MouseSelection);
            lastPlayerActivity.StoreExclusive(Time.time, true);
            break;

        case EventType.MouseUp:
            if (contextMenu != null && MouseSelection != null)
            {
                var guiScreenRect = MouseSelection.GUIScreenRect();
                if (guiScreenRect.HasValue)
                {
                    var selection = contextMenu.SelectedAction(guiScreenRect.Value.Center());
                    if (selection != null)
                    {
                        simController.QueueEvent("player_input", selection);
                    }
                }
            }

            lastPlayerActivity.StoreExclusive(Time.time, true);
            contextMenu = null;
            break;

        case EventType.KeyDown:
            if (GUI.GetNameOfFocusedControl() == "")
            {
                HandleKeyDown(e);
                if (!e.alt && !e.control)
                {
                    TryCompletionIfCompleteWord();
                }
            }
            break;

        case EventType.Repaint:
            DrawGUI();
            break;
        }
    }
Esempio n. 2
0
    private void DrawGUI()
    {
        var arrowActive = typingPromptStartTime > Time.time - 3;

        if (contextMenu == null)
        {
            ShowMouseSelectionCaption();
        }

        if (!string.IsNullOrEmpty(input) || arrowActive || Time.time > haloOnset + 2f)
        {
            GameObject addressee;

            var da = dialogAct as Structure;
            if (da != null)
            {
                addressee = (GameObject)da.Argument(1);
            }
            else if (talkingToElNode.Children.Count > 0)
            {
                addressee = (GameObject)talkingToElNode.Children[0].Key;
            }
            else
            {
                addressee = gameObject;
            }

            addressee.DrawThumbNail(new Vector2(InputRect.x - 40, InputRect.y));
        }
        var text = (string.IsNullOrEmpty(input) && arrowActive) ? "<color=grey><i>Talk to me</i></color>" : formatted;

        GUI.Label(InputRect, text, InputGUIStyle);
        GUI.Label(CommentaryRect, commentary, CommentaryGUIStyle);
        GUI.Label(ResponseRect, characterResponse, InputGUIStyle);
        GUI.depth = 0;
        if (contextMenu != null && MouseSelection != null)
        {
            var guiScreenRect = MouseSelection.GUIScreenRect();
            if (guiScreenRect.HasValue)
            {
                contextMenu.Draw(guiScreenRect.Value.Center(), 50);
            }
        }
    }