浏览代码

Event system refactoring

/main
Ciro Continisio 4 年前
当前提交
f8f9e0b0
共有 34 个文件被更改,包括 306 次插入177 次删除
  1. 12
      UOP1_Project/Assets/Scenes/Initialization.unity
  2. 90
      UOP1_Project/Assets/Scenes/Locations/Beach.unity
  3. 90
      UOP1_Project/Assets/Scenes/Locations/Forest.unity
  4. 2
      UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_Fire_looping.asset
  5. 2
      UOP1_Project/Assets/ScriptableObjects/EventChannels/ExitGame.asset
  6. 2
      UOP1_Project/Assets/ScriptableObjects/EventChannels/RegularSFX.asset
  7. 4
      UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCue.cs
  8. 6
      UOP1_Project/Assets/Scripts/Audio/AudioManager.cs
  9. 32
      UOP1_Project/Assets/Scripts/Events/IntEventListener.cs
  10. 2
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventChannelSO.cs.meta
  11. 2
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidEventChannelSO.cs.meta
  12. 30
      UOP1_Project/Assets/Scripts/Events/VoidEventListener.cs
  13. 8
      UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs
  14. 3
      UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs.meta
  15. 41
      UOP1_Project/Assets/Scripts/SceneManagement/LocationLoader.cs
  16. 8
      UOP1_Project/Assets/Scripts/SceneManagement/LocationLoader.cs.meta
  17. 2
      UOP1_Project/Assets/Scripts/SceneManagement/ScriptableObjects/GameSceneSO.cs
  18. 4
      UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs
  19. 17
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventChannelSO.cs
  20. 17
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/IntEventChannelSO.cs
  21. 18
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs
  22. 20
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidEventChannelSO.cs
  23. 16
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/IntGameEvent.cs
  24. 19
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidGameEvent.cs
  25. 19
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEvent.cs
  26. 17
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventSO.cs
  27. 0
      /UOP1_Project/Assets/Art/Flags/french fr.png
  28. 0
      /UOP1_Project/Assets/Art/Flags/french fr.png.meta
  29. 0
      /UOP1_Project/Assets/ScriptableObjects/EventChannels.meta
  30. 0
      /UOP1_Project/Assets/ScriptableObjects/EventChannels
  31. 0
      /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/IntEventChannelSO.cs.meta
  32. 0
      /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs.meta
  33. 0
      /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventChannelSO.cs.meta
  34. 0
      /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidEventChannelSO.cs.meta

12
UOP1_Project/Assets/Scenes/Initialization.unity


m_Script: {fileID: 11500000, guid: 0ba826e9d52310a43b98dffc289c71b2, type: 3}
m_Name:
m_EditorClassIdentifier:
voidGameEvent: {fileID: 11400000, guid: c499d87f35465124f8fb2751b150430d, type: 2}
_channel: {fileID: 11400000, guid: c499d87f35465124f8fb2751b150430d, type: 2}
OnEventRaised:
m_PersistentCalls:
m_Calls:

m_Script: {fileID: 11500000, guid: b6b928d1d6f59854499ed82bdeef2305, type: 3}
m_Name:
m_EditorClassIdentifier:
initializationScene: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b,
_initializationScene: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b,
mainMenuScenes:
_mainMenuScenes:
loadingInterface: {fileID: 363619424}
loadingProgressBar: {fileID: 841012435}
_loadEvent: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
_loadingInterface: {fileID: 363619424}
_loadingProgressBar: {fileID: 841012435}
_loadEventChannel: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
--- !u!4 &1242953037
Transform:
m_ObjectHideFlags: 0

90
UOP1_Project/Assets/Scenes/Locations/Beach.unity
文件差异内容过多而无法显示
查看文件

90
UOP1_Project/Assets/Scenes/Locations/Forest.unity


m_Script: {fileID: 11500000, guid: 02e6b73898a4a52438d630a7ba29da77, type: 3}
m_Name:
m_EditorClassIdentifier:
onLocationExit: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
locationsToLoad:
_onLocationExit: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
_locationsToLoad:
showLoadScreen: 0
_showLoadScreen: 0
--- !u!65 &1406036542
BoxCollider:
m_ObjectHideFlags: 0

m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1657732992883833910, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.035635047
objectReference: {fileID: 0}
- target: {fileID: 1657732992883833910, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.z
value: -0.00917581
objectReference: {fileID: 0}
- target: {fileID: 1657732992883833910, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0.24919108
objectReference: {fileID: 0}
- target: {fileID: 2808035858438402709, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.035795644
objectReference: {fileID: 0}
- target: {fileID: 2808035858438402709, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.z
value: -0.0085278265
objectReference: {fileID: 0}
- target: {fileID: 2808035858438402709, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0.23159356
objectReference: {fileID: 0}
- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0.22959729
objectReference: {fileID: 0}
- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.y
value: 0.035813097
objectReference: {fileID: 0}
- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalPosition.x
value: 0.0000004172325
objectReference: {fileID: 0}
- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.z
value: -0.008454323
objectReference: {fileID: 0}
- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.w
value: 0.9725899
objectReference: {fileID: 0}
- target: {fileID: 2955398947125553842, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalPosition.z
value: -0.0000009536743
objectReference: {fileID: 0}
- target: {fileID: 8745341640208226293, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_Name

propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 8745341641394998850, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalPosition.x
value: -0.73545045
objectReference: {fileID: 0}
- target: {fileID: 8745341641394998850, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalPosition.z
value: -9.9729185
objectReference: {fileID: 0}
- target: {fileID: 8745341642014614481, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: near clip plane

- target: {fileID: 8745341642014614482, guid: 45632f0a227c860489bcba0eb1f4ec3e,
type: 3}
propertyPath: m_LocalRotation.x
value: 0.18778464
value: 0.24919108
value: -0.20536137
value: 0.03563505
value: 0.040184725
value: -0.009175809
value: 0.9596608
value: 0.967755
value: 4.712467
value: -0.73545045
value: 6.307
value: 6
value: -24.900238
value: -9.9729185
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 45632f0a227c860489bcba0eb1f4ec3e, type: 3}

2
UOP1_Project/Assets/ScriptableObjects/Audio/AudioCues/SFX_Fire_looping.asset


m_Script: {fileID: 11500000, guid: 08e854ccd8588da4694c3ae040c10c5e, type: 3}
m_Name: SFX_Fire_looping
m_EditorClassIdentifier:
_looping: 1
looping: 1
_audioClipGroups:
- sequenceMode: 0
audioClips:

2
UOP1_Project/Assets/ScriptableObjects/EventChannels/ExitGame.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 04ea2f19feb15654cb31bb60f7f50855, type: 3}
m_Script: {fileID: 11500000, guid: 7fafac715ff920c4383fed91a38a351e, type: 3}
m_Name: ExitGame
m_EditorClassIdentifier:

2
UOP1_Project/Assets/ScriptableObjects/EventChannels/RegularSFX.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7847b6caa8e5464c80cd90a8cc33a19, type: 3}
m_Script: {fileID: 11500000, guid: 273f9313082320e41a484f6faf242dab, type: 3}
m_Name: RegularSFX
m_EditorClassIdentifier:

4
UOP1_Project/Assets/Scripts/Audio/AudioData/AudioCue.cs


public class AudioCue : MonoBehaviour
{
[SerializeField] private AudioCueSO _audioCue = default;
[SerializeField] private AudioCueEventSO _audioCueEventChannel = default;
[SerializeField] private AudioCueEventChannelSO _audioCueEventChannel = default;
_audioCueEventChannel.Raise(_audioCue, _audioConfiguration, transform.position);
_audioCueEventChannel.RaiseEvent(_audioCue, _audioConfiguration, transform.position);
}
}

6
UOP1_Project/Assets/Scripts/Audio/AudioManager.cs


[SerializeField] private int _initialPoolSize = 1;
[SerializeField] private SoundEmitter _soundEmitterPrefab = default;
[Tooltip("The SoundManager listens to this event, fired by objects in any scene, to play SFXs")]
[SerializeField] private AudioCueEventSO _SFXEvent = default;
[SerializeField] private AudioCueEventChannelSO _SFXEvent = default;
[SerializeField] private AudioCueEventSO _musicEvent = default;
[SerializeField] private AudioCueEventChannelSO _musicEvent = default;
private SoundEmitterFactorySO _factory;
private SoundEmitterPoolSO _pool;

{
InitPool();
_SFXEvent.eventRaised += PlayAudioCue;
_SFXEvent.OnAudioCueRequested += PlayAudioCue;
}
private void InitPool()

32
UOP1_Project/Assets/Scripts/Events/IntEventListener.cs


using UnityEngine.Events;
/// <summary>
/// To use a generic UnityEvent type you must override the class type
/// To use a generic UnityEvent type you must override the generic type.
/// This class is listener for Int Events
/// A flexible handler for int events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector.
public IntGameEvent intGameEvent;
[SerializeField] private IntEventChannelSO _channel = default;
//Check if the event exists to avoid errors
if (intGameEvent == null)
{
return;
}
intGameEvent.eventRaised += Respond;
if (_channel != null)
_channel.OnEventRaised += Respond;
if (intGameEvent == null)
{
return;
}
intGameEvent.eventRaised -= Respond;
if (_channel != null)
_channel.OnEventRaised -= Respond;
public void Respond(int value)
private void Respond(int value)
if (OnEventRaised == null)
{
return;
}
OnEventRaised.Invoke(value);
if (OnEventRaised != null)
OnEventRaised.Invoke(value);
}
}

2
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventChannelSO.cs.meta


fileFormatVersion: 2
guid: d7847b6caa8e5464c80cd90a8cc33a19
guid: 273f9313082320e41a484f6faf242dab
MonoImporter:
externalObjects: {}
serializedVersion: 2

2
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidEventChannelSO.cs.meta


fileFormatVersion: 2
guid: 04ea2f19feb15654cb31bb60f7f50855
guid: 7fafac715ff920c4383fed91a38a351e
MonoImporter:
externalObjects: {}
serializedVersion: 2

30
UOP1_Project/Assets/Scripts/Events/VoidEventListener.cs


using UnityEngine.Events;
/// <summary>
/// This class is listener for Void Events
/// A flexible handler for void events in the form of a MonoBehaviour. Responses can be connected directly from the Unity Inspector.
public VoidGameEvent voidGameEvent;
[SerializeField] private VoidEventChannelSO _channel = default;
//Check if the event exists to avoid errors
if (voidGameEvent == null)
{
return;
}
voidGameEvent.eventRaised += Respond;
if (_channel != null)
_channel.OnEventRaised += Respond;
if (voidGameEvent == null)
{
return;
}
voidGameEvent.eventRaised -= Respond;
if (_channel != null)
_channel.OnEventRaised -= Respond;
public void Respond()
private void Respond()
if (OnEventRaised == null)
{
return;
}
OnEventRaised.Invoke();
if (OnEventRaised != null)
OnEventRaised.Invoke();
}
}

8
UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs


public class LocationExit : MonoBehaviour
{
public LoadEvent onLocationExit;
public GameSceneSO[] locationsToLoad;
public bool showLoadScreen;
[SerializeField] private LoadEventChannelSO _onLocationExit = default;
[SerializeField] private GameSceneSO[] _locationsToLoad = default;
[SerializeField] private bool _showLoadScreen = default;
onLocationExit.Raise(locationsToLoad, showLoadScreen);
_onLocationExit.RaiseEvent(_locationsToLoad, _showLoadScreen);
}
}
}

3
UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs.meta


MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
defaultReferences:
- _onLocationExit: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597, type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:

41
UOP1_Project/Assets/Scripts/SceneManagement/LocationLoader.cs


/// <summary>
/// This class manages the scenes loading and unloading
/// </summary>
public GameSceneSO initializationScene;
[SerializeField] private GameSceneSO _initializationScene = default;
public GameSceneSO[] mainMenuScenes;
[SerializeField] private GameSceneSO[] _mainMenuScenes = default;
public GameObject loadingInterface;
public Image loadingProgressBar;
[SerializeField] private GameObject _loadingInterface = default;
[SerializeField] private Image _loadingProgressBar = default;
[SerializeField] private LoadEvent _loadEvent = default;
[SerializeField] private LoadEventChannelSO _loadEventChannel = default;
//List of the scenes to load and track progress
private List<AsyncOperation> _scenesToLoadAsyncOperations = new List<AsyncOperation>();

private void OnEnable()
{
_loadEvent.loadEvent += LoadScenes;
_loadEventChannel.OnLoadingRequested += LoadScenes;
_loadEvent.loadEvent -= LoadScenes;
_loadEventChannel.OnLoadingRequested -= LoadScenes;
if (SceneManager.GetActiveScene().name == initializationScene.sceneName)
if (SceneManager.GetActiveScene().name == _initializationScene.sceneName)
{
LoadMainMenu();
}

{
LoadScenes(mainMenuScenes, false);
LoadScenes(_mainMenuScenes, false);
public void LoadScenes(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
private void LoadScenes(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
{
//Add all current open scenes to unload list
AddScenesToUnload();

if (showLoadingScreen)
{
//Show the progress bar and track progress if loadScreen is true
loadingInterface.SetActive(true);
_loadingInterface.SetActive(true);
StartCoroutine(TrackLoadingProgress());
}
else

SceneManager.SetActiveScene(SceneManager.GetSceneByName(_activeScene.sceneName));
}
public void AddScenesToUnload()
private void AddScenesToUnload()
if (scene.name != initializationScene.sceneName)
if (scene.name != _initializationScene.sceneName)
{
Debug.Log("Added scene to unload = " + scene.name);
//Add the scene to the list of the scenes to unload

}
public void UnloadScenes()
private void UnloadScenes()
{
if (_ScenesToUnload != null)
{

}
/// <summary> This function checks if a scene is already loaded </summary>
public bool CheckLoadState(String sceneName)
private bool CheckLoadState(String sceneName)
{
for (int i = 0; i < SceneManager.sceneCount; ++i)
{

}
/// <summary> This function updates the loading progress once per frame until loading is complete </summary>
IEnumerator TrackLoadingProgress()
private IEnumerator TrackLoadingProgress()
{
float totalProgress = 0;
//When the scene reaches 0.9f, it means that it is loaded

totalProgress += _scenesToLoadAsyncOperations[i].progress;
}
//The fillAmount for all scenes, so we devide the progress by the number of scenes to load
loadingProgressBar.fillAmount = totalProgress / _scenesToLoadAsyncOperations.Count;
Debug.Log("progress bar" + loadingProgressBar.fillAmount + "and value =" + totalProgress / _scenesToLoadAsyncOperations.Count);
_loadingProgressBar.fillAmount = totalProgress / _scenesToLoadAsyncOperations.Count;
Debug.Log("progress bar" + _loadingProgressBar.fillAmount + "and value =" + totalProgress / _scenesToLoadAsyncOperations.Count);
yield return null;
}

//Hide progress bar when loading is done
loadingInterface.SetActive(false);
_loadingInterface.SetActive(false);
public void ExitGame()
private void ExitGame()
{
Application.Quit();
Debug.Log("Exit!");

8
UOP1_Project/Assets/Scripts/SceneManagement/LocationLoader.cs.meta


MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
defaultReferences:
- _initializationScene: {fileID: 11400000, guid: c2119785ce96367428081d6eee0d932b,
type: 2}
- _loadingInterface: {instanceID: 0}
- _loadingProgressBar: {instanceID: 0}
- _loadEventChannel: {fileID: 11400000, guid: 00e3063edc5902e40832ea618644c597,
type: 2}
executionOrder: 0
icon: {instanceID: 0}
userData:

2
UOP1_Project/Assets/Scripts/SceneManagement/ScriptableObjects/GameSceneSO.cs


using UnityEngine;
/// <summary>
/// This class is a base class which contains what is commun for all game scenes (Locations or Menus)
/// This class is a base class which contains what is common to all game scenes (Locations or Menus)
/// </summary>
public class GameSceneSO : ScriptableObject

4
UOP1_Project/Assets/Scripts/SceneManagement/StartGame.cs


public class StartGame : MonoBehaviour
{
public LoadEvent onPlayButtonPress;
public LoadEventChannelSO onPlayButtonPress;
onPlayButtonPress.Raise(locationsToLoad, showLoadScreen);
onPlayButtonPress.RaiseEvent(locationsToLoad, showLoadScreen);
}
}

17
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventChannelSO.cs


using UnityEngine;
using System.Collections;
using UnityEngine.Events;
/// <summary>
/// Event on which <c>AudioCue</c> components send a message to play SFX and music. <c>AudioManager</c> listens on these events, and actually plays the sound.
/// </summary>
[CreateAssetMenu(menuName = "Events/AudioCue Event Channel")]
public class AudioCueEventChannelSO : ScriptableObject
{
public UnityAction<AudioCueSO, AudioConfigurationSO, Vector3> OnAudioCueRequested;
public void RaiseEvent(AudioCueSO audioCue, AudioConfigurationSO audioConfiguration, Vector3 positionInSpace)
{
OnAudioCueRequested.Invoke(audioCue, audioConfiguration, positionInSpace);
}
}

17
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/IntEventChannelSO.cs


using UnityEngine.Events;
using UnityEngine;
/// <summary>
/// This class is used for Events that have one int argument.
/// Example: An Achievement unlock event, where the int is the Achievement ID.
/// </summary>
[CreateAssetMenu(menuName = "Events/Int Event Channel")]
public class IntEventChannelSO : ScriptableObject
{
public UnityAction<int> OnEventRaised;
public void RaiseEvent(int value)
{
OnEventRaised.Invoke(value);
}
}

18
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs


using UnityEngine;
using UnityEngine.Events;
/// <summary>
/// This class is a used for scene loading events.
/// Takes an array of the scenes we want to load and a bool to specify if we want to show a loading screen.
/// </summary>
[CreateAssetMenu(menuName = "Events/Load Event Channel")]
public class LoadEventChannelSO : ScriptableObject
{
public UnityAction<GameSceneSO[], bool> OnLoadingRequested;
public void RaiseEvent(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
{
if (OnLoadingRequested != null)
OnLoadingRequested.Invoke(locationsToLoad, showLoadingScreen);
}
}

20
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidEventChannelSO.cs


using UnityEngine;
using UnityEngine.Events;
/// <summary>
/// This class is used for Events that have no arguments (Example: Exit game event)
/// </summary>
[CreateAssetMenu(menuName = "Events/Void Event Channel")]
public class VoidEventChannelSO : ScriptableObject
{
public UnityAction OnEventRaised;
public void RaiseEvent()
{
if (OnEventRaised != null)
OnEventRaised.Invoke();
}
}

16
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/IntGameEvent.cs


using UnityEngine.Events;
using UnityEngine;
/// <summary>
/// This class is used for Events that have one Int argument (Example: Achievement Unlock Event)
/// </summary>
[CreateAssetMenu(fileName = "IntGameEvent", menuName = "Game Event/Int")]
public class IntGameEvent : ScriptableObject
{
public UnityAction<int> eventRaised;
public void Raise(int value)
{
eventRaised.Invoke(value);
}
}

19
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidGameEvent.cs


using UnityEngine;
using UnityEngine.Events;
/// <summary>
/// This class is used for Events that have no arguments (Example: Exit game event)
/// </summary>
[CreateAssetMenu(fileName = "VoidGameEvent", menuName = "Game Event/Void")]
public class VoidGameEvent : ScriptableObject
{
public UnityAction eventRaised;
public void Raise()
{
if (eventRaised != null)
eventRaised.Invoke();
}
}

19
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEvent.cs


using UnityEngine;
using UnityEngine.Events;
/// <summary>
/// This class is a used for scene loading Events
/// Takes an array of the scenes we want to load
/// and a bool to specify if we want to show a loading screen
/// </summary>
[CreateAssetMenu(fileName = "LoadGameEvent", menuName = "Game Event/Load")]
public class LoadEvent : ScriptableObject
{
public UnityAction<GameSceneSO[], bool> loadEvent;
public void Raise(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
{
if (loadEvent != null)
loadEvent.Invoke(locationsToLoad, showLoadingScreen);
}
}

17
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventSO.cs


using UnityEngine;
using System.Collections;
using UnityEngine.Events;
/// <summary>
/// Event on which <c>AudioCue</c> components send a message to play SFX and music. <c>AudioManager</c> listens on these events, and actually plays the sound.
/// </summary>
[CreateAssetMenu(menuName = "Game Event/Audio Cue")]
public class AudioCueEventSO : ScriptableObject
{
public UnityAction<AudioCueSO, AudioConfigurationSO, Vector3> eventRaised;
public void Raise(AudioCueSO audioCue, AudioConfigurationSO audioConfiguration, Vector3 positionInSpace)
{
eventRaised.Invoke(audioCue, audioConfiguration, positionInSpace);
}
}

/UOP1_Project/Assets/Art/Flags/frensh fr.png → /UOP1_Project/Assets/Art/Flags/french fr.png

/UOP1_Project/Assets/Art/Flags/frensh fr.png.meta → /UOP1_Project/Assets/Art/Flags/french fr.png.meta

/UOP1_Project/Assets/ScriptableObjects/Events.meta → /UOP1_Project/Assets/ScriptableObjects/EventChannels.meta

/UOP1_Project/Assets/ScriptableObjects/Events → /UOP1_Project/Assets/ScriptableObjects/EventChannels

/UOP1_Project/Assets/Scripts/Events/ScriptableObjects/IntGameEvent.cs.meta → /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/IntEventChannelSO.cs.meta

/UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEvent.cs.meta → /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs.meta

/UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventSO.cs.meta → /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/AudioCueEventChannelSO.cs.meta

/UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidGameEvent.cs.meta → /UOP1_Project/Assets/Scripts/Events/ScriptableObjects/VoidEventChannelSO.cs.meta

正在加载...
取消
保存