Esempio n. 1
0
        /// <inheritdoc />
        public override void Update()
        {
            base.Update();

            // Invoke our custom event on each update. Subscribe to MyCustomEvent get events.
            MyCustomEvent?.Invoke();
        }
Esempio n. 2
0
        public void ItShouldNotApplyAnUnsupportedEvent()
        {
            var toDo = new Domain.Write.ToDo.ToDo();

            var @event = new MyCustomEvent(toDo.Id, new MyCustomEventData());

            Assert.Throws <InvalidOperationException>(() => toDo.When(@event));
        }
    public static void TriggerEvent(string eventName, string data)
    {
        MyCustomEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(data);
        }
    }
    public static void StopListening(string eventName, UnityAction <string> listener)
    {
        if (eventName == null)
        {
            return;
        }
        MyCustomEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.RemoveListener(listener);
        }
    }
    public static void StartListening(string eventName, UnityAction <string> listener)
    {                                   //Empieza a escuchar los eventos que ocurren dentro del juego
        MyCustomEvent thisEvent = null; //Crea un costum event vacío

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        { //Inicializa el dictionario y busca obtener el evento. Si ya tiene eventos, nada más lo añade
            thisEvent.AddListener(listener);
        }
        else
        { //Si no tiene eventos, crea un nuevo evento y lo añade
            thisEvent = new MyCustomEvent();
            thisEvent.AddListener(listener);
            instance.eventDictionary.Add(eventName, thisEvent);
        }
    }