public void Handle(GameKeyEvent message) { if (!IsActive || IsPopupShowing) { return; } if (DebugSongHelper.HandleKeyPressed(this, message)) { return; } if (message.PlayerAction == PlayerAction.Back) { PauseGame(); IsPopupShowing = true; _eventAggregator.Publish(new ShowPopupEvent() { PopupType = PopupType.ButtonsPopup, PopupSettings = (vm) => { (vm as ButtonsPopupViewModel).Buttons.AddRange(new List <string>() { "Resume", "Play again", "Go back" }); (vm as ButtonsPopupViewModel).Message = "Pause"; } }); } }
public static void TriggerEvent(string eventName, string payload = "") { GameKeyEvent thisEvent = new GameKeyEvent(); if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(payload); } }
public static void StopListening(string eventName, UnityAction <string> listener) { if (eventManager == null) { return; } GameKeyEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void StartListening(string eventName, UnityAction <string> listener) { GameKeyEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new GameKeyEvent(); thisEvent.AddListener(listener); instance.eventDictionary.Add(eventName, thisEvent); } }
public static bool HandleKeyPressed(GameViewModel model, GameKeyEvent e) { #if DEBUG_HIT_TIME || DEBUG_TIMING if (e.PlayerAction == PlayerAction.Back) { return(false); } else if (e.PlayerAction == PlayerAction.Enter) { model.ResumeGame(); } else { model.PauseGame(); } return(true); #else return(false); #endif }