Last active
October 3, 2023 08:26
-
-
Save satomi-i-k/a658a1c2b23a3d6ae5e1a6714f56c360 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class EventManager : MonoBehaviour | |
{ | |
private static EventManager instance; | |
public delegate void HitEventHandler(Vector3 direction); | |
public static event HitEventHandler OnRaqplayerHit; | |
public delegate void ServeEventHandler(); | |
public static event ServeEventHandler OnRaqplayerServe; | |
public delegate void OutEventHandler(); | |
public static event OutEventHandler OnRaqgameOut; | |
public delegate void NextEventHandler(); | |
public static event NextEventHandler OnNext; | |
public static EventManager Instance | |
{ | |
get | |
{ | |
if (instance == null) | |
{ | |
instance = FindObjectOfType<EventManager>(); | |
if (instance == null) | |
{ | |
GameObject obj = new GameObject("EventManager"); | |
instance = obj.AddComponent<EventManager>(); | |
} | |
} | |
return instance; | |
} | |
} | |
public void TriggerRaqplayerHit(Vector3 direction) | |
{ | |
OnRaqplayerHit?.Invoke(direction); | |
} | |
public void TriggerRaqplayerServe() | |
{ | |
OnRaqplayerServe?.Invoke(); | |
} | |
public void TriggerOut() | |
{ | |
OnRaqgameOut?.Invoke(); | |
} | |
public void TriggerNext() | |
{ | |
OnNext?.Invoke(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment