Esempio n. 1
0
 public void End()
 {
     isActive  = false;
     doorState = door.GetComponent <AnimStates>();
     anim      = door.GetComponent <Animation>();
     anim.Play(doorState.states[doorState.getState()]);
     doorState.incState();
     door.tag = "Untagged";
 }
Esempio n. 2
0
 public void Begin()
 {
     isActive  = true;
     doorState = door.GetComponent <AnimStates>();
     anim      = door.GetComponent <Animation>();
     anim.Play(doorState.states[doorState.getState()]);
     doorState.incState();
     door.tag = "LockedDoor";
 }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (Physics.Raycast(transform.position, transform.forward, out hit, rayDistance))
            {
                if (hit.collider)
                {
                    if (hit.collider.gameObject.tag == "GenericDoor")
                    {
                        doorHit = 1;    // Normal door
                    }

                    else if (hit.collider.gameObject.tag == "LockedDoor")
                    {
                        doorHit = 2;    // Locked door
                    }

                    if (doorHit > 0)
                    {
                        bool        locked      = false;
                        PlayerLogic playerLogic = player.GetComponent <PlayerLogic>();
                        door = hit.collider.gameObject;

                        if (doorHit == 2)
                        {
                            LockState lockState = door.GetComponent <LockState>();
                            string    key       = lockState.getKeyName();

                            if (playerLogic.HasItem(key))
                            {
                                lockState.unlock();
                            }

                            locked = lockState.getState();
                        }

                        if (locked == false)
                        {
                            door.GetComponent <AudioSource>().Play();
                            doorState = door.GetComponent <AnimStates>();
                            Animation anim = door.GetComponent <Animation>();
                            anim.Play(doorState.states[doorState.getState()]);
                            doorState.incState();

                            if (doorHit == 2)
                            {
                                door.tag = "GenericDoor";
                            }
                        }
                        else
                        {
                            _AudioSource.Stop();
                            _AudioSource.clip = clipLocked;
                            _AudioSource.Play();
                        }

                        doorHit = 0;
                    }
                }
            }
        }
    }