Beispiel #1
0
 private void Start()
 {
     if (isOnRightController)
     {
         controller = car.castRayRightController;
     }
     else
     {
         controller = car.castRayLeftController;
     }
 }
Beispiel #2
0
    private void Update()
    {
        if (Input.GetKeyDown("escape"))
        {
            MasterScript.EnableCAM1();
        }

        //check for object on layer OS
        if (CastRay.Shoot(this.GetComponent <Camera>(), layerMask, range)) //(OPTIMISE LATER: shoot only when mouse moves)
        {
            //if the detected Object has IsOS Component
            if (CastRay.detected.GetComponent <IsOS>() != null)
            {
                //if that OS object is clickable
                if (CastRay.detected.GetComponent <IsOS>().clickable)
                {
                    //CODE HERE WILL RUN IF HOVERING ON CLICKABLE OBJECT
                    OSManager.runHoverFunction();
                    MasterScript.EnableCrosshairAll();
                    MasterScript.toast(CastRay.detected.GetComponent <IsOS>().text);
                    if (Input.GetMouseButtonDown(0)) //if clicked on the clickable object
                    {
                        OSManager.runClickFunction();
                    }
                }
                else //if the object has IsOS component but isn't clickable
                {
                    MasterScript.DisableCrosshairDark();
                    MasterScript.HideSubText();
                    DesktopManager.disableAllBlack();
                }
            }
            else //if detected object doesn't have a IsOS component
            {
                MasterScript.inactive();
                DesktopManager.disableAllBlack();
                if (Input.GetMouseButtonDown(0))
                {
                    LoginManager.inputDeselected();
                }
            }
        }
        else //if no object detected by ray
        {
            MasterScript.inactive();
            DesktopManager.disableAllBlack();
        }
    } //update close
Beispiel #3
0
    private void inspectMode()
    {
        if (Input.GetMouseButton(0))
        {
            onMouseDrag();
        }

        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            MasterScript.CAM1.GetComponent <Camera>().fieldOfView -= zoomSpeed * Time.deltaTime;
        }
        else if ((Input.GetAxis("Mouse ScrollWheel") < 0f))
        {
            MasterScript.CAM1.GetComponent <Camera>().fieldOfView += zoomSpeed * Time.deltaTime;
        }



        if (CastRay.Shoot(this.GetComponent <Camera>(), inspectLayer, shootRange))
        {
            if (CastRay.detected.GetComponent <Inspectable>() != null)
            {
                MasterScript.EnableCrosshairAll();
                Inspectable inspectableScript = CastRay.detected.GetComponent <Inspectable>();
                MasterScript.toast(inspectableScript.text);

                if (Input.GetKeyDown(KeyCode.E))
                {
                    Inspectable.useInspectable();
                }
            }
            else
            {
                MasterScript.inactive();
            }
        }    // shoot close

        else //if nothing is hit
        {
            MasterScript.inactive();
        }
    }
Beispiel #4
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();
        }
    }