Exemplo n.º 1
0
    //public void OnMouseUp()
    //{
    //    //StartCoroutine(WaitToClickRoom());
    //    //clickAgain = true;

    //    mouseReleased = true;
    //}

    public void OnMouseOver()
    {
        //if(preplacedRoom) return;

        if (GameManager.instance.currentGameState == InGameStates.ShipBuilding && clickAgain == true && !FindObjectOfType <CrewManagementAlertConfirmation>().AlertPanel.activeSelf) // && PauseMenu.Instance.isPaused == false// commented out until menus are ready
        {
            if (ObjectMover.hasPlaced && !PauseMenu.IsPaused)
            {
                roomTooltip.SetActive(true);
                roomIsHovered = true;
            }
            else if (roomTooltip.activeSelf)
            {
                roomTooltip.SetActive(false);
            }

            //if(preplacedRoom) return; // could moved preplacedRoom check here so tooltip can be activated.

            if (Input.GetMouseButtonDown(0) && ObjectMover.hasPlaced == true && !gameObject.GetComponent <ObjectMover>().enabled&& preplacedRoom == false)
            {
                //buttons.SetActive(true);
                AudioManager.instance.PlaySFX(mouseOverAudio[Random.Range(0, mouseOverAudio.Length - 1)]);

                CrewViewManager.Instance.DisableCrewView();
                if (FindObjectOfType <RoomPanelToggle>().GetIsOpen() == true)
                {
                    FindObjectOfType <RoomPanelToggle>().TogglePanelVis(0);
                }

                Edit();
            }
        }

        if ((GameManager.instance.currentGameState == InGameStates.Events || GameManager.instance.currentGameState == InGameStates.ShipBuilding && !FindObjectOfType <CrewManagementAlertConfirmation>().AlertPanel.activeSelf) &&
            !OverclockController.instance.overclocking && !EventSystem.instance.eventActive && !EventSystem.instance.NextEventLockedIn && !PauseMenu.IsPaused)
        {
            roomTooltip.SetActive(true);
            roomIsHovered = true;

            //if the object is clicked, open the room management menu
            if (Input.GetMouseButtonDown(1) && ObjectMover.hasPlaced == true && !gameObject.GetComponent <ObjectMover>().enabled)
            {
                //FindObjectOfType<CrewManagement>().UpdateRoom(gameObject);
                //FindObjectOfType<RoomPanelToggle>().TogglePanelVis(0);

                if (gameObject == roomDetailsMenu.selectedRoom)
                {
                    FindObjectOfType <RoomPanelToggle>().TogglePanelVis(0);
                }
                else
                {
                    FindObjectOfType <RoomPanelToggle>().OpenPanel(0);
                    //Enables Crew View while details panel is open
                    CrewViewManager.Instance.EnableCrewView();
                }
                roomDetailsMenu.ChangeCurrentRoom(gameObject);


                //FindObjectOfType<CrewManagementRoomDetailsMenu>().UpdatePanelInfo();
                AudioManager.instance.PlaySFX(mouseOverAudio[Random.Range(0, mouseOverAudio.Length - 1)]);

                //Closes the shop window if open during shipbuilding
                if (GameManager.instance.currentGameState == InGameStates.ShipBuilding)
                {
                    RoomPanelToggle[] panels = FindObjectsOfType <RoomPanelToggle>();
                    for (int i = 1; i < 2; i++)
                    {
                        panels[i].ClosePanel();
                    }
                }
            }
        }
    }