44 lines
1.1 KiB
C#

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<UIHandler>().showMessage("ERROR;You already tried this house");
}
else
{
int openChance = new System.Random().Next(4);
if(openChance == 0){
gameObject.GetComponent<Animator>().Play("DoorOpen");
}
else{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;This house is locked.");
}
}
hasInteracted = true;
}
}
}