SharpLibEar/Event.cs
author StephaneLenclud
Fri, 29 Jul 2016 14:46:30 +0200
changeset 229 7c631055b94b
parent 212 1a0791daa243
child 231 4c706feaf706
permissions -rw-r--r--
Adding event test button.
     1 //
     2 
     3 
     4 using System;
     5 using System.Collections.Generic;
     6 using System.Runtime.Serialization;
     7 
     8 namespace SharpLib.Ear
     9 {
    10     [DataContract]
    11     public abstract class MEvent
    12     {
    13         public string Name { get; protected set; }
    14         public string Description { get; protected set; }
    15 
    16         public abstract void Trigger();
    17     };
    18 
    19     [DataContract]
    20     public abstract class Event : MEvent
    21     {
    22         [DataMember]
    23         public List<Action> Actions = new List<Action>();
    24 
    25         protected Event()
    26         {
    27            
    28         }
    29 
    30         public override void Trigger()
    31         {
    32             Console.WriteLine("Event triggered: " + Name);
    33             foreach (Action action in Actions)
    34             {
    35                 action.Execute();
    36             }
    37         }
    38     }
    39 
    40 }