Exemple #1
0
    public void Update()
    {
        if (!MasterScript.inspecting)
        {
            defaultMode();
        }

        else if (MasterScript.inspecting)
        {
            inspectMode();
            if (Input.GetKeyDown("escape"))
            {
                IsInteractive.Deselect();
                MasterScript.setDefaultFOV();
            }
        }
    } //update close
Exemple #2
0
    //runs when E is pressed on Interactive Object
    public static void doStuff()
    {
        IsInteractive interactiveObjectScript = CastRay.detected.GetComponent <IsInteractive>();

        switch (CastRay.detected.tag)
        {
        case "Drawer":
            if (interactiveObjectScript.isInteractedWith == false)
            {
                CastRay.detected.transform.Translate(0.0f, 0f, 0.35f);
                interactiveObjectScript.isInteractedWith = true;
                AudioManager.DrawerOpenSFX();
            }
            else
            {
                CastRay.detected.transform.Translate(0.0f, 0f, -0.35f);
                interactiveObjectScript.isInteractedWith = false;
                AudioManager.DrawerCloseSFX();
            }
            break;


        case "Computer":
            MasterScript.EnableCAM2();
            break;


        case "lookable":

            //if the object isn't already interactedWith && not currently inspecting anything else
            if (!interactiveObjectScript.isInteractedWith && !MasterScript.inspecting)
            {
                Transform camTransform = MasterScript.CAM1.transform;
                Select(camTransform.position + camTransform.forward * 0.4f, camTransform.position);
            }
            break;

        case "Keyboard":
            GameObject.Find("MidiKeyboard").GetComponent <AudioSource>().Play();
            break;

        default:
            Debug.Log("default interactive object");
            break;
        } // switch close
    }     //doStuff() close
Exemple #3
0
    } //update close

    private void defaultMode()
    {
        //if something is hit in layer default within range
        if (CastRay.Shoot(this.GetComponent <Camera>(), defaultLayer, shootRange))
        {
            //if that hit object is Interactive, show subtext & check if can be used.
            if (CastRay.detected.GetComponent <IsInteractive>() != null)
            {
                IsInteractive usableObject = CastRay.detected.GetComponent <IsInteractive>();
                MasterScript.toast(usableObject.displayText);

                //if that object is usable- turn on crosshair and on pressing E run doStuff().
                if (usableObject.canBeUsed)
                {
                    MasterScript.EnableCrosshairAll();
                    if (Input.GetKeyDown(KeyCode.E))
                    {
                        IsInteractive.doStuff();
                    }
                }
                else
                {
                    MasterScript.EnableCrosshairRed();
                }
            }

            else //and if that hit object is not Interactive.
            {
                MasterScript.inactive();
            }
        }    //shoot close

        else //if nothing is hit
        {
            MasterScript.inactive();
        }
    }