private void InteractWithLockedDoor()
        {
            //if we have a door in range and the door is not unlocked
            if (_doorInRange != null && !_doorInRange.IsUnlocked)
            {
                //Check if we try to open it
                if (Input.GetKeyDown(KeyCode.E))
                {
                    //Get the door id
                    LockedDoorID doorID = _doorInRange.GetLockID();

                    //Search through the inventory for a matching key
                    InventorySlot[] slots = _playerInventory.GetFilledSlots();
                    foreach (InventorySlot slot in slots)
                    {
                        KeycardItem keycard = slot.item as KeycardItem;

                        if (keycard)
                        {
                            if (keycard.GetUnlockables() == doorID)
                            {
                                _doorInRange.Unlock();
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 // Update is called once per frame
 void DieCollision()
 {
     if (!dead)
     {
         dead = true;
         Instantiate(ps1.gameObject, gameObject.transform.position + new Vector3(0, 1, 0), Quaternion.identity);
         Instantiate(ps2.gameObject, gameObject.transform.position + new Vector3(0, 1, 0), Quaternion.identity);
         door.Unlock(this);
     }
 }