Files
Dontback/Assets/Scripts/Event/EventManager.cs
Eicy 6d3f85829b +物品展示
todo 玩家背包
2024-09-28 18:06:49 +08:00

105 lines
2.6 KiB
C#

using Event.EventArgs;
using Event.EventHandler;
using UnityEngine;
namespace Event
{
public class EventManager : MonoBehaviour
{
private static EventManager _instance;
public static EventManager Instance
{
get
{
if (_instance)
return _instance;
_instance = FindObjectOfType<EventManager>() ??
new GameObject("EventManager").AddComponent<EventManager>();
return _instance;
}
}
private void Awake()
{
if (_instance != null && _instance != this)
{
Destroy(gameObject);
}
else
{
_instance = this;
}
}
public event CameraInterActHandler CameraInterAct;
public event DialogPopHandler DialogPop;
public event PlayerRunStartHandler PlayerRunStart;
public event PlayerRunningHandler PlayerRunning;
public event PlayerRunStopHandler PlayerRunStop;
public event PlayerWalkStartHandler PlayerWalkStart;
public event PlayerWalkStopHandler PlayerWalkStop;
public event PlayerWalkingHandler PlayerWalking;
public event ItemDialogHandler ItemDialog;
public void EventSwitch(string eventName, string args)
{
switch (eventName)
{
case "OnDialogPop":
OnDialogPop(int.Parse(args));
break;
default:
break;
}
}
public void OnCameraInterAct(GameObject item)
{
CameraInterAct?.Invoke(new CameraInterActArgs(item));
}
public void OnDialogPop(int index)
{
DialogPop?.Invoke(new DialogPopArgs(index));
}
public void OnPlayerWalkStart()
{
PlayerWalkStart?.Invoke();
}
public void OnPlayerWalkStop()
{
PlayerWalkStop?.Invoke();
}
public void OnPlayerWalking()
{
PlayerWalking?.Invoke();
}
public void OnPlayerRunStart()
{
PlayerRunStart?.Invoke();
}
public void OnItemDialog(string nName)
{
ItemDialog?.Invoke(new ItemDialogArgs(nName));
}
public void OnPlayerRunning()
{
PlayerRunning?.Invoke();
}
public void OnPlayerRunStop()
{
PlayerRunStop?.Invoke();
}
}
}