Beispiel #1
0
    void CheckForInput(RaycastHit hit)
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            if (hit.collider.CompareTag("Door"))
            {
                Animator doorAnim = hit.collider.GetComponent <DoorScript>().GetAnim();
                doorAnim.SetBool("isOpen", !doorAnim.GetBool("isOpen"));
            }

            if (hit.collider.CompareTag("Mine"))
            {
                Tool       currTool = GetComponentInChildren <Tool>();
                MineScript mine     = hit.collider.GetComponent <MineScript>();
                if (interactText.activeInHierarchy)
                {
                    mine.SetToolIndex(mine.GetNeededToolIndex() + 1);

                    AudioManager.audioManager.PlaySound(currTool.GetSound(), transform.position);

                    if (mine.GetNeededToolIndex() == mine.GetLastToolIndex())
                    {
                        Manager.GetManager().RemoveMine(hit.collider.gameObject);
                        Manager.GetManager().AddMinesCount();
                        //canvas.SetActive(true);
                    }
                }
            }
        }
    }
Beispiel #2
0
    void CheckForDistance(RaycastHit hit)
    {
        if (hit.collider.CompareTag("Door"))
        {
            interactText.SetActive(true);
        }

        else if (hit.collider.CompareTag("Mine"))
        {
            Tool       currTool = GetComponentInChildren <Tool>();
            MineScript mine     = hit.collider.GetComponent <MineScript>();
            if (currTool.GetName() == mine.toolsToUse[mine.GetNeededToolIndex()])
            {
                interactText.SetActive(true);
            }
            else if (currTool.GetName() != mine.toolsToUse[mine.GetNeededToolIndex()])
            {
                interactText.SetActive(false);
            }
        }
    }