Newer
Older
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
bool searched = false;
private EvidenceHandler e;
private Notebook n;
private CutsceneManager c;
Evidence[] clues;
// Start is called before the first frame update
void Start()
{
clues = this.gameObject.GetComponents<Evidence>();
e = FindObjectOfType<EvidenceHandler>();
n = FindObjectOfType<Notebook>();
c = FindObjectOfType<CutsceneManager>();
}
// Update is called once per frame
void Update()
{
if(allowInspection)
{
this.GetComponent<SpriteRenderer>().color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
} else
{
this.GetComponent<SpriteRenderer>().color = new Color(1.0f, 1.0f, 1.0f, 0.0f);
}
if(allowInspection && Input.GetButtonDown("Inspect") & !searched)
{
for(int i = 0; i < clues.Length; i++)
{
e.foundClues.Add(clues[i]);
n.AddClues(clues[i]);
}
searched = true;
}
}
private void OnTriggerEnter(Collider other)
{
if (other.tag == "Character")
allowInspection = true;
}
private void OnTriggerExit(Collider other)
{
if (other.tag == "Character")
allowInspection = false;
}
}