コード例 #1
0
        public async Task <GameResult> PlayGame(CancellationToken cancellationToken)
        {
            //Initial animation
            await gameType.StartAnimation(cancellationToken);

            gameUIAdapter = (IGameUIAdapter)(await windowNavigation.Show <IGameUIAdapter>(cancellationToken));
            _             = gameUIAdapter.CardsUIAdapter.Hide(cancellationToken);


            for (int i = 0; i < currentGame.Waves.Length && !cancellationToken.IsCancellationRequested; i++)
            {
                gameUIAdapter.SetCurrentWave(i, currentGame.Waves.Length);
                gameUIAdapter.PlayerUIAdapter.Load();

                var currentWave = currentGame.Waves[i];
                var waveResult  = await waveStrategy.PlayWave(gameType, currentWave, cancellationToken);

                gameUIAdapter.PlayerUIAdapter.Unload();

                currentGameResult.WavesResults[i] = waveResult;
            }

            if (!cancellationToken.IsCancellationRequested)
            {
                resultsUIAdapter.LoadResult(currentGameResult);
                await resultsUIAdapter.Show(cancellationToken);
            }

            await windowNavigation.Hide <IGameUIAdapter>(cancellationToken);

            await gameType.EndAnimation(cancellationToken);

            return(currentGameResult);
        }
コード例 #2
0
 public WaveStrategy(Player player, IGameUIAdapter gameUIadapter, ITimeAdapter timeAdapter, IEnemyLoader enemyLoader, IWeaponLoader weaponLoader, IInputService inputService)
 {
     this.player        = player;
     this.gameUIadapter = gameUIadapter;
     this.timeAdapter   = timeAdapter;
     this.enemyLoader   = enemyLoader;
     this.weaponLoader  = weaponLoader;
     this.inputService  = inputService;
 }