using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace Assets.Scripts { public class PlayerCamera : MonoBehaviour { UIHandler uihandler; // Start is called before the first frame update void Start() { uihandler = GameObject.Find("UIHandler").GetComponent(); } // Update is called once per frame void Update() { } private void FixedUpdate() { showInformation(); } public GameObject interactWithObject() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, 3)) { if (hit.collider.gameObject.tag.ToLower().Contains("object")) { return hit.collider.gameObject; } } return null; } void showInformation() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.forward, out hit, Mathf.Infinity)) { if (hit.collider.gameObject.tag.ToLower().Contains("object")) { string obj = hit.collider.gameObject.tag.Split(':')[1]; switch (obj.ToLower()) { case "tree": displayInformation("Tree"); break; case "stone": displayInformation("Stone"); break; case "npc": displayInformation("NPC"); break; case "enemy": displayInformation(hit.collider.gameObject.GetComponent().getEnemyName()); break; case "city": displayInformation("City"); break; case "house": displayInformation("House"); break; case "door": displayInformation("Exit"); break; case "chest": displayInformation("Chest"); break; default: uihandler.hideInformation(); break; } } else { uihandler.hideInformation(); } } else { uihandler.hideInformation(); } } private void displayInformation(string information) { if (!uihandler.isPlayerInFight()) { uihandler.displayInformation(information); } else { uihandler.hideInformation(); } } } }