浏览代码

Added Void, Int and Load Events SO and Listeners

/main
Unknown 4 年前
当前提交
da0bbab5
共有 23 个文件被更改,包括 159 次插入78 次删除
  1. 2
      UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_Exit.asset.meta
  2. 2
      UOP1_Project/Assets/Scripts/Scriptable Objects/Events/LoadEvent.cs.meta
  3. 2
      UOP1_Project/Assets/Scripts/Event Listeners/IntEventListener.cs.meta
  4. 2
      UOP1_Project/Assets/Scripts/Scriptable Objects/Events/IntGameEvent.cs.meta
  5. 14
      UOP1_Project/Assets/Scriptable Objects/Events/LoadLocationEvent.asset
  6. 8
      UOP1_Project/Assets/Scriptable Objects/Events/LoadLocationEvent.asset.meta
  7. 8
      UOP1_Project/Assets/Scripts/Event Listeners.meta
  8. 12
      UOP1_Project/Assets/Scripts/Scriptable Objects/Events/IntGameEvent.cs
  9. 12
      UOP1_Project/Assets/Scripts/Scriptable Objects/Events/LoadEvent.cs
  10. 14
      UOP1_Project/Assets/Scripts/Scriptable Objects/Events/VoidGameEvent.cs
  11. 40
      UOP1_Project/Assets/Scripts/Event Listeners/IntEventListener.cs
  12. 36
      UOP1_Project/Assets/Scripts/Event Listeners/VoidEventListener.cs
  13. 11
      UOP1_Project/Assets/Scripts/Event Listeners/VoidEventListener.cs.meta
  14. 14
      UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadMainMenu.asset
  15. 8
      UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadMainMenu.asset.meta
  16. 8
      UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadNextLevel.asset.meta
  17. 8
      UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadNextLevelWithProgress.asset.meta
  18. 36
      UOP1_Project/Assets/Scripts/GameEventListener.cs
  19. 0
      /UOP1_Project/Assets/Scripts/Scriptable Objects/Events/VoidGameEvent.cs.meta
  20. 0
      /UOP1_Project/Assets/Scripts/Scriptable Objects/Events/LoadEvent.cs.meta
  21. 0
      /UOP1_Project/Assets/Scripts/Event Listeners/IntEventListener.cs.meta
  22. 0
      /UOP1_Project/Assets/Scripts/Scriptable Objects/Events/IntGameEvent.cs.meta

2
UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_Exit.asset.meta


fileFormatVersion: 2
guid: 95eb00b1852501648b8f37799fcd78f7
guid: c499d87f35465124f8fb2751b150430d
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0

2
UOP1_Project/Assets/Scripts/Scriptable Objects/Events/LoadEvent.cs.meta


fileFormatVersion: 2
guid: 8cb8658de1ad97b4eb747df35933650f
guid: 82df99cd4c7564d4ca44d50a1dce516b
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
UOP1_Project/Assets/Scripts/Event Listeners/IntEventListener.cs.meta


fileFormatVersion: 2
guid: 8ade5a748610bf348a549932627f98d1
guid: 8e135d888ad24024f90a15e07ae82bbc
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
UOP1_Project/Assets/Scripts/Scriptable Objects/Events/IntGameEvent.cs.meta


fileFormatVersion: 2
guid: 74ddcd50a4953a24a83702bb14e0a801
guid: 696142ab7e0adf0478f66a5c9e06a168
MonoImporter:
externalObjects: {}
serializedVersion: 2

14
UOP1_Project/Assets/Scriptable Objects/Events/LoadLocationEvent.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 82df99cd4c7564d4ca44d50a1dce516b, type: 3}
m_Name: LoadLocationEvent
m_EditorClassIdentifier:

8
UOP1_Project/Assets/Scriptable Objects/Events/LoadLocationEvent.asset.meta


fileFormatVersion: 2
guid: 00e3063edc5902e40832ea618644c597
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/Scripts/Event Listeners.meta


fileFormatVersion: 2
guid: 0e40ff7dabb309543830cc3ce88b7841
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

12
UOP1_Project/Assets/Scripts/Scriptable Objects/Events/IntGameEvent.cs


using UnityEngine.Events;
using UnityEngine;
[CreateAssetMenu(fileName = "IntGameEvent", menuName = "Game Event/Int")]
public class IntGameEvent : ScriptableObject
{
public UnityAction<int> eventRaised;
public void Raise(int value)
{
eventRaised.Invoke(value);
}
}

12
UOP1_Project/Assets/Scripts/Scriptable Objects/Events/LoadEvent.cs


using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(fileName = "LoadGameEvent", menuName = "Game Event/Load")]
public class LoadEvent : ScriptableObject
{
public UnityAction<GameScene[], bool> loadEvent;
public void RaiseEvent(GameScene[] locationsToLoad, bool loadScreen)
{
if (loadEvent != null) loadEvent.Invoke(locationsToLoad, loadScreen);
}
}

14
UOP1_Project/Assets/Scripts/Scriptable Objects/Events/VoidGameEvent.cs


using UnityEngine;
using UnityEngine.Events;
[CreateAssetMenu(fileName = "VoidGameEvent", menuName = "Game Event/Void")]
public class VoidGameEvent : ScriptableObject
{
public UnityAction eventRaised;
public void Raise()
{
if(eventRaised != null) eventRaised.Invoke();
}
}

40
UOP1_Project/Assets/Scripts/Event Listeners/IntEventListener.cs


using UnityEngine;
using UnityEngine.Events;
[System.Serializable]
public class IntEvent : UnityEvent<int>
{
}
public class IntEventListener : MonoBehaviour
{
public IntGameEvent intGameEvent;
public IntEvent OnEventRaised;
private void OnEnable()
{
//Check if the event exists to avoid errors
if (intGameEvent == null)
{
return;
}
intGameEvent.eventRaised += Respond;
}
private void OnDisable()
{
if (intGameEvent == null)
{
return;
}
intGameEvent.eventRaised -= Respond;
}
public void Respond(int value)
{
if (OnEventRaised == null)
{
return;
}
OnEventRaised.Invoke(value);
}
}

36
UOP1_Project/Assets/Scripts/Event Listeners/VoidEventListener.cs


using UnityEngine;
using UnityEngine.Events;
public class VoidEventListener : MonoBehaviour
{
public VoidGameEvent voidGameEvent;
public UnityEvent OnEventRaised;
private void OnEnable()
{
//Check if the event exists to avoid errors
if (voidGameEvent == null)
{
return;
}
voidGameEvent.eventRaised += Respond;
}
private void OnDisable()
{
if (voidGameEvent == null)
{
return;
}
voidGameEvent.eventRaised -= Respond;
}
public void Respond()
{
if (OnEventRaised == null)
{
return;
}
OnEventRaised.Invoke();
}
}

11
UOP1_Project/Assets/Scripts/Event Listeners/VoidEventListener.cs.meta


fileFormatVersion: 2
guid: 0ba826e9d52310a43b98dffc289c71b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

14
UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadMainMenu.asset


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04ea2f19feb15654cb31bb60f7f50855, type: 3}
m_Name: GameEvent_LoadMainMenu
m_EditorClassIdentifier:

8
UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadMainMenu.asset.meta


fileFormatVersion: 2
guid: 652ff0e2a34af0246b658aed07ec44a3
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadNextLevel.asset.meta


fileFormatVersion: 2
guid: d166670d1b4b0af4b969be97d28317e4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

8
UOP1_Project/Assets/Scriptable Objects/Events/GameEvent_LoadNextLevelWithProgress.asset.meta


fileFormatVersion: 2
guid: 31d49a74dcfce42488af012acaf74bdb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 0
userData:
assetBundleName:
assetBundleVariant:

36
UOP1_Project/Assets/Scripts/GameEventListener.cs


using UnityEngine;
using UnityEngine.Events;
public class GameEventListener : MonoBehaviour
{
public GameEvent Event;
public UnityEvent Response;
private void OnEnable()
{
//Check if the event exists to avoid errors
if (Event == null)
{
return;
}
Event.RegisterListener(this);
}
private void OnDisable()
{
if (Event == null)
{
return;
}
Event.UnregisterListener(this);
}
public void OnEventRaised()
{
if (Response == null)
{
return;
}
Response.Invoke();
}
}

/UOP1_Project/Assets/Scripts/Scriptable Objects/Events/GameEvent.cs.meta → /UOP1_Project/Assets/Scripts/Scriptable Objects/Events/VoidGameEvent.cs.meta

/UOP1_Project/Assets/Scripts/GameEventListener.cs.meta → /UOP1_Project/Assets/Scripts/Scriptable Objects/Events/LoadEvent.cs.meta

/UOP1_Project/Assets/Scripts/MainMenu.cs.meta → /UOP1_Project/Assets/Scripts/Event Listeners/IntEventListener.cs.meta

/UOP1_Project/Assets/Scripts/ClearLists.cs.meta → /UOP1_Project/Assets/Scripts/Scriptable Objects/Events/IntGameEvent.cs.meta

正在加载...
取消
保存