Example #1
0
        public bool FlushRenderQueue(IUnitySnapBehavior targetViewModel)
        {
            while (m_renderQueue.Count > 0)
            {
                targetViewModel.AddGameObjectToScene(m_renderQueue.Dequeue());
            }

            return(true);
        }
Example #2
0
        public static IGameController GetGameController(IUnitySnapBehavior viewModel)
        {
            Check.NotNull(viewModel, "viewModel");

            if (_gameContextContainer == null)
            {
                _gameContextContainer = CreateGameContextContainer(viewModel);
            }

            using (var scope = _gameContextContainer.BeginLifetimeScope())
                return(scope.Resolve <IGameController>());
        }
Example #3
0
        public DefaultGameController(IUnitySnapBehavior viewModel,
                                     IGameTurnManager turnManager, ISlapjackGame game)
        {
            Check.NotNull(viewModel, "viewModel");
            Check.NotNull(turnManager, "turnManager");
            Check.NotNull(game, "game");

            m_turnManager = turnManager;
            ViewModel     = viewModel;
            CurrentGame   = game;

            m_renderQueue         = new Queue <GameObject>();
            m_playerDeckLocations = new Dictionary <ICardGamePlayer, GameObjectTransformModel>();
        }
Example #4
0
        private static IContainer CreateGameContextContainer(IUnitySnapBehavior viewModel)
        {
            var builder = new ContainerBuilder();

            builder.RegisterInstance(viewModel).As <IUnitySnapBehavior>();
            builder.RegisterType <FrenchCardCollectionFactory>().As <ICardCollectionFactory>();
            builder.RegisterType <DefaultCardDealerLogic>().As <ICardDealerLogic>();
            builder.RegisterType <DefaultSnapGameType>().As <ISlapjackGame>();
            builder.RegisterType <DefaultGameController>().As <IGameController>();
            builder.RegisterType <DefaultGameTurnManager>().As <IGameTurnManager>();
            builder.RegisterType <DefaultPlayerTurnManager>().As <IPlayerTurnManager>();
            builder.RegisterType <FrenchCardObjectFactory>().As <ICardObjectFactory>();
            builder.RegisterType <DefaultCardSpriteFactory>().As <ICardSpriteFactory>();
            builder.RegisterType <DefaultCardTypeDescriptor>().As <ICardTypeDescriptor>();
            builder.RegisterType <DefaultCardTypeTextureResolver>().As <ICardTypeTextureResolver>();

            return(builder.Build());
        }
        private static void SetupMocks(out IUnitySnapBehavior snapBehavior, out IGameTurnManager gameTurnManager,
                                       out ISlapjackGame game, out ICardDealerLogic cardDealerLogic)
        {
            snapBehavior = Substitute.For <IUnitySnapBehavior>();
            snapBehavior.TurnUpCard(Arg.Any <ICardObject>()).Returns(true);

            gameTurnManager = SetupTurnManagerMock();
            var player = gameTurnManager.PlayerTurnManager.PlayerTurns.First().AssociatedPlayer;

            game = Substitute.For <ISlapjackGame>();
            game.Players.Returns(new List <ICardGamePlayer>()
            {
                player
            });

            cardDealerLogic = Substitute.For <ICardDealerLogic>();
            cardDealerLogic.DealCards(Arg.Any <int>()).Returns(new List <ICardCollection>());
        }