Thomas ICHÉ
5 年前
当前提交
645f9ec8
共有 3 个文件被更改,包括 88 次插入 和 3 次删除
-
16Runtime/Managers/Implementations/GameManager.cs
-
64Runtime/LevelScripting/Events/OnGameManagerLevelStart.cs
-
11Runtime/LevelScripting/Events/OnGameManagerLevelStart.cs.meta
|
|||
using NaughtyAttributes; |
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
|
|||
namespace GameplayIngredients.Events |
|||
{ |
|||
public class OnGameManagerLevelStart : EventBase |
|||
{ |
|||
public enum GameManagerLevelType |
|||
{ |
|||
MainMenu, |
|||
GameLevel |
|||
} |
|||
|
|||
public GameManagerLevelType levelType { get { return m_LevelType; } } |
|||
|
|||
[SerializeField] |
|||
protected GameManagerLevelType m_LevelType = GameManagerLevelType.GameLevel; |
|||
|
|||
string m_Message; |
|||
|
|||
[ReorderableList] |
|||
public Callable[] OnMessageRecieved; |
|||
|
|||
void OnEnable() |
|||
{ |
|||
m_Message = GetMessage(m_LevelType); |
|||
Messager.RegisterMessage(m_Message, Execute); |
|||
} |
|||
|
|||
void OnDisable() |
|||
{ |
|||
Messager.RemoveMessage(m_Message, Execute); |
|||
} |
|||
|
|||
static string GetMessage(GameManagerLevelType type) |
|||
{ |
|||
switch(type) |
|||
{ |
|||
case GameManagerLevelType.MainMenu: return GameManager.MainMenuStartMessage; |
|||
default: |
|||
case GameManagerLevelType.GameLevel: return GameManager.GameLevelStartMessage; |
|||
} |
|||
} |
|||
|
|||
void Execute() |
|||
{ |
|||
try |
|||
{ |
|||
Callable.Call(OnMessageRecieved, gameObject); |
|||
} |
|||
catch (System.Exception e) |
|||
{ |
|||
UnityEngine.Debug.LogError(string.Format("OnMessageEvent : Exception Caught while catching message '{0}' on Object '{1}'", m_Message, gameObject.name)); |
|||
UnityEngine.Debug.LogException(e); |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
} |
|||
|
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: 2089a4bf3f6e46d40be6510a3989744d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue