public void ReceiveEvent (IGameEvent gameEvent) { foreach (var gameEventListener in listeners) { gameEventListener.ReceiveEvent (gameEvent); } }
public string PublishEvent(IGameEvent eventToPublish) { using (var connection = _factory.CreateConnection()) using (var channel = connection.CreateModel()) { string message = JsonConvert.SerializeObject(eventToPublish); var body = Encoding.UTF8.GetBytes(message); channel.BasicPublish( exchange: "EventExchange", routingKey: eventToPublish.RoutingKey, basicProperties: null, body: body); return $"[x] Sent {message}"; } }
public override void ReceiveEvent(IGameEvent ev) { if (ev.Name == "ChangeSwitch") { object p = ev.getParameter("value"); string iswitch = (string)ev.getParameter("switch"); // When there is a sequence we try to save it as local var but if not, we save it as global if (Sequence.current != null && (Sequence.current.ContainsVariable(iswitch) || !IsoSwitchesManager.getInstance().getIsoSwitches().containsSwitch(iswitch))) { // Save as local Sequence.current.SetVariable(iswitch, p); } else { // Save as global IsoSwitchesManager.getInstance().getIsoSwitches().getSwitch(iswitch).State = p; } } }
public void ReceiveEvent(IGameEvent ev) { if (ev.Name == "event finished" && ev.getParameter("event") == waiting) { finished = true; if (Game.main) { Game.main.DeRegisterEventManager(this); } // eventfinished clone if (eventFinished != null) { eventFinished.Name = ev.Name; foreach (var param in ev.Params) { eventFinished.setParameter(param, ev.getParameter(param)); } } } }
private void CreateBonus(IGameEvent currentEvent) { ICell cell = default(ICell); do { int left = _random.Next(0, currentEvent.GameContext.PlayWidth - 1); int top = _random.Next(0, currentEvent.GameContext.Height - 1); int choice = _random.Next(3); switch (choice) { case 0: cell = _cellFactory.Create("DoubleFoodBonus", left, top); break; case 1: cell = _cellFactory.Create("SlowMoveBonus", left, top); break; case 2: cell = _cellFactory.Create("ImmortalMoveBonus", left, top); break; } } while (currentEvent.GameContext.Used.Contains(cell)); _body.Add(cell); currentEvent.GameContext.Used.Add(cell); }
public override void ReceiveEvent(IGameEvent ev) { if (ev.Name.Equals("Store")) { order = pickUp.GetComponent <PickUpManager> ().data(); pickUp.GetComponent <PickUpManager> ().feedBack++; IsoSwitchesManager.getInstance().getIsoSwitches().getSwitch("order").State = order; } if (ev.Name == "LoadHallWay") { SceneManager.LoadScene("HallWay"); } if (ev.Name == "LoadRecipes") { CharactersController c = GameObject.Find("CharacterController").GetComponent <CharactersController> (); c.endDinner = true; partner.SetActive(false); phone.gameObject.GetComponent <Transform> ().position = new Vector3(0, 0, 0); } }
/// <summary> /// handle cue controller based on the cue ball events /// </summary> /// <param name="sender"></param> /// <param name="gameEvent"></param> private void OnCueBallEvent(object sender, IGameEvent gameEvent) { CueBallActionEvent cueBallActionEvent = (CueBallActionEvent)gameEvent; // start moving the cue stick towards the ball switch (cueBallActionEvent.State) { case CueBallActionEvent.States.Stationary: case CueBallActionEvent.States.Default: { // making sure everything is clean _forceGathered = 0f; // on ready for next shot position the cue controller closer to cue ball transform.position = _cueBall.transform.position - transform.forward * _defaultDistFromCueBall; transform.LookAt(_cueBall); _posToRot = Vector3.one; } break; case CueBallActionEvent.States.Striked: { _cueReleasedToStrike = false; // make the cue ball go back in the play state if (GameManager.Instance.CurrGameState == GameManager.GameState.Play) { // move the cue backward after striking so that cue ball doesnt touch the cue StartCoroutine(MoveCueAfterStrike(transform.position, _cueBall.transform.position - transform.forward * _defaultDistFromCueBall * 1.5f, 1.0f)); } transform.LookAt(_cueBall); _posToRot = _cueBall.transform.position; } break; } }
private void OnReceiveTriggerInfo(IGameEvent obj) { StandardSendGameEvent ssge = (StandardSendGameEvent)obj; if (ssge.Sender.transform.IsChildOf(transform) && estado == EstadoDaqui.emEspera) { if (((Collider2D)ssge.MyObject[0]).tag == "Player") { doHeroi = GameController.g.Manager.transform; estado = EstadoDaqui.buscadorDeAcao; /* * * * EventAgregator.Publish(new StandardSendGameEvent(EventKey.changeMusicWithRecovery, new NameMusicaComVolumeConfig() * { * Musica = NameMusic.miniBoss, * Volume = 1 * }));*/ } } }
void OnReceivedAnimationPoint(IGameEvent e) { if (e.Sender == gameObject) { StandardSendGameEvent ssge = (StandardSendGameEvent)e; string info = (string)ssge.MyObject[1]; switch (info) { case "a": break; case "b": int random = Random.Range(0, 3); if (random < 2) { _Animator.SetTrigger("retornaAoPadrao"); estado = EstadoDaqui.buscadorDeAcao; tempoDecorrido = 0; } else { _Animator.SetTrigger("espadadaDois"); } break; case "c": _Animator.SetTrigger("retornaAoPadrao"); estado = EstadoDaqui.buscadorDeAcao; tempoDecorrido = 0; break; case "e": mov.ApplyForce(forDesl * Mathf.Sign(-transform.localScale.x) * Vector3.right, 1); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.EnemySlash)); break; } } }
public override void eventHappened(IGameEvent ge) { switch (ge.Name.ToLower()) { case "pick": if (ge.getParameter("Executer") != null && ge.getParameter("Item") == this) { Entity executor = ge.getParameter("Executer") as Entity; by = executor.GetComponent <Inventory>(); picked = by != null; } break; case "event finished": if (ge.getParameter("event") == addItemEvent) { destroy = true; } break; } }
public static void Publish(EventKey key, IGameEvent umEvento) { List <Action <IGameEvent> > callbackList; if (_eventDictionary.TryGetValue(key, out callbackList)) { //Debug.Log(callbackList.Count+" : "+umEvento.Sender+" : "+key); foreach (var e in callbackList) { if (e != null) { e(umEvento); } else { Debug.LogWarning("Event agregator chamou uma função nula na key: " + key + "\r\n Geralmente ocorre quando o objeto do evento foi destruido sem se retirar do listener"); } } } }
IEnumerator StartQueue() { queueRunning = true; while (queueRunning) { if (eventQueue.Count != 0) { if (!runningEvent) { IGameEvent gameEvent = eventQueue.Dequeue(); gameEvent.RunEvent(); while (!gameEvent.EventCompleted()) { yield return(null); } } } yield return(null); } eventQueue.Clear(); }
void OnReceivedTriggerInfo(IGameEvent e) { if (e.Sender.transform.IsChildOf(transform)) { Collider2D c = (Collider2D)(((StandardSendGameEvent)e).MyObject[0]); if (c.tag == "Player") { if (e.Sender.name == "ligador") { ligado = true; } else if (e.Sender.name == "desligador") { ligado = false; } else if (e.Sender.name == "requestColor") { VerifiqueSpawnarCorChave(); } } } }
void CheckAnimationPoint(IGameEvent e) { if (e.Sender == gameObject) { StandardSendGameEvent ssge = (StandardSendGameEvent)e; string info = (string)ssge.MyObject[1]; switch (info) { case "a": case "b": case "c": Mov.ApplyForce(forDesl * Mathf.Sign(-transform.localScale.x) * Vector3.right, 1); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.EnemySlash)); break; case "d": TempoDecorrido = 0; _Animator.SetTrigger("retornarAoPadrao"); estado = EstadoDaqui.movendo; break; } } }
public override void HandleMessage(IGameEvent gameEvent) { switch (gameEvent.EventName) { case "RequestActiveItem": { var id = (Guid)gameEvent.EventParams[0]; SystemManager.BroadcastEvent(new SendActiveItemEvent(GetActiveItemForEntity(id))); break; } case "ChangeActiveItem": { var id = (Guid)gameEvent.EventParams[0]; var ent = _systemEntities.Where(e => e.Id == id).FirstOrDefault(); if (ent != null) { ent.GetComponent <InventoryComponent>().IncrementActiveItem(); } break; } } }
void OnReceivedTriggerInfo(IGameEvent e) { StandardSendGameEvent ssge = (StandardSendGameEvent)e; //Debug.Log(ssge.Sender.name+" : "+estado); if (ssge.Sender.transform.IsChildOf(transform)) { Collider2D c = (Collider2D)ssge.MyObject[0]; if (ssge.Sender.name == "triggerAcionador" && estado == EstadoDaqui.emEspera && Time.time - ultimaMordida > intervaloEntreMordidas) { estado = EstadoDaqui.telegrafando; InstanciaLigando.Instantiate(particulaDoInicio, transform.position, 5); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.Fire1)); _Animator.SetTrigger("telegrafar"); new MyInvokeMethod().InvokeNoTempoDeJogo(gameObject, PosTelegrafar, tempoTelegrafando); } else if (ssge.Sender.name == "mordedorEscondido") { VerificadorDeDano(c); } } }
public override void HandleMessage(IGameEvent gameEvent) { switch (gameEvent.EventName) { case "NextFrame": NextFrame(); break; case "AddGameLogMessage": var msg = (string)gameEvent.EventParams[0]; AddGameLogMessage(msg); break; case "RequestGameLogMessages": var msgs = RequestGameLogMessages(); BroadcastMessage(new SendGameLogMessagesEvent(msgs)); break; case "ToggleGameLog": _gameLogEnabled = !_gameLogEnabled; break; } }
//Every update cycle the queue is processed, if the queue processing is limited, //a maximum processing time per update can be set after which the events will have //to be processed next update loop. void Update() { float timer = 0.0f; while (m_eventQueue.Count > 0) { if (LimitQueueProcesing) { if (timer > QueueProcessTime) { return; } } IGameEvent evt = m_eventQueue.Dequeue() as IGameEvent; SendEvent(evt); if (LimitQueueProcesing) { timer += Time.deltaTime; } } }
public override void ReceiveEvent(IGameEvent ev) { if (ev.Name == "Player Name Input") { processing = ev; _input.gameObject.SetActive(true); } else if (ev.Name == "Fernando_Leaves") { //Fernando se va if (this.mainCharacter != null) { this.mainCharacter.SetActive(false); } //Y le llaman al teléfono this.phone.SetActive(true); } else if (ev.Name == "Change_To_Maria_Scene") { //Cambia a escena con María. SceneManager.LoadScene("Conver with Maria"); } }
//广播某个事件 public void Run(IGameEvent msg) { gameEvent(msg); for (int i = eventInfos.Count - 1; i >= 0; --i) { if (eventInfos[i].time == EGameConstL.Infinity) { continue; } eventInfos[i].time -= 1; if (eventInfos[i].time <= 0) { //移除 gameEvent -= eventInfos[i].handler; eventInfos.RemoveAt(i); #if UNITY_EDITOR EventManager.Instance.MgrLog(string.Format("Time is zero, remove handler. KEY = {0}", eventKey)); #endif } } }
void OnReceivedTriggerInfo(IGameEvent e) { if (transform.IsChildOf(e.Sender.transform) && estado == EstadoDaqui.emEspera) { float px = ((Collider2D)((StandardSendGameEvent)e).MyObject[0]).transform.position.x; bool foi = false; if (Mathf.Abs(ultimoInvestimento - Time.time) > intervaloDeInvestimento) { for (int i = 0; i < trajetorias.Length; i++) { float partida = trajetorias[i].partida.position.x; float chegada = trajetorias[i].chegada.position.x; //Debug.Log(Mathf.Abs(partida - px)+" : "+px +" : "+" : "+partida+" : "+chegada+" : "+(partida < px && px < chegada) +" : "+ (partida > px && chegada < px) +" : "+ (Mathf.Abs(partida - px) > disMin)+" : "+i); if (((partida < px && px < chegada) || (partida > px && chegada < px)) && (Mathf.Abs(partida - px) > disMin)) { indiceDoDeslocamento = i; foi = true; } } if (foi) { transform.position = trajetorias[indiceDoDeslocamento].partida.position; InstanciaLigando.Instantiate(particulaDoAparecimento, transform.position, 5); EventAgregator.Publish(new StandardSendGameEvent(EventKey.disparaSom, SoundEffectID.aparicaoSurpresaDeInimigo)); estado = EstadoDaqui.telegrafando; tempoDecorrido = 0; FlipDirection.Flip(transform, trajetorias[indiceDoDeslocamento].partida.position.x - trajetorias[indiceDoDeslocamento].chegada.position.x); ChangeView(true); } } } }
private void OnUpdateGeometryComplete(IGameEvent e) { StandardSendGameEvent ssge = (StandardSendGameEvent)e; bool ePentagono = (bool)ssge.MyObject[0]; if (ePentagono) { dados.PentagonosCompletados++; dados.MaxMana = dados.BaseMaxMana + dados.PentagonosCompletados * dados.AddMagicBarAmount; dados.PontosDeMana = dados.MaxMana; dados.PartesDePentagonosObtidas = 0; } else { dados.PartesDeHexagonoObtidas = 0; dados.HexagonosCompletados++; dados.MaxVida = dados.BaseMaxLife + dados.HexagonosCompletados * dados.AddLifeBarAmount; dados.PontosDeVida = dados.MaxVida; } TrophiesManager.VerifyTrophy(ePentagono ? TrophyId.completeUmPentagono : TrophyId.completeUmHexagono); EventAgregator.Publish(new StandardSendGameEvent(EventKey.starterHudForTest, dados)); }
public override void ReceiveEvent(IGameEvent ev) { if (ev.Name == "Phone Appears") { phone.SetActive(true); parent.SetActive(false); } else if (ev.Name == "First_Step") { recipe.showFirstStep(); } else if (ev.Name == "Second_Step") { recipe.showSecondtStep(); } else if (ev.Name == "Third_Step") { recipe.showThirdStep(); } else if (ev.Name == "Fourth_Step") { recipe.showFourthStep(); } }
/// <summary> /// Receive the pick event /// </summary> /// <param name="ev"></param> public override void ReceiveEvent(IGameEvent ev) { if (ev.Name.Replace("\"", "") == "change state" && (keyEvent == null || keyEvent == "" || ((String)ev.getParameter(SequenceGenerator.EVENT_KEY_FIELD)).Replace("\"", "") == keyEvent)) { object vAux = ev.getParameter(SequenceGenerator.EVENT_VARIABLE_FIELD); string var = null; if (vAux != null) { var = ((String)vAux).Replace("\"", ""); } var value = ev.getParameter(SequenceGenerator.EVENT_VALUE_FIELD); object sAux = ev.getParameter(SequenceGenerator.EVENT_STATE_FIELD); int state = 0; if (sAux != null) { state = (int)sAux; } this.ChangeStateObject(var, value, state); } }
public static void Publish(string eventName, IGameEvent eventInfos) { if (_eventDictionary.TryGetValue(eventName, out List <Action <IGameEvent> > callbackList)) { Action <IGameEvent>[] callbackListAux = callbackList.ToArray(); foreach (var callback in callbackListAux) { callback?.Invoke(eventInfos); if (callback != null) { #if UNITY_EDITOR Debug.Log($"Event: {eventName}. Calling {callback.Method} from {callback.Target}."); #endif } #if UNITY_EDITOR else { Debug.LogWarning($"Event: {eventName}. Some callback is null."); } #endif } } }
public void OnEvent(IGameEvent gameEvent) { }
public void EventHappened(IGameEvent ge) { }
internal static void EventHappened(MonoBehaviour reference, Dictionary <GameEventConfig, MethodInfo> calls, Dictionary <MethodInfo, GameEventAttribute> attrInfo, IGameEvent ge, CoroutineControllerDelegate coroutineController) { if (calls != null && calls.Count > 0) { var config = new GameEventConfig(ge); if (calls.ContainsKey(config)) { var call = calls[config]; if (!attrInfo[call].RequiresReference || ge.belongsTo(reference, reference.GetType().Name)) { List <object> parameters = new List <object>(); foreach (var p in call.GetParameters()) { if (ge.Params.Contains(p.Name.ToLower())) { parameters.Add(ge.getParameter(p.Name)); } else { parameters.Add(p.DefaultValue); } } var output = call.Invoke(reference, parameters.ToArray()); if (output is IEnumerator) { // If we want to autofinish it we use the controller, else just launch it reference.StartCoroutine(attrInfo[call].AutoFinish ? coroutineController(ge, output as IEnumerator, reference) : output as IEnumerator); } else if (attrInfo[call].AutoFinish) { // If is not a coroutine and we have to auto finish it, we just do it Game.main.eventFinished(ge); } } } } }
public void Tick() { if (node.Content is Dialog) { Dialog dialog = node.Content as Dialog; if (!launched) { wasLooking = CameraManager.Instance.Target; fragments = new Queue <Fragment>(dialog.Fragments); launched = true; next = true; chosen = -1; } if (next) { if (fragments.Count > 0) { if (fragments.Peek().Entity != null) { CameraManager.Instance.LookTo(fragments.Peek().Entity.gameObject); } // Launch next fragment event var nextFragment = fragments.Dequeue().Clone(); // Parse the formulas nextFragment.Name = ParseFormulas(nextFragment.Name); nextFragment.Msg = ParseFormulas(nextFragment.Msg); var ge = new GameEvent(); ge.name = "show dialog fragment"; ge.setParameter("fragment", nextFragment); ge.setParameter("launcher", this); ge.setParameter("synchronous", true); eventLaunched = ge; Game.main.enqueueEvent(ge); next = false; } else { chosen = 0; } } } else if (node.Content is Options) { if (!launched) { chosen = -1; Options options = (node.Content as Options).Clone() as Options; wasLooking = CameraManager.Instance.Target; // Launch options event var ge = new GameEvent(); ge.name = "show dialog options"; optionsList = options.Values; launchedOptionsList = optionsList.FindAll(o => o.Fork == null || o.Fork.check()); // Parse the formulas options.Question = ParseFormulas(options.Question); launchedOptionsList.ForEach(o => o.Parameter = ParseFormulas(o.Parameter)); launchedOptionsList.ForEach(o => o.Text = ParseFormulas(o.Text)); ge.setParameter("options", launchedOptionsList); ge.setParameter("message", options.Question); ge.setParameter("launcher", this); ge.setParameter("synchronous", true); eventLaunched = ge; Game.main.enqueueEvent(ge); launched = true; } } if (chosen != -1) { finished = true; CameraManager.Instance.LookTo(wasLooking); if (node.Childs.Length > chosen) { nextNode = node.Childs[chosen]; } chosen = -1; } }
private void OnExecutionCompleted(IGameEvent eventparameters) { gameObject.SetActive(true); }
private void OnExecutionTriggered(IGameEvent eventparameters) { gameObject.SetActive(false); }
public override void ReceiveEvent(IGameEvent ge) { Current = ge; EventedEntityScript.EventHappened(this, calls, attrInfo, ge, CoroutineController); Current = null; }
public void Trigger(IGameEvent gameEvent) { _events.OnNext(gameEvent); }
void TestEventHandler(IGameEvent evt) { TestEvent test = (TestEvent)evt; Console.WriteLine(test.Message); }
/// <inheritdoc/> public void Emit(IGameEvent e) { _eventSource.OnNext(e); }
/// <summary> /// Adds an event to the event queue to be processed /// before the frame being processed /// </summary> /// <param name="evt">Event to be queued</param> public static void QueueEvent(IGameEvent evt) { EventQueues[activeQueue].Enqueue(evt); }
/// <summary> /// Fire an event inmediately /// </summary> /// <param name="evt">Event to fire</param> public static void FireEvent(IGameEvent evt) { Listeners[evt.ID].Invoke(evt); }
public void Emit(IGameEvent e) => _transaction.Emit(e);