You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rua/Script/NonPlayerCharacter.cs

40 lines
899 B

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NonPlayerCharacter : MonoBehaviour
{
public float displayTime = 4.0f;
public GameObject dialogBox;
float timerDisplay;
Vector2 lookDirection = new Vector2(0, -1);
void Start()
{
dialogBox.SetActive(false);
timerDisplay = -1.0f;
RaycastHit2D hit = Physics2D.Raycast(transform.position, lookDirection, 1.0f, LayerMask.GetMask("Cells"));
hit.collider.GetComponent<Cell>().SetOccupied(true);
}
void Update()
{
if (timerDisplay >= 0)
{
timerDisplay -= Time.deltaTime;
if (timerDisplay < 0)
{
dialogBox.SetActive(false);
}
}
}
public void DisplayDialog()
{
timerDisplay = displayTime;
dialogBox.SetActive(true);
}
}