| 12345678910111213141516171819202122232425262728 |
- import { EventTarget } from 'cc';
- /**
- * 全局事件总线,用于模块间解耦通信。
- */
- export enum GameEvents {
- GAME_START = 'GAME_START',
- GAME_PAUSE = 'GAME_PAUSE',
- GAME_RESUME = 'GAME_RESUME',
- GAME_SUCCESS = 'GAME_SUCCESS',
- GAME_DEFEAT = 'GAME_DEFEAT',
- SHOP_UPDATED = 'SHOP_UPDATED'
- }
- export default class EventBus extends EventTarget {
- private static _instance: EventBus;
- private constructor() {
- super();
- }
- public static getInstance(): EventBus {
- if (!this._instance) {
- this._instance = new EventBus();
- }
- return this._instance;
- }
- }
|