Advertisement
LukeWhite_Work

Door script

Dec 15th, 2017
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Door : MonoBehaviour {
  6.  
  7. public string requiredKey;
  8. private GameObject playerRef;
  9. private KeyInventory KeyInventory;
  10. private Animator doorAnimation;
  11. private BoxCollider collisionBox;
  12.  
  13.  
  14. public void DoesThePlayerHaveTheRightKeyOrNot()
  15. {
  16. foreach(string keyName in KeyInventory.Keys)
  17. {
  18. if(keyName == requiredKey)
  19. {
  20. doorAnimation.SetBool("Begin", true);
  21. Debug.Log("Player has key "+ keyName);
  22. }
  23. }
  24. }
  25.  
  26.  
  27. // Use this for initialization
  28. void Start () {
  29. playerRef = GameObject.Find("FirstPersonCharacter");
  30. KeyInventory = playerRef.GetComponent<KeyInventory>();
  31. doorAnimation = GetComponent<Animator>();
  32.  
  33. }
  34.  
  35. // Update is called once per frame
  36. void Update () {
  37.  
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement