Unregister() public method

When somebody dies, or when a gameobject doesnt need to be called anyMore, Use Unregister, and it will be removes before the next "Turn"
public Unregister ( IGameObject gameObject ) : void
gameObject IGameObject
return void
Example #1
0
 public void CanRegisterGameObject()
 {
     var gm = new GameManager();
     var go = new DummyGameObject();
     Assert.That(gm.GameObjects.Count, Is.EqualTo(0));
     gm.Register(go);
     Assert.That(gm.GameObjects.Count, Is.EqualTo(1));
     Assert.That(gm.GameObjects.Contains(go), Is.EqualTo(true));
     gm.Unregister(go);
     gm.RunTurn();
 }
Example #2
0
 public void ActionIsCalledOnGameObjectInRunTurn()
 {
     var gm = new GameManager();
     var go = new DummyGameObject();
     gm.Register(go);
     Assert.That(go.ActionCalled, Is.False);
     gm.RunTurn();
     Assert.That(go.ActionCalled, Is.True);
     gm.Unregister(go);
     gm.RunTurn();
 }
Example #3
0
        public void CanRegisterRealStuffToTurnManager()
        {
            var gm = new GameManager();
            var listofObjectsToRegister = new List<object>
            {
                new BasicFighter("TestFighter"),
                new Goblin()
            };

            listofObjectsToRegister.ForEach(x =>
            {
                Assert.That(x is IGameObject, Is.True);
                var y = x as IGameObject;
                Assert.DoesNotThrow(() => { gm.Register(y); });
            });
            Assert.That(gm.GameObjects.Count, Is.EqualTo(listofObjectsToRegister.Count));
            listofObjectsToRegister.ForEach(x => { gm.Unregister(x as IGameObject); });
        }