GameManager is the class that handles a game, it handles all the gameobjects and runs the current turn based of the gameobjects Initative
 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();
 }
 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();
 }
        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); });
        }
Exemple #4
0
        public MainWindowVm()
        {
            DoBattleButtonCommand = new DoBattleCommand(this);
            Game.OnGameLoggedEntry += UpdateGameLog;

            GameEngine = new GameManager();
            var bs = new BasicFighter("Urban den förskräcklige");
            var bs2 = new BasicFighter("Jürgen den oförskräcklige");

            bs.Target = bs2;
            bs2.Target = bs;

            bs.AddCommand(CommandHandler.enums.Commands.MeleeAttack);
            bs2.AddCommand(CommandHandler.enums.Commands.MeleeAttack);

            GameEngine.Register(bs);
            GameEngine.Register(bs2);

            FirstCombatant = GameEngine.GameObjects.First() as IEntity;
            SecondCombatant = GameEngine.GameObjects.ElementAt(1) as IEntity;
            RaisePropertyChanged(nameof(FirstCombatantHp));
            RaisePropertyChanged(nameof(SecondCombatantHp));
            RaisePropertyChanged(nameof(FirstCombatantAc));
            RaisePropertyChanged(nameof(SecondCombatantAc));
        }
Exemple #5
0
 public GameManager()
 {
     ActiveGameManager = this;
 }
Exemple #6
0
 public Camera(Canvas displayCanvas, GameManager gameManager)
 {
     DisplayCanvas = displayCanvas;
     GameManager = gameManager;
     GameManager.UnregisterEvent += RemoveUnregisteredGameObjectsFromCanvas;
 }