示例#1
0
 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));
 }
示例#2
0
 //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]);
 }
示例#3
0
 /// <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));
 }
示例#4
0
 /// <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));
 }