Esempio n. 1
0
        public void TestRegisterUnregister()
        {
            int resultvalue = 0;

            SmartEvent.OnReceiveEvent <PlayerHealthEvent>(this, evt =>
            {
                resultvalue = evt.Health;
            });

            SmartEvent.Broadcast(new PlayerHealthEvent()
            {
                Health = 100
            });

            Assert.AreEqual(100, resultvalue, "Maybe OnReceiveEvent was not called");

            resultvalue = 50;
            SmartEvent.OnReceiveEventRemove <PlayerHealthEvent>(this);

            SmartEvent.Broadcast(new PlayerHealthEvent()
            {
                Health = 100
            });

            Assert.AreEqual(resultvalue, 50, "Maybe OnReceiveEvent was called and couldn't get removed");

            SmartEvent.Clear();
        }
Esempio n. 2
0
 void SendEvent()
 {
     SmartEvent.Broadcast(new DamageEvent(30)
     {
         Attacker = "Soldier"
     });
 }
Esempio n. 3
0
        public void TestPlayerHealth()
        {
            int testValue = 100;

            SmartEvent.OnReceiveEvent <PlayerHealthEvent>(this, evt =>
            {
                Assert.AreEqual(testValue, evt.Health);
            });

            SmartEvent.Broadcast(new PlayerHealthEvent()
            {
                Health = 100
            });

            SmartEvent.Clear();
        }