コード例 #1
0
    public void DisplayBookmarks()
    {
        PanelController.ClearTextFields();
        PanelController.BookmarksPanel.SetActive(true);
        PanelController.gameObject.SetActive(false);
        for (int i = 0; i < _bookmarksContainer.transform.childCount; i++)
        {
            Destroy(_bookmarksContainer.transform.GetChild(i).gameObject);
        }

        foreach (StarController bookmark in _bookmarkedObjects)
        {
            string entryText = bookmark.Name;

            GameObject bookmarkEntry = Instantiate(_bookmarkEntryPrefab, _bookmarksContainer);
            bookmarkEntry.GetComponentInChildren <TextMeshProUGUI>().text = entryText;

            bookmarkEntry.GetComponent <BookmarkController>().StarController = bookmark;
        }
    }
コード例 #2
0
    void Update()
    {
        if (PlayerController.Instance.isGameStarted)
        {
            if (Input.GetMouseButtonDown(1) && LensGlassController.CanCameraZoom)
            {
                _panelController.ClearTextFields();
                if (_zoomedIn)
                {
                    if (_starViewController.CurrentStarController != null)
                    {
                        _starViewController.CurrentStarController.HideMarker();
                    }

                    _panelController.UpdateLightIndicators();
                    _audioController.PlaySound("Zoom Out");
                    _starViewController.DisplayBookmarks();
                    foreach (GameObject obj in MainViewObjects)
                    {
                        if (obj != null)
                        {
                            if (_starViewController.GetNumberOfBookmarks() > 0)
                            {
                                obj.SetActive(true);
                            }
                            else
                            {
                                if (obj.name != "Bookmarks Panel")
                                {
                                    obj.SetActive(true);
                                }
                            }
                        }
                    }
                    foreach (GameObject obj in ZoomedViewObjects)
                    {
                        if (obj != null)
                        {
                            obj.SetActive(false);
                        }
                    }
                }
                else
                {
                    _panelController.UpdateLightIndicators();
                    _audioController.PlaySound("Zoom In");
                    _starViewController.DisplayBookmarks();
                    foreach (GameObject obj in MainViewObjects)
                    {
                        if (obj != null)
                        {
                            obj.SetActive(false);
                        }
                    }
                    foreach (GameObject obj in ZoomedViewObjects)
                    {
                        if (obj != null)
                        {
                            obj.SetActive(true);
                        }
                    }
                }
                _zoomedIn = !_zoomedIn;
            }

            Vector3 mousePosition = Input.mousePosition;
            if ((mousePosition.x > -Mathf.Abs(ConsoleDisplay.rectTransform.anchoredPosition.x) &&
                 mousePosition.x < ConsoleDisplay.rectTransform.sizeDelta.x) &&
                ((mousePosition.y > -Mathf.Abs(ConsoleDisplay.rectTransform.anchoredPosition.y) + 80 &&
                  mousePosition.y < ConsoleDisplay.rectTransform.sizeDelta.y)))
            {
                if (Input.GetMouseButtonDown(0) && _zoomedIn == false && _isErrorIconBlinking == false)
                {
                    _audioController.PlaySound("Zooming Error");
                    StartCoroutine(BlinkIcon());
                    _isErrorIconBlinking = true;
                }
                if (Input.GetMouseButtonDown(0) && _zoomedIn == true)
                {
                    _panelController.ClearTextFields();
                    Vector3 pointerPosition = _zoomCamera.ScreenToWorldPoint(Input.mousePosition);
                    Vector2 origin          = new Vector2(pointerPosition.x, pointerPosition.y);
                    Vector2 direction       = Vector2.one;

                    RaycastHit2D hit = Physics2D.Raycast(pointerPosition, direction, Mathf.Infinity);

                    if (hit && hit.transform.tag == "Space Object")
                    {
                        StarController starController = hit.collider.GetComponent <StarController>();
                        if (starController != null)
                        {
                            // Sound effect
                            AudioController audioController = starController.GetComponent <AudioController>();
                            audioController.PlaySound(Random.Range(0, audioController.CountOfSounds()));

                            starController.ToggleMarker();
                            _panelController.LoadDetails(starController, false);
                        }
                        //ObjectDetailsManager.Instance.InitializePanelOf(hit.collider.GetComponent<StarController>(), pointerPosition);
                    }

                    _panelController.UpdateLightIndicators();
                }
            }
        }
    }