Esempio n. 1
0
        //======================================================================

        void Start()
        {
            // Instantiate controllers.
            ShipCtrl ship = new ShipCtrl(this.shipView);

            this.inputMngr.ship = ship;
            game = new GameCtrl(this.gameView, ship);

            // Start everything.
            game.StartGame();
        }
Esempio n. 2
0
        public void CanRaiseDestroyedEvent()
        {
            ShipCtrl ship   = new ShipCtrl(Substitute.For <IShipView> ());
            bool     raised = false;

            ship.DestroyedEvent += () => raised = true;

            ship.Destroyed();

            Assert.IsTrue(raised);
        }
Esempio n. 3
0
        public void CanBeDestoyedAndRespawned()
        {
            ShipCtrl ship = new ShipCtrl(Substitute.For <IShipView> ());

            ship.Destroyed();

            Assert.False(ship.IsAlive);
            Assert.False(ship.IsActive);

            ship.Respawn();

            Assert.True(ship.IsAlive);
            Assert.True(ship.IsActive);
        }
Esempio n. 4
0
        public void CanBeInactiveWhileTeleporting()
        {
            var    view         = Substitute.For <IShipView> ();
            Action teleportDone = null;

            view.Teleport(Arg.Do <Action> (x => teleportDone = x));
            ShipCtrl ship = new ShipCtrl(view);

            ship.Teleport();

            Assert.True(ship.IsAlive);
            Assert.False(ship.IsActive);

            teleportDone();

            Assert.True(ship.IsAlive);
            Assert.True(ship.IsActive);
        }
Esempio n. 5
0
        public void CannotReactWhileInactive()
        {
            var      view = Substitute.For <IShipView> ();
            ShipCtrl ship = new ShipCtrl(view);

            ship.Destroyed();
            ship.Thrust();
            ship.Rotate(0);
            ship.Teleport();

            view.DidNotReceive().Thrust();
            view.DidNotReceive().Rotate(0);
            view.DidNotReceive().Teleport(Arg.Any <Action> ());

            ship.Respawn();
            ship.Thrust();
            ship.Rotate(0);
            ship.Fire();
            ship.Teleport();

            view.Received(1).Thrust();
            view.Received(1).Rotate(0);
            view.Received(1).Teleport(Arg.Any <Action> ());
        }