public static ConditionalEventWrapper CreateWrapper <T1, T2>(
            IConditionalEvent <T1, T2> iConditional)
            where T1 : GameObject
            where T2 : GameObject
        {
            var instance = new ConditionalEventWrapper(iConditional, typeof(T1), typeof(T2));

            return(instance);
        }
예제 #2
0
 private void AddToDictionary(Type first, Type second, ConditionalEventWrapper action)
 {
     if (!conditionalEvents.ContainsKey(first))
     {
         conditionalEvents[first] = new Dictionary <Type, List <ConditionalEventWrapper> >();
     }
     if (!conditionalEvents[first].ContainsKey(second))
     {
         conditionalEvents[first][second] = new List <ConditionalEventWrapper>();
     }
     conditionalEvents[first][second].Add(action);
 }
예제 #3
0
 public ParametrizedCharacter <TCharacter> AddCollideInteraction <T>(Action <TCharacter, T> action)
     where T : ParametrizedGameObject
 {
     if (!conditionalEvents.ContainsKey(typeof(T)))
     {
         conditionalEvents[typeof(T)] = new List <ConditionalEventWrapper>();
     }
     conditionalEvents[typeof(T)].Add(ConditionalEventWrapper.CreateWrapper(
                                          new SimpleCollideInteraction <TCharacter, T>((a, b) =>
     {
         if (a != b)
         {
             action(a, b);
         }
     })));
     return(this);
 }
 public static ConditionalEventWrapper Wrap <TObject1, TObject2>(this IConditionalEvent <TObject1, TObject2> item)
     where TObject1 : GameObject
     where TObject2 : GameObject
 {
     return(ConditionalEventWrapper.CreateWrapper(item));
 }
예제 #5
0
 public void AddIConditionalEvent <TFirst, TSecond>(IConditionalEvent <TFirst, TSecond> action)
     where TFirst : GameObject
     where TSecond : GameObject
 {
     AddToDictionary(typeof(TFirst), typeof(TSecond), ConditionalEventWrapper.CreateWrapper(action));
 }