Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        Ray        ray = new Ray(transform.position, transform.forward);
        RaycastHit hit = new RaycastHit();

        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            if (hit.transform.GetComponent <SwitchEngine>() != null)
            {
                SwitchEngine switchEngine = hit.transform.GetComponent <SwitchEngine>();
                // switchEngine.ShowMouseOverObject();
                if (Input.GetKeyDown(KeyCode.Joystick1Button5) || Input.GetKeyDown(KeyCode.Joystick1Button4))
                {
                    if (Services.DayCycleManager.dayHasEnded)
                    {
                        Debug.Log("switch!!!");
                        // switchEngine.AnimateButtonPress();
                        // switchEngine.myName = "Close up.";
                        audioController.spotlightSfx.PlayScheduled(AudioSettings.dspTime);
                        // switchEngine.HideMouseOverObject();
                        // foreach(Light light in lights){
                        //  light.enabled = false;
                        // }
                        GetComponentInParent <InteractionManager>().enabled    = false;
                        GetComponentInParent <FirstPersonController>().enabled = false;
                        Services.DayCycleManager.switchOff = true;
                        // fpc.enabled = false;
                        //this.enabled = false;
                    }
                    else
                    {
                        // switchEngine.myName = "Close up.";
                        Debug.Log("Some customers still need you.");
                    }
                }
            }
            else
            {
            }
        }
    }
Exemplo n.º 2
0
    void ObjectNameRay()
    {
        Ray        ray     = new Ray(transform.position, transform.forward);
        float      rayDist = Mathf.Infinity;
        RaycastHit hit     = new RaycastHit();

        if (Physics.Raycast(ray, out hit, rayDist))
        {
            GameObject hitObj = hit.transform.gameObject;
            if (hitObj.GetComponent <Interactable>() != null)
            {
                Interactable thisObj = hitObj.GetComponent <Interactable>();
                UpdateDescriptionText(thisObj.myName);
            }
            else if (hitObj.GetComponent <SwitchEngine>() != null)
            {
                SwitchEngine thisSwitch = hitObj.GetComponent <SwitchEngine>();
                UpdateDescriptionText(thisSwitch.myName);
            }
            //only check if you're looking at a coaster if you're holding something
        }
    }