public void End() { isActive = false; doorState = door.GetComponent <AnimStates>(); anim = door.GetComponent <Animation>(); anim.Play(doorState.states[doorState.getState()]); doorState.incState(); door.tag = "Untagged"; }
public void Begin() { isActive = true; doorState = door.GetComponent <AnimStates>(); anim = door.GetComponent <Animation>(); anim.Play(doorState.states[doorState.getState()]); doorState.incState(); door.tag = "LockedDoor"; }
// 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; } } } } }