public void Jump() { // Do some math here... Debug.Log("Player jumps..."); // Dispatch via Signal Hub that we made a jump. _hub.Get <Sgnls.PlayerSignals.Jump>().Dispatch(); }
private void Start() { SimonSaysPuzzle Parent = GetComponentInParent <SimonSaysPuzzle>(); if (Parent) { SSSignals = Parent.SimonSaysHub; } SSSignals.Get <LightOnGreenSignal>().AddListener(OnGreen); SSSignals.Get <LightOnYellowSignal>().AddListener(OnYellow); SSSignals.Get <LightOnRedSignal>().AddListener(OnRed); SSSignals.Get <LightOffSignal>().AddListener(OffDull); }
private void Start() { // Listen signals via hub1 hub.Get <Sgnls.PlayerSignals.Jump>() .On(OnPlayerJump) // Set handler .Countdown(3) // How many times handler (OnPlayerJump) will be called. .Priority(1000) // Priority of handler (OnPlayerJump) in queue. .When(() => _player.health >= 50); // Condition in which handler will be called. // Sometime very handy to listen signal only once. _playerDamageCallback = hub.Get <Sgnls.PlayerSignals.Damage>().Once(damage => { Debug.Log($"Update player's health bar: health {_player.health} / 100"); }); _player = new Player(hub); }
private void Start() { SignalHub hub = new SignalHub(); button1.onClick.AddListener(() => hub.Get <OnClick>().Dispatch(button1)); button2.onClick.AddListener(() => hub.Get <OnClick>().Dispatch(button2)); hub.Get <OnClick>() .On(btn => { Debug.Log($"On Click Handler 1. Dispatcher {btn.name}"); }); hub.Get <OnClick>() .On(btn => Debug.Log($"On Click Handler 2. But should go first. Dispatcher {btn.name}")) .Priority(100); var count = 3; hub.Get <OnClick>() .On(btn => { count--; Debug.Log($"On Click Handler 3. Left {count}. Dispatcher {btn.name}"); }) .Countdown(3); hub.Get <OnClick>() .On(btn => { Debug.Log($"On Click Handler 4. Dispatch when count == 0 {count}. Dispatcher {btn.name}"); }) .When(() => count == 0); }
// Start is called before the first frame update void Start() { Parent = GetComponentInParent <SimonSaysPuzzle>(); if (Parent) { SSSignals = Parent.SimonSaysHub; } SSSignals.Get <CorrectLightSignal>().AddListener(CorrectAndLock); SSSignals.Get <IncorrectLightSignal>().AddListener(IncorrectAndLock); SSSignals.Get <ClearLightSignal>().AddListener(Reset); SSSignals.Get <FlashLightSignal>().AddListener(StartFlashNoParams); SSSignals.Get <LockLightSignal>().AddListener(Lock); }
public static SType Get <SType>() where SType : ISignal, new() { return(hub.Get <SType>()); }
// Start is called before the first frame update void Start() { //get count for random ButtonCount = LightButtons.Count; for (int i = 0; i < ButtonCount; i++) { LightButtons[i].ID = i; } ClearLights(); SimonSaysHub.Get <SimonButtonPressedSignal>().AddListener(HandleButtonPress); GenerateSequence(); //debug to see sequence //PresentSequence(); }