using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class clueObject : MonoBehaviour { public bool allowInspection = false; 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" && !searched) allowInspection = true; } private void OnTriggerExit(Collider other) { if (other.tag == "Character") allowInspection = false; } }