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();
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
    public bool doWeHaveKeycardOfClearance(int clearance)
    {
        foreach (Item i in inventoryItems)
        {
            KeycardItem k = i.gameObject.GetComponent <KeycardItem> ();

            if (k == null)
            {
            }
            else
            {
                if (k.securityClearance == clearance)
                {
                    return(true);
                }
            }
        }
        return(false);
    }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Keycard"/> class.
 /// </summary>
 /// <param name="itemBase"><inheritdoc cref="Base"/></param>
 public Keycard(KeycardItem itemBase)
     : base(itemBase)
 {
     Base = itemBase;
 }
Esempio n. 4
0
    void initialiseLockActions()
    {
        RoomScript myRoom     = LevelController.me.getRoomObjectIsIn(this.gameObject);
        string     myRoomText = "";

        if (myRoom == null)
        {
        }
        else
        {
            myRoomText = "The door is located in " + myRoom.roomName + ".";
        }

        if (wayIAmLocked == lockedWith.key)
        {
            this.gameObject.AddComponent <PlayerAction_UnlockWithLockpick> ();
            //this.gameObject.AddComponent<PlayerAction_KickInDoor> ();
            GameObject key = Instantiate(CommonObjectsStore.me.keyBase, new Vector3(0, 0, 0), Quaternion.Euler(0, 0, 0));
            Item       i   = key.GetComponent <Item> ();
            Container  toSpawnIn;

            if (placesToSpawnUnlockItems.Count > 0)
            {
                toSpawnIn = placesToSpawnUnlockItems [Random.Range(0, placesToSpawnUnlockItems.Count)];
            }
            else
            {
                toSpawnIn = FindObjectOfType <Container> ();
            }
            key.transform.position = toSpawnIn.gameObject.transform.position;
            toSpawnIn.addItemToContainer(i);
            ////////Debug.Log ("Spawned key in " + toSpawnIn.gameObject.name);
            myKey              = key;
            i.itemDescription += myRoomText;
            this.gameObject.AddComponent <PlayerAction_UnlockWithKey> ();
            this.gameObject.AddComponent <PlayerAction_OpenDoorWithExplosives> ();
        }
        else if (wayIAmLocked == lockedWith.keycard)
        {
            this.gameObject.AddComponent <PlayerAction_OpenDoorWithExplosives> ();
            GameObject  key = Instantiate(CommonObjectsStore.me.keycardBase, new Vector3(0, 0, 0), Quaternion.Euler(0, 0, 0));
            KeycardItem i   = key.GetComponent <KeycardItem> ();
            Container   toSpawnIn;
            if (placesToSpawnUnlockItems.Count > 0)
            {
                toSpawnIn = placesToSpawnUnlockItems [Random.Range(0, placesToSpawnUnlockItems.Count)];
            }
            else
            {
                toSpawnIn = FindObjectOfType <Container> ();
            }
            toSpawnIn.addItemToContainer(i);
            if (i.securityClearance == 0)               //TODO add way to manually set security tier
            {
                securityTier = Random.Range(1, 4);
            }
            i.securityClearance = securityTier;
            //i.itemDescription += myRoomText;

            ////////Debug.Log ("Spawned keycard in " + toSpawnIn.gameObject.name);
            myKey = key;
            this.gameObject.AddComponent <PlayerAction_OpenWithKeycard> ();
            key.transform.position = toSpawnIn.transform.position;
        }
        else if (wayIAmLocked == lockedWith.passcode)
        {
            this.gameObject.AddComponent <PlayerAction_OpenDoorWithExplosives> ();
            if (keycodeNumber < 1000)
            {
                keycodeNumber = Random.Range(1000, 9999);
            }

            //create note for door
            ////////Debug.Log ("Keycode number was " + keycodeNumber);
            this.gameObject.AddComponent <PlayerAction_OpenDoorWithKeycode> ();

            GameObject g = (GameObject)Instantiate(CommonObjectsStore.me.noteBase, Vector3.zero, Quaternion.Euler(0, 0, 0));
            myCode = g;
            NoteItem   i = g.GetComponent <NoteItem> ();
            RoomScript r = LevelController.me.getRoomObjectIsIn(g);

            if (r == null)
            {
                i.noteText = "Here is the passcode for the door, its " + keycodeNumber.ToString() + ". Please destroy this note when you memorise it." + myRoomText;
            }
            else
            {
                i.noteText = "Here is the passcode for the door in the " + r.roomName + ", its " + keycodeNumber.ToString() + ". Please destroy this note when you memorise it." + myRoomText;
            }

            Container toSpawnIn;
            if (placesToSpawnUnlockItems.Count > 0)
            {
                toSpawnIn = placesToSpawnUnlockItems [Random.Range(0, placesToSpawnUnlockItems.Count)];
            }
            else
            {
                toSpawnIn = FindObjectOfType <Container> ();
            }
            toSpawnIn.addItemToContainer(i);
            g.transform.position = toSpawnIn.transform.position;

            ////////Debug.Log ("Created note with passcode in " + toSpawnIn.name);
        }
        else if (wayIAmLocked == lockedWith.vaultDoor)
        {
        }
        else if (wayIAmLocked == lockedWith.computer)
        {
            this.gameObject.AddComponent <PlayerAction_OpenDoorWithExplosives> ();
        }
        else if (wayIAmLocked == lockedWith.none)
        {
            //this.gameObject.AddComponent<PlayerAction_KickInDoor> ();
            this.gameObject.AddComponent <PlayerAction_OpenDoorWithExplosives> ();
        }
    }