Esempio n. 1
0
        private void OnGUI()
        {
            if (!Application.isPlaying)
            {
                if (AdvGame.GetReferences())
                {
                    menuManager = AdvGame.GetReferences().menuManager;

                    if (menuManager && menuManager.drawInEditor && AdvGame.GetReferences().viewingMenuManager)
                    {
                        if (menuManager.GetSelectedMenu() != null)
                        {
                            AC.Menu menu = menuManager.GetSelectedMenu();

                            if (menu.IsUnityUI())
                            {
                                return;
                            }

                            if (KickStarter.mainCamera != null)
                            {
                                KickStarter.mainCamera.DrawBorders();
                            }

                            CheckScreenSize(menu);

                            if ((menu.appearType == AppearType.Manual || menu.appearType == AppearType.OnInputKey) && menu.pauseWhenEnabled && menuManager.pauseTexture)
                            {
                                GUI.DrawTexture(AdvGame.GUIRect(0.5f, 0.5f, 1f, 1f), menuManager.pauseTexture, ScaleMode.ScaleToFit, true, 0f);
                            }

                            if ((menu.positionType == AC_PositionType.FollowCursor || menu.positionType == AC_PositionType.AppearAtCursorAndFreeze || menu.positionType == AC_PositionType.OnHotspot || menu.positionType == AC_PositionType.AboveSpeakingCharacter || menu.positionType == AC_PositionType.AbovePlayer) && AdvGame.GetReferences().cursorManager&& AdvGame.GetReferences().cursorManager.pointerIcon.texture)
                            {
                                CursorIconBase icon = AdvGame.GetReferences().cursorManager.pointerIcon;
                                GUI.DrawTexture(AdvGame.GUIBox(new Vector2(AdvGame.GetMainGameViewSize().x / 2f, AdvGame.GetMainGameViewSize().y / 2f), icon.size), icon.texture, ScaleMode.ScaleToFit, true, 0f);
                            }

                            menu.StartDisplay();

                            foreach (MenuElement element in menu.visibleElements)
                            {
                                SetStyles(element);

                                for (int i = 0; i < element.GetNumSlots(); i++)
                                {
                                    if (menuManager.GetSelectedElement() == element && element.isClickable && i == 0)
                                    {
                                        //	element.PreDisplay (i, true, 0);
                                        element.Display(highlightedStyle, i, 1f, true);
                                    }

                                    else
                                    {
                                        //	element.PreDisplay (i, true, 0);
                                        element.Display(normalStyle, i, 1f, false);
                                    }
                                }

                                if (UnityEditor.EditorWindow.mouseOverWindow != null && UnityEditor.EditorWindow.mouseOverWindow.ToString().Contains("(UnityEditor.GameView)"))
                                {
                                    if (menu.IsPointerOverSlot(element, 0, Event.current.mousePosition + new Vector2(menu.GetRect().x, menu.GetRect().y)))
                                    {
                                        menuManager.SelectElementFromPreview(menu, element);
                                    }
                                }
                            }

                            menu.EndDisplay();

                            if (menuManager.drawOutlines)
                            {
                                menu.DrawOutline(menuManager.GetSelectedElement());
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /**
         * <summary>Draws an icon at the Hotspot's centre.</summary>
         * <param name = "inWorldSpace">If True, the icon shall be drawn as a sprite in world space, as opposed to an OnGUI graphic in screen space.</param>
         */
        public void DrawHotspotIcon(bool inWorldSpace = false)
        {
            if (iconAlpha > 0f)
            {
                if (!KickStarter.mainCamera.IsPointInCamera(GetIconScreenPosition()))
                {
                    return;
                }

                if (inWorldSpace)
                {
                    if (iconRenderer == null)
                    {
                        GameObject iconOb = new GameObject(this.name + " - icon");
                        iconRenderer = iconOb.AddComponent <SpriteRenderer>();
                        iconOb.transform.localScale = Vector3.one * (25f * KickStarter.settingsManager.hotspotIconSize);

                        if (iconSortingLayer != "")
                        {
                            iconRenderer.GetComponent <SpriteRenderer>().sortingLayerName = iconSortingLayer;
                        }
                        iconRenderer.GetComponent <SpriteRenderer>().sortingOrder = iconSortingOrder;
                    }

                    if (KickStarter.settingsManager.hotspotIcon == HotspotIcon.UseIcon)
                    {
                        GetMainIcon();
                        if (mainIcon != null)
                        {
                            iconRenderer.sprite = mainIcon.GetSprite();
                        }
                    }
                    else
                    {
                        if (iconSprite == null && KickStarter.settingsManager.hotspotIconTexture != null)
                        {
                            iconSprite = UnityEngine.Sprite.Create(KickStarter.settingsManager.hotspotIconTexture, new Rect(0f, 0f, KickStarter.settingsManager.hotspotIconTexture.width, KickStarter.settingsManager.hotspotIconTexture.height), new Vector2(0.5f, 0.5f));
                        }
                        if (iconSprite != iconRenderer.sprite)
                        {
                            iconRenderer.sprite = iconSprite;
                        }
                    }

                    iconRenderer.transform.position = GetIconPosition();
                    iconRenderer.transform.LookAt(iconRenderer.transform.position + KickStarter.mainCamera.transform.rotation * Vector3.forward, KickStarter.mainCamera.transform.rotation * Vector3.up);
                }
                else
                {
                    if (iconRenderer != null)
                    {
                        GameObject.Destroy(iconRenderer.gameObject);
                        iconRenderer = null;
                    }

                    Color c         = GUI.color;
                    Color tempColor = c;
                    c.a       = iconAlpha;
                    GUI.color = c;

                    if (KickStarter.settingsManager.hotspotIcon == HotspotIcon.UseIcon)
                    {
                        GetMainIcon();
                        if (mainIcon != null)
                        {
                            mainIcon.Draw(GetIconScreenPosition(), !KickStarter.playerMenus.IsMouseOverInteractionMenu());
                        }
                    }
                    else if (KickStarter.settingsManager.hotspotIconTexture != null)
                    {
                        GUI.DrawTexture(AdvGame.GUIBox(GetIconScreenPosition(), KickStarter.settingsManager.hotspotIconSize), KickStarter.settingsManager.hotspotIconTexture, ScaleMode.ScaleToFit, true, 0f);
                    }

                    GUI.color = tempColor;
                }
            }

            if (inWorldSpace && iconRenderer != null)
            {
                Color tempColor = iconRenderer.color;
                tempColor.a        = iconAlpha;
                iconRenderer.color = tempColor;
            }
        }
Esempio n. 3
0
        public void DrawCursor()
        {
            if (KickStarter.playerInput && KickStarter.playerInteraction && KickStarter.stateHandler && KickStarter.settingsManager && KickStarter.cursorManager && KickStarter.runtimeInventory && showCursor)
            {
                if (KickStarter.playerInput.IsCursorLocked() && KickStarter.settingsManager.hideLockedCursor)
                {
                    canShowHardwareCursor = false;
                    return;
                }

                GUI.depth             = -1;
                canShowHardwareCursor = true;

                if (KickStarter.runtimeInventory.selectedItem != null)
                {
                    // Cursor becomes selected inventory
                    selectedCursor        = -2;
                    canShowHardwareCursor = false;
                }
                else if (KickStarter.settingsManager.interactionMethod != AC_InteractionMethod.ChooseInteractionThenHotspot)
                {
                    if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive && KickStarter.cursorManager.allowInteractionCursorForInventory && KickStarter.runtimeInventory.hoverItem != null)
                    {
                        ShowContextIcons(KickStarter.runtimeInventory.hoverItem);
                        return;
                    }
                    else if (KickStarter.playerInteraction.GetActiveHotspot() != null && KickStarter.stateHandler.gameState == GameState.Normal && (KickStarter.playerInteraction.GetActiveHotspot().HasContextUse() || KickStarter.playerInteraction.GetActiveHotspot().HasContextLook()))
                    {
                        selectedCursor = 0;

                        if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                        {
                            if (KickStarter.cursorManager.allowInteractionCursor)
                            {
                                canShowHardwareCursor = false;
                                ShowContextIcons();
                            }
                            else if (KickStarter.cursorManager.mouseOverIcon.texture != null)
                            {
                                DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                            }
                            else
                            {
                                DrawMainCursor();
                            }
                        }
                    }
                    else
                    {
                        selectedCursor = -1;
                    }
                }
                else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                {
                    if (KickStarter.stateHandler.gameState == GameState.DialogOptions || KickStarter.stateHandler.gameState == GameState.Paused)
                    {
                        selectedCursor = -1;
                    }
                    else if (KickStarter.playerInteraction.GetActiveHotspot() != null && !KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction() && !KickStarter.cursorManager.allowInteractionCursor && KickStarter.cursorManager.mouseOverIcon.texture != null)
                    {
                        DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                        return;
                    }
                }


                if (KickStarter.stateHandler.gameState == GameState.Cutscene && KickStarter.cursorManager.waitIcon.texture != null)
                {
                    // Wait
                    DrawIcon(KickStarter.cursorManager.waitIcon, false);
                }
                else if (selectedCursor == -2 && KickStarter.runtimeInventory.selectedItem != null)
                {
                    // Inventory
                    canShowHardwareCursor = false;

                    if (KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot && KickStarter.settingsManager.cycleInventoryCursors)
                    {
                        if (KickStarter.playerInteraction.GetActiveHotspot() == null && KickStarter.runtimeInventory.hoverItem == null)
                        {
                            if (KickStarter.playerInteraction.GetInteractionIndex() >= 0)
                            {
                                // Item was selected due to cycling icons
                                KickStarter.playerInteraction.ResetInteractionIndex();
                                KickStarter.runtimeInventory.SetNull();
                                return;
                            }
                        }
                    }

                    if (KickStarter.settingsManager.inventoryActiveEffect != InventoryActiveEffect.None && KickStarter.runtimeInventory.selectedItem.activeTex && KickStarter.playerMenus.GetHotspotLabel() != "" &&
                        (KickStarter.settingsManager.activeWhenUnhandled || KickStarter.playerInteraction.DoesHotspotHaveInventoryInteraction() || (KickStarter.runtimeInventory.hoverItem != null && KickStarter.runtimeInventory.hoverItem.DoesHaveInventoryInteraction(KickStarter.runtimeInventory.selectedItem))))
                    {
                        if (KickStarter.cursorManager.inventoryHandling == InventoryHandling.ChangeHotspotLabel)
                        {
                            DrawMainCursor();
                        }
                        else
                        {
                            DrawActiveInventoryCursor();
                        }
                    }
                    else if (KickStarter.runtimeInventory.selectedItem.tex)
                    {
                        if (KickStarter.cursorManager.inventoryHandling == InventoryHandling.ChangeHotspotLabel)
                        {
                            DrawMainCursor();
                        }
                        else
                        {
                            DrawIcon(AdvGame.GUIBox(KickStarter.playerInput.GetMousePosition(), KickStarter.cursorManager.inventoryCursorSize), KickStarter.runtimeInventory.selectedItem.tex);
                            pulseDirection = 0;
                        }
                    }
                    else
                    {
                        selectedCursor = -1;
                        KickStarter.runtimeInventory.SetNull();
                        pulseDirection = 0;
                    }

                    if (KickStarter.runtimeInventory.selectedItem != null && KickStarter.runtimeInventory.selectedItem.canCarryMultiple)
                    {
                        KickStarter.runtimeInventory.DrawInventoryCount(KickStarter.playerInput.GetMousePosition(), KickStarter.cursorManager.inventoryCursorSize, KickStarter.runtimeInventory.selectedItem.count);
                    }
                }
                else if (KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingCursorAndClickingHotspot)
                {
                    ShowCycleCursor(KickStarter.playerInteraction.GetActiveUseButtonIconID());
                }
                else if (KickStarter.cursorManager.allowMainCursor || KickStarter.settingsManager.inputMethod == InputMethod.KeyboardOrController)
                {
                    // Pointer
                    pulseDirection = 0;

                    if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseHotspotThenInteraction)
                    {
                        if (KickStarter.runtimeInventory.hoverItem == null && KickStarter.playerInteraction.GetActiveHotspot() != null && (!KickStarter.playerInput.interactionMenuIsOn || KickStarter.settingsManager.SelectInteractionMethod() == SelectInteractions.CyclingMenuAndClickingHotspot))
                        {
                            if (KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction())
                            {
                                ShowContextIcons();
                            }
                            else if (KickStarter.cursorManager.mouseOverIcon.texture != null)
                            {
                                DrawIcon(KickStarter.cursorManager.mouseOverIcon, false);
                            }
                            else
                            {
                                DrawMainCursor();
                            }
                        }
                        else
                        {
                            DrawMainCursor();
                        }
                    }
                    else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ContextSensitive)
                    {
                        if (selectedCursor == -1)
                        {
                            DrawMainCursor();
                        }
                        else if (selectedCursor == -2 && KickStarter.runtimeInventory.selectedItem == null)
                        {
                            selectedCursor = -1;
                        }
                    }
                    else if (KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                    {
                        if (KickStarter.playerInteraction.GetActiveHotspot() != null && KickStarter.playerInteraction.GetActiveHotspot().IsSingleInteraction())
                        {
                            selectedCursor = -1;
                            ShowContextIcons();
                        }
                        else if (selectedCursor >= 0)
                        {
                            if (KickStarter.cursorManager.allowInteractionCursor)
                            {
                                //	Custom icon
                                pulseDirection        = 0;
                                canShowHardwareCursor = false;

                                DrawIcon(KickStarter.cursorManager.cursorIcons [selectedCursor], false);
                            }
                            else
                            {
                                DrawMainCursor();
                            }
                        }
                        else if (selectedCursor == -1)
                        {
                            DrawMainCursor();
                        }
                        else if (selectedCursor == -2 && KickStarter.runtimeInventory.selectedItem == null)
                        {
                            selectedCursor = -1;
                        }
                    }
                }
            }
        }