예제 #1
0
    /// <summary>
    /// Used when code is typed corectly
    /// </summary>
    public void ButtonInteract()
    {
        codeUI.SetActive(false);
        Cursor.lockState        = CursorLockMode.Locked;
        Cursor.visible          = false;
        sterowanie.active       = true;
        playerRigid.constraints = RigidbodyConstraints.FreezeRotation;

        backupButton.Interact();
        backupButton = null;
    }
예제 #2
0
    void CheckRayHit()
    {
        RaycastHit hit;

        if (Physics.Raycast(playerCam.transform.position, playerCam.transform.forward, out hit, rayDistance, raycastLayer))
        {
            if (hit.collider.GetComponent <Interactable>() != null)
            {
                if (hit.collider.GetComponent <MAIPA.Interactable.Button>() != null)
                {
                    if (!hit.collider.GetComponent <MAIPA.Interactable.Button>().isInteractable())
                    {
                        return;
                    }
                }

                interactableText.SetActive(true);
                if (Input.GetKeyDown(KeyCode.E))
                {
                    if (hit.collider.GetComponent <Item>() != null)
                    {
                        PickupItem(hit.collider.GetComponent <Item>());
                        hit.collider.GetComponent <Interactable>().Interact();
                    }
                    else if (hit.collider.GetComponent <MAIPA.Interactable.Button>() != null)
                    {
                        MAIPA.Interactable.Button btn = hit.collider.GetComponent <MAIPA.Interactable.Button>();
                        ButtonCheck(btn);
                    }
                    else
                    {
                        hit.collider.GetComponent <Interactable>().Interact();
                    }
                }
            }
            else
            {
                interactableText.SetActive(false);
            }
        }
        else
        {
            interactableText.SetActive(false);
        }
    }
예제 #3
0
    void Update()
    {
        time -= Time.deltaTime;
        CheckRayHit();

        if (Input.GetKeyDown(KeyCode.Q) && time <= 0 && playerState == PlayerState.Playing)
        {
            if (!pickedUpItem)
            {
                DropItem();
            }
        }

        // Open/Close Inventory
        if (Input.GetKeyDown(KeyCode.I) && time <= 0 && (playerState == PlayerState.Playing || playerState == PlayerState.InInvetory))
        {
            if (inventoryUI.activeSelf)
            {
                inventoryUI.SetActive(false);
                Cursor.lockState        = CursorLockMode.Locked;
                Cursor.visible          = false;
                sterowanie.active       = true;
                playerRigid.constraints = RigidbodyConstraints.FreezeRotation;
                playerState             = PlayerState.Playing;
            }
            else
            {
                inventoryUI.SetActive(true);
                Cursor.lockState  = CursorLockMode.None;
                Cursor.visible    = true;
                sterowanie.active = false;
                inventory.Refresh();
                time = betweenInputs;
                playerRigid.constraints = RigidbodyConstraints.FreezeAll;
                playerState             = PlayerState.InInvetory;
            }
        }

        // Open/Close Pause Menu Or Close CodeUI
        if (Input.GetKeyDown(KeyCode.Escape) && time <= 0 && (playerState == PlayerState.Playing || playerState == PlayerState.Paused || playerState == PlayerState.Decoding))
        {
            if (codeUI.activeSelf)
            {
                codeUI.SetActive(false);
                Cursor.lockState        = CursorLockMode.Locked;
                Cursor.visible          = false;
                sterowanie.active       = true;
                playerRigid.constraints = RigidbodyConstraints.FreezeRotation;

                backupButton = null;
                playerState  = PlayerState.Playing;
            }
            else
            {
                if (pauseMenuUI.activeSelf)
                {
                    pauseMenuUI.SetActive(false);
                    Cursor.lockState        = CursorLockMode.Locked;
                    Cursor.visible          = false;
                    sterowanie.active       = true;
                    playerRigid.constraints = RigidbodyConstraints.FreezeRotation;
                    playerState             = PlayerState.Playing;
                }
                else
                {
                    pauseMenuUI.SetActive(true);
                    Cursor.lockState  = CursorLockMode.None;
                    Cursor.visible    = true;
                    sterowanie.active = false;
                    time = betweenInputs;
                    playerRigid.constraints = RigidbodyConstraints.FreezeAll;
                    playerState             = PlayerState.Paused;
                }
            }
        }

        // Changing Selected Slot
        if (playerState == PlayerState.Playing)
        {
            if (Input.GetKey(KeyCode.Alpha1) || Input.GetKey(KeyCode.Keypad1))
            {
                selectedSlot = 0;
                RefreshSelectedSlot();
            }

            if (Input.GetKey(KeyCode.Alpha2) || Input.GetKey(KeyCode.Keypad2))
            {
                selectedSlot = 1;
                RefreshSelectedSlot();
            }

            if (Input.GetKey(KeyCode.Alpha3) || Input.GetKey(KeyCode.Keypad3))
            {
                selectedSlot = 2;
                RefreshSelectedSlot();
            }

            if (Input.GetKey(KeyCode.Alpha4) || Input.GetKey(KeyCode.Keypad4))
            {
                selectedSlot = 3;
                RefreshSelectedSlot();
            }

            if (Input.mouseScrollDelta.y != 0)
            {
                int toAdd = (int)Input.mouseScrollDelta.y % 4;
                if (selectedSlot + toAdd > 3)
                {
                    toAdd = toAdd - 4;
                }
                if (selectedSlot + toAdd < 0)
                {
                    toAdd = toAdd + 4;
                }
                selectedSlot += toAdd;
                RefreshSelectedSlot();
            }
        }
    }
예제 #4
0
    //Button:
    void ButtonCheck(MAIPA.Interactable.Button btn)
    {
        if (btn.isItemNeeded)
        {
            bool isId = false;
            foreach (var id in btn.itemIds)
            {
                if (choosedItemID == id)
                {
                    isId = true;
                    break;
                }
            }

            if (isId)
            {
                if (btn.isCoded)
                {
                    codeUI.SetActive(true);
                    Cursor.lockState  = CursorLockMode.None;
                    Cursor.visible    = true;
                    sterowanie.active = false;
                    time = betweenInputs;
                    playerRigid.constraints = RigidbodyConstraints.FreezeAll;
                    playerState             = PlayerState.Decoding;


                    codeHandler.codeType = btn.codeType;
                    if (btn.codeType == CodeType.TEXT_CODE)
                    {
                        codeHandler.SetTextCode(btn.textCode);
                    }
                    else if (btn.codeType == CodeType.NUM_CODE)
                    {
                        codeHandler.SetNumCode(btn.num1, btn.num2, btn.num3, btn.num4);
                    }
                    codeHandler.UpdateUI();
                    backupButton = btn;
                }
                else
                {
                    btn.Interact();
                }
            }
            else
            {
                if (!itemIsNeededText.activeSelf)
                {
                    itemIsNeededText.SetActive(true);
                }
                else
                {
                    itemIsNeededText.SetActive(false);
                    itemIsNeededText.SetActive(true);
                }
            }
        }
        else
        {
            if (btn.isCoded)
            {
                codeUI.SetActive(true);
                Cursor.lockState  = CursorLockMode.None;
                Cursor.visible    = true;
                sterowanie.active = false;
                time = betweenInputs;
                playerRigid.constraints = RigidbodyConstraints.FreezeAll;
                playerState             = PlayerState.Decoding;


                codeHandler.codeType = btn.codeType;
                if (btn.codeType == CodeType.TEXT_CODE)
                {
                    codeHandler.SetTextCode(btn.textCode);
                }
                else if (btn.codeType == CodeType.NUM_CODE)
                {
                    codeHandler.SetNumCode(btn.num1, btn.num2, btn.num3, btn.num4);
                }
                codeHandler.UpdateUI();
                backupButton = btn;
            }
            else
            {
                btn.Interact();
            }
        }
    }