Ejemplo n.º 1
0
    private void RayToDoor()
    {
        Ray        ray = new Ray(playerView.transform.position, playerView.transform.forward);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, MAXDISTANCEOFRAY))
        {
            if (Input.GetKeyDown(leftMouseKeyDown))
            {
                if (hit.collider.gameObject.layer == LayerMask.NameToLayer("Buttons"))
                {
                    currentButtonState   = hit.collider.gameObject.GetComponent <ButtonClicked>();
                    currentDoorTransform = hit.collider.gameObject.GetComponentInParent <DoorIsOpenedAndClosed>();
                    doorOpenCloseSound   = hit.collider.gameObject.GetComponentInParent <DoorOpenColseSound>();
                    currentButtonState.ButtonClick();
                    doorOpenCloseSound.PlayClip();

                    if (emergencyLights.GetLightState() != LightsState.Off)
                    {
                        currentDoorTransform.SetDoorIsOpened();
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
 // Use this for initialization
 void Awake()
 {
     doorOpenedAndClosed = GetComponent <DoorIsOpenedAndClosed>();
     emergencyLights     = GameObject.FindGameObjectWithTag("LightState").GetComponent <EmergencyLights>();
     sourceOfDoorSounds  = GetComponent <AudioSource>();
     doorOpenSound       = Resources.Load("Switches/ClickOn", typeof(AudioClip)) as AudioClip;
     doorCloseSound      = Resources.Load("Switches/ClickOn", typeof(AudioClip)) as AudioClip;
 }