void InitListeners() { EM_EventMgr_ = gameObject.AddComponent <EM_EventMgr>(); //listenerPlayerConfirmed = new UnityAction(PlayerConfirmFunction); //listenerEtc = new UnityAction(EtcFunction); listenerMakeMaze = new UnityAction(MakeMaze); }
void VerifySufficientAmountPlayersToBegin() { PM_PlayerMgr playerMgr = gameObject.GetComponent <PM_PlayerMgr>(); if (playerMgr == null) { return; } if (playerMgr.coupledPlayersActive >= PM_PlayerMgr.MINIMUM_PLAYERS) { PermitState resultState = TransitionToNewState(StartButtonState_, NumberPlayers.Enough); if (resultState != StartButtonState_) { StartButtonState_ = resultState; EM_EventMgr.TriggerEvent("enable start button"); } } else if (playerMgr.coupledPlayersActive < PM_PlayerMgr.MINIMUM_PLAYERS) { PermitState resultState = TransitionToNewState(StartButtonState_, NumberPlayers.Not_Enough); if (resultState != StartButtonState_) { StartButtonState_ = resultState; EM_EventMgr.TriggerEvent("disable start button"); } } }
void Update() { string[] gamepadChanges = DetectGamepadsConnectedChanged(); // send message of (gamepadChanges); if (gamepadChanges.Length != 0) { coupledGamepadChanges = gamepadChanges; EM_EventMgr.TriggerEvent("update players connected"); } }
void InitGame() { //add a bunch of startup logic (other classes, other components). SM_ScreenMgr_ = gameObject.AddComponent <SM_ScreenMgr>(); GPM_GamepadMgr_ = gameObject.AddComponent <GPM_GamepadMgr>(); PM_PlayerMgr_ = gameObject.AddComponent <PM_PlayerMgr>(); GSM_GameStateMgr_ = gameObject.AddComponent <GSM_GameStateMgr>(); MM_MazeMgr_ = gameObject.AddComponent <MM_MazeMgr>(); EM_EventMgr.TriggerEvent("get players"); }
//"adapter method" that is exposed / bound in-Editor to the Button's OnClick. //perhaps in the future create an interface which enforces this, by throwing an exception, by detecting when a singular function isn't bound public void StartButton() { EM_EventMgr.TriggerEvent("make maze"); }
void OnDisable() { EM_EventMgr.StopListening("enable start button", ToggleStartButtonOn); EM_EventMgr.StopListening("disable start button", ToggleStartButtonOff); }
void OnDisable() { EM_EventMgr.StopListening("update players connected", UpdatePlayerActiveCount); }
} //prefer to rewrite event manager to support parameters to avoid this coupling void Start() { EM_EventMgr.TriggerEvent("player confirm"); //gamepadNamesEverConnected = Input.GetJoystickNames(); gamepadNamesEverConnected = new string[0]; }
//OnDisable is necessary to manage properly memory and thus avoid memory leaks void OnDisable() { //EM_EventMgr.StopListening("player confirm", PlayerConfirmFunction); //EM_EventMgr.StopListening("etc", EtcFunction); EM_EventMgr.StopListening("make maze", MakeMaze); }
void OnDisable() { EM_EventMgr.StopListening("get players", ActivateScenesGettingPlayers); EM_EventMgr.StopListening("update players connected", UpdateGamepadIconsInSceneS1); EM_EventMgr.StopListening("update players connected", UpdatePlayerIconsInSceneS1); }
void OnDisable() { EM_EventMgr.StopListening("update players connected", VerifySufficientAmountPlayersToBegin); }