Exemplo n.º 1
0
        public void AddEvent_containMultiTrigger_TheAddedEventGetsFired()
        {
            TriggerManager tm = new TriggerManager();

            bool eventfired = false;

            MultiTrigger mt = new MultiTrigger();

            tm.Register(mt);

            mt.AddAction<XmasEvent>(e => eventfired = true);

            mt.RegisterEvent<UnitTakesDamagePostEvent>();

            tm.Raise(new UnitTakesDamagePostEvent(null, null, 0, 0));

            Assert.IsTrue(eventfired);
        }
Exemplo n.º 2
0
        public void AddAction_containMultiTrigger_TheActionIsNotFired()
        {
            TriggerManager tm = new TriggerManager();

            bool actionfired = false;

            MultiTrigger mt = new MultiTrigger();

            Action<UnitTakesDamagePostEvent> action = (e => actionfired = true);

            mt.RegisterEvent<UnitTakesDamagePostEvent>();

            tm.Register(mt);

            mt.AddAction(action);

            tm.Raise(new UnitTakesDamagePostEvent(null, null, 0, 0));

            Assert.IsTrue(actionfired);
        }
Exemplo n.º 3
0
        public void AddEventToUnit_containMultiTrigger_TheAddedEventGetsFired()
        {
            EventManager gem = new EventManager();

            Unit A = new Unit();

            gem.AddEntity(A);

            bool eventfired = false;

            MultiTrigger mt = new MultiTrigger();

            A.Register(mt);

            mt.AddAction<XmasEvent>(e => eventfired = true);

            mt.RegisterEvent<UnitTakesDamagePostEvent>();

            A.Raise(new UnitTakesDamagePostEvent(null, null, 0, 0));

            Assert.IsTrue(eventfired);
        }
Exemplo n.º 4
0
        public void RemoveCondition_containMultiTrigger_TheActionIsFired()
        {
            TriggerManager tm = new TriggerManager();

            bool actionfired = false;

            MultiTrigger mt = new MultiTrigger();

            Predicate<UnitTakesDamagePostEvent> cond = (e => false);
            mt.AddCondition(cond);
            mt.AddAction<XmasEvent>(e => actionfired = true);
            mt.RegisterEvent<UnitTakesDamagePostEvent>();

            tm.Register(mt);

            mt.RemoveCondition(cond);

            tm.Raise(new UnitTakesDamagePostEvent(null, null, 0, 0));

            Assert.IsTrue(actionfired);
        }