void Start() { energy = new Dictionary <string, int> { { "fire", 100 }, { "life", 100 } }; terrain = GameObject.Find("Terrain"); lastTickTime = 0.0f; uiState = UI_STATES["Idle"]; events.Add(new Event(gameObject, Config.Fire_Drain_Ticks, DrainFireEnergy, true)); events.Add(new Event(gameObject, Config.Life_Drain_Ticks, DrainLifeEnergy, true)); }
//Creates an EventHandler on runtime and registers that handler to the Event specified public void BindEvent(DependencyObject owner, string eventName) { EventName.Add(eventName); Owner = owner; Event.Add(Owner.GetType().GetEvent(eventName, BindingFlags.Public | BindingFlags.Instance)); if (Event == null) { return; } EventHandler.Add(EventHandlerGenerator.CreateDelegate( Event[Event.Count - 1].EventHandlerType, typeof(CommandBehaviorBinding).GetMethod("Execute", BindingFlags.Public | BindingFlags.Instance), this, eventName)); Event[Event.Count - 1].AddEventHandler(Owner, EventHandler[EventHandler.Count - 1]); }
/// <summary>Add an event handler which is kept only by a weak reference.</summary> /// <param name="source">The source (publisher).</param> /// <param name="targetHandler">The target event handler of the subscriber.</param> /// <returns>The created proxy object.</returns> public static IWeakEventProxy Add(INotifyDataErrorInfo source, S.EventHandler <DataErrorsChangedEventArgs> targetHandler) { return(EventHandler <DataErrorsChangedEventArgs> .Add(source, targetHandler, (s, h) => s.ErrorsChanged += h, (s, h) => s.ErrorsChanged -= h)); }
/// <summary>Add an event handler which is kept only by a weak reference.</summary> /// <param name="source">The source (publisher).</param> /// <param name="targetHandler">The target event handler of the subscriber.</param> /// <returns>The created proxy object.</returns> public static IWeakEventProxy Add(ICommand source, S.EventHandler targetHandler) { return(EventHandler.Add(source, targetHandler, (s, h) => s.CanExecuteChanged += h, (s, h) => s.CanExecuteChanged -= h)); }