2021-02-19 16:14:14 +01:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2021-02-19 21:38:45 +01:00
|
|
|
using Ktyl.Util;
|
2021-02-19 16:14:14 +01:00
|
|
|
|
|
|
|
public class ArtefactControl : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
private bool _show;
|
|
|
|
private bool _canInteract;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private Artefact data;
|
|
|
|
public int artefactID => _artefactID;
|
|
|
|
private int _artefactID;
|
|
|
|
private string _artefactDialogue;
|
2021-02-19 21:38:45 +01:00
|
|
|
[SerializeField] private SerialInt _nearbyArtefactID;
|
2021-02-19 16:14:14 +01:00
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
_artefactID = data.artefactID;
|
|
|
|
_artefactDialogue = data.artefactDialogue;
|
|
|
|
_show = data.show;
|
|
|
|
_canInteract = data.canInteract;
|
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
ArtefactInventory.addA(data);
|
|
|
|
foreach (var x in ArtefactInventory.artefactList)
|
|
|
|
{
|
|
|
|
Debug.Log(x.ToString());
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
//here put 'show artifact dialogue'
|
|
|
|
if (this.gameObject != null)
|
|
|
|
Destroy(this.gameObject);
|
2021-02-22 10:01:33 +01:00
|
|
|
_nearbyArtefactID.Value = -1;
|
2021-02-19 21:38:45 +01:00
|
|
|
//PlayerInputHandler.id = 0;
|
2021-02-19 16:14:14 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void OnGUI()
|
|
|
|
{
|
|
|
|
if (_show)
|
|
|
|
{
|
|
|
|
GUI.Label(new Rect(Screen.width / 2 - 50, 5, 100, 100), "Press E to pickup");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|