artefact registration, register event listeners after awake event
This commit is contained in:
parent
b64e4e30af
commit
1aee232cb6
|
@ -14,3 +14,4 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_dialogue: {fileID: 11400000, guid: 56369c4e83cc59e44bf55cd16fafc4e8, type: 2}
|
_dialogue: {fileID: 11400000, guid: 56369c4e83cc59e44bf55cd16fafc4e8, type: 2}
|
||||||
_inventory: {fileID: 11400000, guid: 1a9441435aa1fc649a84169f689c7f53, type: 2}
|
_inventory: {fileID: 11400000, guid: 1a9441435aa1fc649a84169f689c7f53, type: 2}
|
||||||
|
_nearbyArtefactId: {fileID: 11400000, guid: caba70196fbb1c549a934f7566f7a247, type: 2}
|
||||||
|
|
|
@ -10,7 +10,7 @@ MonoBehaviour:
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: cc38ab5b9e594a344a8eb1635487d5eb, type: 3}
|
m_Script: {fileID: 11500000, guid: cc38ab5b9e594a344a8eb1635487d5eb, type: 3}
|
||||||
m_Name: nearbyArtefactID
|
m_Name: Nearby Artefact ID
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_initialValue: -1
|
_initialValue: -1
|
||||||
_readOnly: 0
|
_readOnly: 0
|
|
@ -2476,15 +2476,15 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.14211853
|
value: 0.14211854
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: -2.2566488e-22
|
value: 1.1133053e-25
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831318799747, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: 2.3205715e-23
|
value: -4.9127595e-24
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalPosition.x
|
propertyPath: m_LocalPosition.x
|
||||||
|
@ -2504,15 +2504,15 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.1419703
|
value: 0.14197029
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0.04519987
|
value: 0.045199864
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831388223341, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: -0.0064896117
|
value: -0.0064896103
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633831414007564, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
|
@ -2600,15 +2600,15 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.x
|
propertyPath: m_LocalRotation.x
|
||||||
value: 0.14211851
|
value: 0.14211854
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: -7.529077e-16
|
value: -0.0000000034819871
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832789495666, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: 4.582889e-18
|
value: 4.999292e-10
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832858914730, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_XAxis.m_InvertInput
|
propertyPath: m_XAxis.m_InvertInput
|
||||||
|
@ -2636,11 +2636,11 @@ PrefabInstance:
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.y
|
propertyPath: m_LocalRotation.y
|
||||||
value: 0.04519986
|
value: 0.045199856
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
- target: {fileID: 4676633832928372887, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
propertyPath: m_LocalRotation.z
|
propertyPath: m_LocalRotation.z
|
||||||
value: -0.006489608
|
value: -0.006489607
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: 8a918f60d084fbe468bf3b2c0a14fb52, type: 3}
|
||||||
|
@ -7128,12 +7128,11 @@ MonoBehaviour:
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
artefactUI: {fileID: 483749937}
|
artefactUI: {fileID: 483749937}
|
||||||
nearbyArtefactID: {fileID: 11400000, guid: caba70196fbb1c549a934f7566f7a247, type: 2}
|
|
||||||
Player: {fileID: 1239556274}
|
Player: {fileID: 1239556274}
|
||||||
artefactText: {fileID: 59318657}
|
artefactText: {fileID: 59318657}
|
||||||
Artefacts: {fileID: 1112305613}
|
|
||||||
inputSettings: {fileID: 11400000, guid: 87faf39b6f22e524984c1680a88045ac, type: 2}
|
inputSettings: {fileID: 11400000, guid: 87faf39b6f22e524984c1680a88045ac, type: 2}
|
||||||
dialogue: {fileID: 11400000, guid: 56369c4e83cc59e44bf55cd16fafc4e8, type: 2}
|
dialogue: {fileID: 11400000, guid: 56369c4e83cc59e44bf55cd16fafc4e8, type: 2}
|
||||||
|
artefacts: {fileID: 11400000, guid: f523ac0d77530064b8b41c627b13fae0, type: 2}
|
||||||
--- !u!114 &2070784759
|
--- !u!114 &2070784759
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -6,8 +7,6 @@ using UnityEngine.Events;
|
||||||
|
|
||||||
public class ArtefactControl : MonoBehaviour
|
public class ArtefactControl : MonoBehaviour
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
private bool _show;
|
private bool _show;
|
||||||
protected bool _canInteract;
|
protected bool _canInteract;
|
||||||
|
|
||||||
|
@ -20,7 +19,12 @@ public class ArtefactControl : MonoBehaviour
|
||||||
[SerializeField] private SerialInt _nearbyArtefactID;
|
[SerializeField] private SerialInt _nearbyArtefactID;
|
||||||
|
|
||||||
[SerializeField] private ArtefactSystem _artefacts;
|
[SerializeField] private ArtefactSystem _artefacts;
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
_artefacts.RegisterArtefact(_data);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void Start()
|
protected virtual void Start()
|
||||||
{
|
{
|
||||||
_artefactID = data.artefactID;
|
_artefactID = data.artefactID;
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using Ktyl.Util;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[CreateAssetMenu(menuName = "KernelPanic/Artefacts/Artefact System")]
|
[CreateAssetMenu(menuName = "KernelPanic/Artefacts/Artefact System")]
|
||||||
|
@ -7,6 +10,36 @@ public class ArtefactSystem : ScriptableObject
|
||||||
{
|
{
|
||||||
[SerializeField] private DialogueSystem _dialogue;
|
[SerializeField] private DialogueSystem _dialogue;
|
||||||
[SerializeField] private ArtefactInventory _inventory;
|
[SerializeField] private ArtefactInventory _inventory;
|
||||||
|
[SerializeField] private SerialInt _nearbyArtefactId;
|
||||||
|
|
||||||
|
private readonly List<Artefact> _artefacts = new List<Artefact>();
|
||||||
|
|
||||||
|
public Artefact GetNearbyArtefact()
|
||||||
|
{
|
||||||
|
return _nearbyArtefactId == -1 ? null : GetArtefact(_nearbyArtefactId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Artefact GetArtefact(int id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _artefacts.Count; i++)
|
||||||
|
{
|
||||||
|
if (_artefacts[i].artefactID == id) return _artefacts[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
Debug.LogError($"no registered artefact with id {id}");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RegisterArtefact(Artefact artefact)
|
||||||
|
{
|
||||||
|
if (_artefacts.Contains(artefact))
|
||||||
|
{
|
||||||
|
Debug.LogError($"{artefact} already registered", this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_artefacts.Add(artefact);
|
||||||
|
}
|
||||||
|
|
||||||
public void FindArtefact(Artefact artefact)
|
public void FindArtefact(Artefact artefact)
|
||||||
{
|
{
|
||||||
|
@ -14,4 +47,9 @@ public class ArtefactSystem : ScriptableObject
|
||||||
|
|
||||||
// _dialogue.PlayLine(artefact.dialogueKey);
|
// _dialogue.PlayLine(artefact.dialogueKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
_artefacts.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ using UnityEngine;
|
||||||
|
|
||||||
public class EventHandler : MonoBehaviour
|
public class EventHandler : MonoBehaviour
|
||||||
{
|
{
|
||||||
//[SerializeField] private SerialInt nearbyArtefactID;
|
|
||||||
public static EventHandler current;
|
public static EventHandler current;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
|
@ -39,10 +38,7 @@ public class EventHandler : MonoBehaviour
|
||||||
{
|
{
|
||||||
if (onArtefactPickUp != null)
|
if (onArtefactPickUp != null)
|
||||||
{
|
{
|
||||||
//if(nearbyArtefactID != -1)
|
onArtefactPickUp(id);
|
||||||
// {
|
|
||||||
onArtefactPickUp(id);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,40 +11,29 @@ public class PickUpDisplay : MonoBehaviour
|
||||||
[SerializeField] private static bool _paused;
|
[SerializeField] private static bool _paused;
|
||||||
|
|
||||||
[SerializeField] private GameObject artefactUI;
|
[SerializeField] private GameObject artefactUI;
|
||||||
[SerializeField] private SerialInt nearbyArtefactID;
|
|
||||||
[SerializeField] private GameObject Player;
|
[SerializeField] private GameObject Player;
|
||||||
[SerializeField] private Text artefactText;
|
[SerializeField] private Text artefactText;
|
||||||
[SerializeField] private GameObject Artefacts;
|
|
||||||
[SerializeField] private InputSettings inputSettings;
|
[SerializeField] private InputSettings inputSettings;
|
||||||
[SerializeField] private DialogueSystem dialogue;
|
[SerializeField] private DialogueSystem dialogue;
|
||||||
|
[SerializeField] private ArtefactSystem artefacts;
|
||||||
|
|
||||||
private Artefact chosenArtefact;
|
private Artefact chosenArtefact;
|
||||||
private static List<Artefact> completeList = new List<Artefact>();
|
|
||||||
|
|
||||||
private void Awake()
|
private void Start()
|
||||||
{
|
{
|
||||||
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()
|
private void Update()
|
||||||
{
|
{
|
||||||
foreach(Artefact arte in completeList)
|
var artefact = artefacts.GetNearbyArtefact();
|
||||||
{
|
if (!artefact) return;
|
||||||
if (nearbyArtefactID != -1 && arte.artefactID == nearbyArtefactID)
|
|
||||||
chosenArtefact = arte;
|
chosenArtefact = artefact;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PopUpOn()
|
public void PopUpOn()
|
||||||
{
|
{
|
||||||
;
|
|
||||||
_paused = true;
|
_paused = true;
|
||||||
artefactUI.SetActive(true);
|
artefactUI.SetActive(true);
|
||||||
Player.GetComponent<PlayerInput>().enabled = false;
|
Player.GetComponent<PlayerInput>().enabled = false;
|
||||||
|
|
Loading…
Reference in New Issue