artefactUI now works

This commit is contained in:
Novvator 2021-03-02 16:33:31 +00:00
parent 81ef58415a
commit af34631ed8
9 changed files with 554 additions and 307 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11,6 +11,9 @@ public class Artefact : ScriptableObject
public string artefactDialogue => _artefactDialogue; public string artefactDialogue => _artefactDialogue;
[SerializeField] private string _artefactDialogue; [SerializeField] private string _artefactDialogue;
public string Name => _name;
[SerializeField] private string _name;
public bool show => _show; public bool show => _show;
private bool _show = false; private bool _show = false;
public bool canInteract => _canInteract; public bool canInteract => _canInteract;

View File

@ -10,19 +10,19 @@ public class ArtefactControl : MonoBehaviour
private bool _show; private bool _show;
protected bool _canInteract; protected bool _canInteract;
[SerializeField] public Artefact data => _data;
private Artefact data; [SerializeField] private Artefact _data;
public int artefactID => _artefactID; public int artefactID => _artefactID;
private int _artefactID; private int _artefactID;
private string _artefactDialogue; private string _artefactDialogue;
[SerializeField] private SerialInt _nearbyArtefactID; [SerializeField] private SerialInt _nearbyArtefactID;
protected virtual void Start() protected virtual void Awake()
{ {
_artefactID = data.artefactID; _artefactID = _data.artefactID;
_artefactDialogue = data.artefactDialogue; _artefactDialogue = _data.artefactDialogue;
_show = data.show; _show = _data.show;
_canInteract = data.canInteract; _canInteract = _data.canInteract;
EventHandler.current.onArtefactTriggerEnter += NearArtefact; EventHandler.current.onArtefactTriggerEnter += NearArtefact;
EventHandler.current.onArtefactTriggerExit += AwayArtefact; EventHandler.current.onArtefactTriggerExit += AwayArtefact;
@ -56,17 +56,18 @@ public class ArtefactControl : MonoBehaviour
{ {
if (_canInteract == true) if (_canInteract == true)
{ {
ArtefactInventory.addA(data); ArtefactInventory.addA(_data);
foreach (var x in ArtefactInventory.artefactList) //debug ArtefactInventory
{ //foreach (var x in ArtefactInventory.artefactList)
Debug.Log(x.ToString()); //{
} // Debug.Log(x.ToString());
//}
} }
//here put 'show artifact dialogue' //here put 'show artifact dialogue'
if (this.gameObject != null) if (this.gameObject != null)
{ {
data.PowerUnlock(); _data.PowerUnlock();
_nearbyArtefactID.Value = -1; _nearbyArtefactID.Value = -1;
_canInteract = false; _canInteract = false;
EventHandler.current.ArtefactUI(); EventHandler.current.ArtefactUI();

View File

@ -8,6 +8,7 @@ public class ArtefactInventory : ScriptableObject
public static List<Artefact> artefactList = new List<Artefact>(); public static List<Artefact> artefactList = new List<Artefact>();
private static bool exists = false; private static bool exists = false;
public static void addA(Artefact a) public static void addA(Artefact a)
{ {
//check if duplicate in the list //check if duplicate in the list

View File

@ -10,8 +10,9 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0228856d50ce2a845abd7b3eda114390, type: 3} m_Script: {fileID: 11500000, guid: 0228856d50ce2a845abd7b3eda114390, type: 3}
m_Name: Power1 m_Name: PowerBlink
m_EditorClassIdentifier: m_EditorClassIdentifier:
_power: {fileID: 11400000, guid: b47ea197a7cc2ed4eb15271cef672997, type: 2} _power: {fileID: 11400000, guid: b47ea197a7cc2ed4eb15271cef672997, type: 2}
_artefactID: 1 _artefactID: 1
_artefactDialogue: _artefactDialogue:
_name: Blink

View File

@ -10,8 +10,9 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0228856d50ce2a845abd7b3eda114390, type: 3} m_Script: {fileID: 11500000, guid: 0228856d50ce2a845abd7b3eda114390, type: 3}
m_Name: Power2 m_Name: PowerBoost
m_EditorClassIdentifier: m_EditorClassIdentifier:
_power: {fileID: 11400000, guid: d5ed942937d8cca478f3ec97f6b9c8a2, type: 2} _power: {fileID: 11400000, guid: d5ed942937d8cca478f3ec97f6b9c8a2, type: 2}
_artefactID: 2 _artefactID: 2
_artefactDialogue: _artefactDialogue:
_name: Boost

View File

@ -2,6 +2,8 @@ using Ktyl.Util;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class PickUpDisplay : MonoBehaviour public class PickUpDisplay : MonoBehaviour
{ {
@ -10,22 +12,48 @@ public class PickUpDisplay : MonoBehaviour
[SerializeField] private GameObject artefactUI; [SerializeField] private GameObject artefactUI;
[SerializeField] private SerialInt nearbyArtefactID; [SerializeField] private SerialInt nearbyArtefactID;
[SerializeField] private GameObject Player;
[SerializeField] private Text artefactText;
[SerializeField] private GameObject Artefacts;
private void Start() private Artefact chosenArtefact;
private static List<Artefact> completeList = new List<Artefact>();
private void Awake()
{ {
EventHandler.current.onArtefactUI += PopUpOn; EventHandler.current.onArtefactUI += PopUpOn;
int i;
for(i=0; i<Artefacts.transform.childCount; i++)
{
completeList.Add(Artefacts.transform.GetChild(i).GetComponent<ArtefactControl>().data);
}
} }
private void FixedUpdate()
{
foreach(Artefact arte in completeList)
{
if (nearbyArtefactID != -1 && arte.artefactID == nearbyArtefactID)
chosenArtefact = arte;
}
}
public void PopUpOn() public void PopUpOn()
{ {
_paused = true; _paused = true;
artefactUI.SetActive(true); artefactUI.SetActive(true);
Time.timeScale = 0.0f; Player.GetComponent<PlayerInput>().enabled = false;
artefactText.text = "You have unlocked " + chosenArtefact.Name + "!";
//Time.timeScale = 0f;
} }
public void PopUpOff() public void PopUpOff()
{ {
_paused = false; _paused = false;
artefactUI.SetActive(false); artefactUI.SetActive(false);
Time.timeScale = 1.0f; Player.GetComponent<PlayerInput>().enabled = true;
//Time.timeScale = 1.0f;
} }
} }