Пример #1
0
 public static void ClearSelection()
 {
     for (int i = Instance.interactables.Count - 1; i >= 0; i--)
     {
         RemoveInteractable(Instance.interactables[i]);
     }
     InteractionMenu.CloseMenu();
 }
Пример #2
0
 private void Awake()
 {
     if (Instance != null)
     {
         Debug.LogError("Interaction menu already exists.");
         Destroy(this);
     }
     Instance = this;
     Close();
 }
Пример #3
0
        public void Initialize(ContentManager content)
        {
            _world.Initialize(content);
            _blobMenu = new InteractionMenu(_blobMenuOptions, content);

            //give the heros there onclick interaction with the interactionMenu
            foreach (var blob in _world.GetBlobs())
            {
                blob.OnClickEvent += PlayerInteraction;
            }

            _blobMenu.OnClickEvent += MenuInteraction;
        }
Пример #4
0
        public void Functions_OnOnDutyStateChanged(bool onDuty)
        {
            if (onDuty)
            {
                Common.RegisterCallouts();

                if (Settings.AmbientEvents.EnableAmbientEvents)
                {
                    EventPool.EventsController();
                }

                Globals.HeliCamera.ManagerFiber.Start();

                // set up integration with PoliceSmartRadio
                if (IsLSPDFRPluginRunning("PoliceSmartRadio"))
                {
                    PoliceSmartRadioAvailable = true;
                    PoliceSmartRadioFunctions = new PoliceSmartRadioFunctions();
                }

                GameFiber.StartNew(delegate
                {
                    Logger.LogTrivial("Functions fiber started");

                    while (true)
                    {
                        GameFiber.Yield();

                        if (Controls.ToggleBinoculars.IsJustPressed() &&
                            !Game.LocalPlayer.Character.IsInAnyVehicle(false) && !Binoculars.IsActive &&
                            Settings.General.IsBinocularEnable)
                        {
                            Binoculars.EnableBinoculars();
                        }

                        if (Controls.ToggleInteractionMenu.IsJustPressed() && !Binoculars.IsActive)
                        {
                            InteractionMenu.DisEnable();
                        }
                    }
                });

                Game.DisplayNotification("~g~<font size=\"14\"><b>WILDERNESS CALLOUTS</b></font>~s~~n~Version: ~b~" +
                                         WildernessCallouts.Common.GetVersion(
                                             @"Plugins\LSPDFR\Wilderness Callouts.dll") + "~s~~n~Loaded!");
            }
        }
Пример #5
0
    public void Update()
    {
        bool overUI = EventSystem.current.IsPointerOverGameObject();

        Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out mouseHit);
        if (BuildMenu.building)
        {
            mouseHit = default;
        }

        // Get Hover target
        if (overUI == false)
        {
            //if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out mouseHit))
            {
                Interactable newHoverInteractable = mouseHit.transform?.GetComponent <Interactable>();
                if (newHoverInteractable && newHoverInteractable.enabled == false)
                {
                    hoverInteractable = null;
                }

                if (hoverInteractable != null && hoverInteractable != mouseHit.transform)
                {
                    hoverInteractable.OnUnhover();
                    hoverMarker.transform.SetParent(null);
                    hoverMarker.SetActive(false);
                }
                hoverInteractable = newHoverInteractable;
                if (hoverInteractable != null)
                {
                    hoverInteractable.OnHover();
                    hoverMarker.transform.localScale    = mouseHit.collider.bounds.size * 2f;
                    hoverMarker.transform.localPosition = mouseHit.collider.bounds.min + new Vector3(mouseHit.collider.bounds.extents.x, 0, mouseHit.collider.bounds.extents.z);
                    hoverMarker.transform.SetParent(hoverInteractable.transform);
                    hoverMarker.SetActive(true);
                }
            }
        }
        else
        {
            hoverInteractable = null;
        }

        if (hoverInteractable)
        {
            // Left mouse button
            if (Input.GetMouseButtonDown(0))
            {
                if (!Input.GetKey(KeyCode.LeftShift))
                {
                    ClearSelection();
                }
                else if (interactables.Contains(hoverInteractable))
                {
                    RemoveInteractable(hoverInteractable);
                }
                AddInteractable(hoverInteractable);
            }
            // Right mouse button
            else if (Input.GetMouseButtonDown(1))
            {
                InteractionMenu.OpenMenu(hoverInteractable);
            }
        }
        else if (overUI == false)
        {
            if (Input.GetMouseButtonDown(0) && Input.GetKey(KeyCode.LeftShift) == false)
            {
                ClearSelection();
            }

            // Move
            if (Input.GetMouseButtonDown(1))
            {
                if (interactables.Count > 0)
                {
                    for (int i = 0; i < interactables.Count; i++)
                    {
                        if (interactables[i].GetComponent <Unit>() is Unit unit)
                        {
                            unit.navAgent.SetDestination(mouseHit.point);
                            unit.currentInteraction = null;
                        }
                    }
                }
            }
        }

        // Get hover over UI
        if (overUI)
        {
            PointerEventData pointerEventData = new PointerEventData(EventSystem.current);
            pointerEventData.position = Input.mousePosition;
            List <RaycastResult> result = new List <RaycastResult>();
            EventSystem.current.RaycastAll(pointerEventData, result);
            if (result.Count > 0)
            {
                hoverUI = result[0].gameObject;
            }
        }

        // Show hover tooltip
        if (BuildMenu.building)
        {
            hoverTooltip.gameObject.SetActive(false);
            hoverMarker.gameObject.SetActive(false);
            hoverMarker.transform.SetParent(null);
            selectionMarker.gameObject.SetActive(false);
        }
        else if (overUI && hoverUI)
        {
            IUIHoverInfo hoverInfo = hoverUI.GetComponent <IUIHoverInfo>();
            if (hoverInfo != null)
            {
                hoverTooltip.text.SetText(hoverInfo.GetTooltip());
                hoverTooltip.transform.position = hoverUI.transform.position + new Vector3(0f, -40f);
                hoverTooltip.gameObject.SetActive(true);
            }
        }
        else if (hoverInteractable)
        {
            IUIHoverInfo hoverInfo = hoverInteractable.GetComponent <IUIHoverInfo>();
            if (hoverInfo != null)
            {
                hoverTooltip.text.SetText(hoverInfo.GetTooltip());
                //hoverTooltip.transform.position = Input.mousePosition + new Vector3(40f, 20f);    // Mouse position
                hoverTooltip.transform.position = Camera.main.WorldToScreenPoint(mouseHit.collider.bounds.max);
                hoverTooltip.gameObject.SetActive(true);
            }
        }
        else
        {
            hoverTooltip.gameObject.SetActive(false);
        }
    }
Пример #6
0
    void Awake()
    {
        outroImage = GameObject.Find("OutroImage");
        if (outroImage != null)
        {
            outroImage.SetActive(false);
        }

        if (Application.loadedLevelName != "MainMenu")
        {
            if (gameSettings.uiCanvas != null)
            {
                //instantiate and declare
                this.uiCanvas            = Instantiate(gameSettings.uiCanvas, Vector3.zero, Quaternion.identity) as GameObject;
                uiCanvas.gameObject.name = "UiCanvas";
                if (!showBlackBars)
                {
                    uiCanvas.transform.FindChild("Blackbars").gameObject.SetActive(false);
                }
            }
            else
            {
                Debug.Log("No UI Canvas assigned in Game Settings!");
            }
        }
        if (Application.loadedLevelName != "MainMenu")
        {
            if (gameSettings.uiInteractioneMenu != null)
            {
                interactionMenu = Instantiate(gameSettings.uiInteractioneMenu, Vector3.zero, Quaternion.identity) as InteractionMenu;
                interactionMenu.gameObject.name = "InteractionMenu";
                interactionMenu.gameObject.transform.SetParent(uiCanvas.transform);
            }
            else
            {
                Debug.Log("No Interaction Menu assigned in Game Settings!");
            }
        }
        if (Application.loadedLevelName != "MainMenu")
        {
            inventoryController = uiCanvas.GetComponentInChildren <Inventory> ();
        }


        if (gameSettings.audioClipSource != null)
        {
            audioClipSource = Instantiate(gameSettings.audioClipSource, Vector3.zero, Quaternion.identity) as GameObject;
            audioClipSource.gameObject.name = "AudioClipSource";
            audioClipSource.gameObject.transform.SetParent(GameObject.Find("AUDIO").transform);
        }
        else
        {
            Debug.Log("No Interaction Menu assigned in Game Settings!");
        }

        if (gameSettings.voiceSource != null)
        {
            voiceSource = Instantiate(gameSettings.voiceSource, Vector3.zero, Quaternion.identity) as GameObject;
            voiceSource.gameObject.name = "VoiceSource";
            voiceSource.gameObject.transform.SetParent(GameObject.Find("AUDIO").transform);
        }
        else
        {
            Debug.Log("No VS assigned in Game Settings!");
        }
        if (Application.loadedLevelName != "MainMenu")
        {
            if (dialogueHolder == null)
            {
                dialogueHolder = uiCanvas.transform.FindChild("Dialogue").gameObject;
            }
            if (dCon == null)
            {
                dCon = GetComponent <DialogueController> ();
            }
        }
    }
Пример #7
0
 private void ListenInteractionMenuEvents(InteractionMenu p_interactionMenu)
 {
     p_interactionMenu.onClickAction += InteractionMenu_OnClickAction;
 }
Пример #8
0
    void Awake()
    {
        if (instance != null){
            Debug.LogWarning("There are 2 gui managers");
        }
        instance = this;
        activeControls = new List<GUIControl>();
        controlsToRemove = new List<GUIControl>();
        controlsToAdd = new List<GUIControl>();

        chatMenu = GetComponent<ChatMenu>();
        inGameMenu = GetComponent<InGameMenu>();
        interactionMenu = GetComponent<InteractionMenu>();
        pauseMenu = GetComponent<PauseMenu>();
        loadingScreen = GetComponent<LoadingScreen>();
    }
Пример #9
0
 private void Awake()
 {
     Instance = this;
     Instance.GetComponent <GameObject>().SetActive(false);
     Instance.GetComponent <CanvasGroup>().alpha = 0;
 }