revival/game/Assets/Scripts/Artefacts/Artefact.cs

69 lines
1.4 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Artefact : MonoBehaviour
{
public int artefactID;
public enum Type { PhysicalArtefact, PowerArtefact, WrittenArtefact }
public string artefactDialogue;
private bool show = false;
public bool canInteract = false;
private void Start()
{
EventHandler.current.onArtefactTriggerEnter += NearArtefact;
EventHandler.current.onArtefactTriggerExit += AwayArtefact;
EventHandler.current.onArtefactPickUp += PickUp;
}
private void NearArtefact(int id)
{
if(id == this.artefactID)
{
show = true;
this.canInteract = true;
}
}
private void AwayArtefact(int id)
{
if(id == this.artefactID)
{
show = false;
this.canInteract = false;
}
}
private void PickUp(int id)
{
if (id == this.artefactID)
{
if ( canInteract == true )
{
foreach (var x in ArtefactInventory.artefactList)
{
Debug.Log(x.ToString());
}
ArtefactInventory.addA(this);
}
//show artifact dialogue
}
}
void OnGUI()
{
if(show)
{
GUI.Label(new Rect(Screen.width / 2 - 50, 5, 100, 100), "Press E to pickup");
}
}
}