Skip to content
Snippets Groups Projects
Commit 4d7c88e8 authored by Tony Pohto's avatar Tony Pohto
Browse files

Global event system

parent f08031e5
No related branches found
No related tags found
No related merge requests found
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class EventSystem
{
static Dictionary<EventType, List<IAction>> events = new Dictionary<EventType, List<IAction>>();
public static void AddEvent(EventType name, IAction target) {
if (!events.ContainsKey(name))
events.Add(name, new List<IAction>());
events[name].Add(target);
}
public static void EventHappened(EventType name)
{
if (events.ContainsKey(name))
{
foreach (IAction e in events.Values){
e.React();
}
}
}
}
fileFormatVersion: 2
guid: 8035379af60d7a344bf9033fff4a1f3f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum EventType
{
TimePeriodChanged
}
fileFormatVersion: 2
guid: 173740ad07280db429023b38a0e230a7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public interface IAction
{
void React();
}
fileFormatVersion: 2
guid: 3804ff07da1145d4dafd154188b42f89
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment