using System.Collections; using System.Collections.Generic; using UnityEngine; using System; namespace Assets.Scripts { public class Door : MonoBehaviour { bool hasInteracted; // Start is called before the first frame update void Start() { hasInteracted = false; } // Update is called once per frame void Update() { } public void interact() { if (hasInteracted) { GameObject.Find("UIHandler").GetComponent().showMessage("ERROR;You already tried this house"); } else { int openChance = new System.Random().Next(4); if(openChance == 0){ gameObject.GetComponent().Play("DoorOpen"); } else{ GameObject.Find("UIHandler").GetComponent().showMessage("ERROR;This house is locked."); } } hasInteracted = true; } } }