示例#1
0
        private void menuTabError(FPEMenuTab tab)
        {
            menuAudio.clip = menuError;
            menuAudio.Play();

            if (shakeUIOnError)
            {
                elementToJiggle         = tab.gameObject.GetComponent <RectTransform>();
                originalElementPosition = elementToJiggle.localPosition;
                jiggleTimer             = jiggleDuration;

                // Set direction of jiggle based on tab (there will only ever be 2 cases - left most or right most)
                if (currentMenuTab == eMenuTab.ITEMS)
                {
                    jiggleOffset = -jiggleDistance;
                }
                else
                {
                    jiggleOffset = jiggleDistance;
                }
            }
        }
示例#2
0
        public override void Awake()
        {
            base.Awake();

            menuCanvas = transform.Find("MenuCanvas").gameObject;
            menuCanvas.SetActive(false);
            itemData       = new FPEInventoryItemData[1];
            audioDiaryData = new FPEAudioDiaryData[1];
            noteData       = new FPENoteData[1];

            // Find tabs - will need to be updated if you add or remove tabs
            FPEMenuTab[] menuTabs = menuCanvas.gameObject.GetComponentsInChildren <FPEMenuTab>();

            for (int t = 0; t < menuTabs.Length; t++)
            {
                if (menuTabs[t].transform.name == "ItemsTab")
                {
                    itemsTab = menuTabs[t];
                }
                else if (menuTabs[t].transform.name == "AudioDiariesTab")
                {
                    audioDiariesTab = menuTabs[t];
                }
                else if (menuTabs[t].transform.name == "NotesTab")
                {
                    notesTab = menuTabs[t];
                }
                else if (menuTabs[t].transform.name == "SystemTab")
                {
                    systemTab = menuTabs[t];
                }
            }

            if (!itemsTab || !audioDiariesTab || !notesTab || !systemTab)
            {
                Debug.LogError("FPEGameMenu:: Cannot find one or more of the menu tabs! Did you rename or remove them?");
            }

            // Find panels  - will need to be updated if you add or remove tabs
            inventoryItemInfoPanelParent = menuCanvas.gameObject.transform.Find("InventoryItemInfoPanel").gameObject;
            inventoryItemsListPanel      = menuCanvas.gameObject.transform.Find("InventoryListPanel").gameObject;
            audioDiariesPanel            = menuCanvas.gameObject.transform.Find("AudioDiariesPanel").gameObject;
            notesPanel = menuCanvas.gameObject.transform.Find("NotesPanel").gameObject;
            noteContentsPanelParent = menuCanvas.gameObject.transform.Find("NoteContentsPanel").gameObject;
            systemPanel             = menuCanvas.gameObject.transform.Find("SystemPanel").gameObject;
            exitConfirmationPanel   = menuCanvas.gameObject.transform.Find("ExitConfirmationPanel").gameObject;
            actionsPanelParent      = menuCanvas.gameObject.transform.Find("InventoryActionsPanel").gameObject;
            pageControlPanel        = menuCanvas.gameObject.transform.Find("PageControlsPanel").gameObject;

            if (!inventoryItemInfoPanelParent || !inventoryItemsListPanel || !audioDiariesPanel || !notesPanel || !noteContentsPanelParent || !systemPanel || !actionsPanelParent || !pageControlPanel)
            {
                Debug.LogError("FPEGameMenu:: Cannot find one or more of the menu panels! Did you rename or remove them?");
            }

            inventoryItemInfoPanelParent.SetActive(true);
            itemInfoPanel = inventoryItemInfoPanelParent.GetComponent <FPEInventoryItemInfoPanel>();

            if (itemInfoPanel == null)
            {
                Debug.LogError("FPEGameMenu:: InventoryItemInfoPanel is missing its 'FPEInventoryItemInfoPanel' (script) component! Did you remove it?");
            }

            actionsPanelParent.SetActive(true);
            inventoryActionsPanel = actionsPanelParent.GetComponent <FPEInventoryActionsPanel>();

            if (inventoryActionsPanel == null)
            {
                Debug.LogError("FPEGameMenu:: InventoryActionsPanel is missing its 'FPEInventoryActionsPanel' (script) component! Did you remove it?");
            }

            // Inventory item slots (We should have more than one of these)
            inventoryItemsListPanel.SetActive(true);
            inventorySlots = menuCanvas.gameObject.GetComponentsInChildren <FPEInventoryItemSlot>();

            if (inventorySlots == null || inventorySlots.Length < 2)
            {
                Debug.LogError("FPEGameMenu:: There are 1 or fewer inventory item slots on the inventory item panel! Things will break.");
            }

            // Audio diary slots (we should have more than one of these as well)
            audioDiariesPanel.SetActive(true);
            audioDiarySlots = menuCanvas.gameObject.GetComponentsInChildren <FPEAudioDiaryEntrySlot>();

            if (audioDiarySlots == null || audioDiarySlots.Length < 2)
            {
                Debug.LogError("FPEGameMenu:: There are 1 or fewer audio diary slots on the audio diary panel! Things will break.");
            }

            // Note slots (we should have more than one of these as well)
            notesPanel.SetActive(true);
            noteSlots = menuCanvas.gameObject.GetComponentsInChildren <FPENoteEntrySlot>();

            if (noteSlots == null || noteSlots.Length < 2)
            {
                Debug.LogError("FPEGameMenu:: There are 1 or fewer note slots on the notes panel! Things will break.");
            }

            noteContentsPanelParent.SetActive(true);
            noteContentsPanel = noteContentsPanelParent.GetComponent <FPENoteContentsPanel>();

            if (noteContentsPanel == null)
            {
                Debug.LogError("FPEGameMenu:: noteContentsPanel is missing its 'FPENoteContentsPanel' (script) component! Did you remove it?");
            }

            // Find all the system buttons
            systemPanel.SetActive(true);
            systemButtons = systemPanel.gameObject.GetComponentsInChildren <FPEMenuButton>();
            exitConfirmationPanel.SetActive(true);
            exitConfirmationButtons   = exitConfirmationPanel.gameObject.GetComponentsInChildren <FPEMenuButton>();
            mouseSensitivityValueText = systemPanel.gameObject.transform.Find("MouseSensitivityValue").GetComponent <Text>();
            lookSmoothingToggle       = systemPanel.gameObject.transform.Find("LookSmoothingToggle").GetComponent <FPEMenuToggle>();
            useGamepadToggle          = systemPanel.gameObject.transform.Find("UseGamepadToggle").GetComponent <FPEMenuToggle>();
            loadGameButton            = systemPanel.gameObject.transform.Find("LoadGameButton").GetComponent <FPEMenuButton>();

            if (!mouseSensitivityValueText || !lookSmoothingToggle || !useGamepadToggle || !loadGameButton)
            {
                Debug.LogError("FPEGameMenu:: mouseSensitivityValue Text, smoothing or gamepad toggle, or load game button component(s) are missing! Did you remove them?");
            }

            // Find Previous/Next page buttons and hints
            pageControlPanel.SetActive(true);
            previousPageButton = pageControlPanel.transform.Find("PreviousPageButton").gameObject;
            nextPageButton     = pageControlPanel.transform.Find("NextPageButton").gameObject;
            previousPageHint   = pageControlPanel.transform.Find("RightStickHintLeft").gameObject;
            nextPageHint       = pageControlPanel.transform.Find("RightStickHintRight").gameObject;
            pageIndicatorText  = pageControlPanel.transform.Find("PageIndicatorText").gameObject.GetComponent <Text>();

            if (!previousPageButton || !nextPageButton || !previousPageHint || !nextPageHint || !pageIndicatorText)
            {
                Debug.LogError("FPEGameMenu:: Page changing buttons, hints, or text are missing from InventoryListPanel! Did you remove them?");
            }

            // items per page and previous page selections for each tab
            itemsPerPage = new int[Enum.GetNames(typeof(eMenuTab)).Length];
            itemsPerPage[(int)eMenuTab.ITEMS]         = inventorySlots.Length;
            itemsPerPage[(int)eMenuTab.AUDIO_DIARIES] = audioDiarySlots.Length;
            itemsPerPage[(int)eMenuTab.NOTES]         = noteSlots.Length;

            previouslySelectedPage = new int[Enum.GetNames(typeof(eMenuTab)).Length];
            previouslySelectedPage[(int)eMenuTab.ITEMS]         = 0;
            previouslySelectedPage[(int)eMenuTab.AUDIO_DIARIES] = 0;

            previouslySelectedTab            = eMenuTab.ITEMS;
            previouslySelectedItemSlot       = inventorySlots[0];
            previouslySelectedAudioDiarySlot = audioDiarySlots[0];
            previouslySelectedNoteSlotIndex  = -1;
        }