#pragma warning restore 618 public void TestFixtureSetUp() { BossManager = MockRepository.GenerateStub <IBossManager>(); BulletManager = MockRepository.GenerateStub <IBulletManager>(); CollisionManager = MockRepository.GenerateStub <ICollisionManager>(); CommandManager = MockRepository.GenerateStub <ICommandManager>(); ConfigManager = MockRepository.GenerateStub <IConfigManager>(); ContentManager = MockRepository.GenerateStub <IContentManager>(); ControlManager = MockRepository.GenerateStub <IControlManager>(); DebugManager = MockRepository.GenerateStub <IDebugManager>(); DelayManager = MockRepository.GenerateStub <IDelayManager>(); DeviceManager = MockRepository.GenerateStub <IDeviceManager>(); EnemyManager = MockRepository.GenerateStub <IEnemyManager>(); EventManager = MockRepository.GenerateStub <IEventManager>(); ExplosionManager = MockRepository.GenerateStub <IExplosionManager>(); IconManager = MockRepository.GenerateStub <IIconManager>(); ImageManager = MockRepository.GenerateStub <IImageManager>(); InputManager = MockRepository.GenerateStub <IInputManager>(); LevelManager = MockRepository.GenerateStub <ILevelManager>(); MoverManager = MockRepository.GenerateStub <IMoverManager>(); RandomManager = MockRepository.GenerateStub <IRandomManager>(); RenderManager = MockRepository.GenerateStub <IRenderManager>(); ResolutionManager = MockRepository.GenerateStub <IResolutionManager>(); ScoreManager = MockRepository.GenerateStub <IScoreManager>(); ScreenManager = MockRepository.GenerateStub <IScreenManager>(); SoundManager = MockRepository.GenerateStub <ISoundManager>(); SpriteManager = MockRepository.GenerateStub <ISpriteManager>(); StateManager = MockRepository.GenerateStub <IStateManager>(); StopwatchManager = MockRepository.GenerateStub <IStopwatchManager>(); StorageManager = MockRepository.GenerateStub <IStorageManager>(); TextManager = MockRepository.GenerateStub <ITextManager>(); ThreadManager = MockRepository.GenerateStub <IThreadManager>(); FileManager = MockRepository.GenerateStub <IFileManager>(); Logger = MockRepository.GenerateStub <ILogger>(); }
public GameManager ( IConfigManager configManager, IContentManager contentManager, IDeviceManager deviceManager, IInputManager inputManager, IRandomManager randomManager, IResolutionManager resolutionManager, IScreenManager screenManager, ITextManager textManager, IThreadManager threadManager, IFileManager fileManager, ILogger logger ) { ConfigManager = configManager; ContentManager = contentManager; DeviceManager = deviceManager; InputManager = inputManager; RandomManager = randomManager; ResolutionManager = resolutionManager; ScreenManager = screenManager; TextManager = textManager; ThreadManager = threadManager; FileManager = fileManager; Logger = logger; }
#pragma warning restore 618 public void TestFixtureTearDown() { BossManager = null; BulletManager = null; CollisionManager = null; CommandManager = null; ConfigManager = null; ContentManager = null; ControlManager = null; DebugManager = null; DelayManager = null; DeviceManager = null; EnemyManager = null; EventManager = null; ExplosionManager = null; IconManager = null; ImageManager = null; InputManager = null; LevelManager = null; MoverManager = null; RandomManager = null; RenderManager = null; ResolutionManager = null; ScoreManager = null; ScreenManager = null; SoundManager = null; SpriteManager = null; StateManager = null; StopwatchManager = null; StorageManager = null; TextManager = null; ThreadManager = null; FileManager = null; Logger = null; }
public ShipManager(IShipFactory shipFactory, ICoordinateManager coordinateManager, IRandomManager randomManager, IOutputManager outputManager, IBoard board, ILog log) { _shipFactory = shipFactory ?? throw new ArgumentNullException(nameof(shipFactory)); _coordinateManager = coordinateManager ?? throw new ArgumentNullException(nameof(coordinateManager)); _randomManager = randomManager ?? throw new ArgumentNullException(nameof(randomManager)); _outputManager = outputManager ?? throw new ArgumentNullException(nameof(outputManager)); _board = board ?? throw new ArgumentNullException(nameof(board)); _log = log ?? throw new ArgumentNullException(nameof(log)); }
public SetupManager( IOutputManager outputManager, IInputManager inputManager, IGameConfig gameConfig, IRandomManager randomManager, IShipManager shipManager, ICoordinateManager coordinateManager, IShotManager shotManager, ILog log) { _outputManager = outputManager ?? throw new ArgumentNullException(nameof(outputManager)); _inputManager = inputManager ?? throw new ArgumentNullException(nameof(outputManager)); _gameConfig = gameConfig ?? throw new ArgumentNullException(nameof(gameConfig)); _randomManager = randomManager ?? throw new ArgumentNullException(nameof(gameConfig)); _shipManager = shipManager ?? throw new ArgumentNullException(nameof(shipManager)); _coordinateManager = coordinateManager ?? throw new ArgumentNullException(nameof(coordinateManager)); _shotManager = shotManager ?? throw new ArgumentNullException(nameof(shotManager)); _log = log ?? throw new ArgumentNullException(nameof(log)); }
public GameManager ( IButtonManager buttonManager, ICollisionManager collisionManager, IConfigManager configManager, IContentManager contentManager, IDeviceManager deviceManager, IImageManager imageManager, IInputManager inputManager, IQuestionManager questionManager, IRandomManager randomManager, IResolutionManager resolutionManager, IScoreManager scoreManager, IScreenManager screenManager, ISoundManager soundManager, ISpriteManager spriteManager, IStorageManager storageManager, ITextManager textManager, IThreadManager threadManager, IFileManager fileManager, ILogger logger ) { ButtonManager = buttonManager; CollisionManager = collisionManager; ConfigManager = configManager; ContentManager = contentManager; DeviceManager = deviceManager; ImageManager = imageManager; InputManager = inputManager; QuestionManager = questionManager; RandomManager = randomManager; ResolutionManager = resolutionManager; ScoreManager = scoreManager; ScreenManager = screenManager; SoundManager = soundManager; SpriteManager = spriteManager; StorageManager = storageManager; TextManager = textManager; ThreadManager = threadManager; FileManager = fileManager; Logger = logger; }
public GameManager ( IAnimationManager animationManager, ICollisionManager collisionManager, IConfigManager configManager, IContentManager contentManager, IEnemysManager enemysManager, IInputManager inputManager, ILevelManager levelManager, IPlayerManager playerManager, IPhysicsManager physicsManager, IRandomManager randomManager, IResolutionManager resolutionManager, IScreenManager screenManager, ISoundManager soundManager, IScrollManager scrollManager, IStateManager stateManager, ITileManager tileManager, IFileManager fileManager, ILogger logger ) { AnimationManager = animationManager; CollisionManager = collisionManager; ConfigManager = configManager; ContentManager = contentManager; EnemysManager = enemysManager; InputManager = inputManager; LevelManager = levelManager; PlayerManager = playerManager; PhysicsManager = physicsManager; RandomManager = randomManager; ResolutionManager = resolutionManager; SoundManager = soundManager; ScreenManager = screenManager; ScrollManager = scrollManager; StateManager = stateManager; TileManager = tileManager; FileManager = fileManager; Logger = logger; }
#pragma warning restore 618 public void TestFixtureTearDown() { AnimationManager = null; CollisionManager = null; ConfigManager = null; ContentManager = null; EnemysManager = null; InputManager = null; LevelManager = null; PlayerManager = null; PhysicsManager = null; RandomManager = null; ResolutionManager = null; ScreenManager = null; SoundManager = null; ScrollManager = null; StateManager = null; TileManager = null; FileManager = null; Logger = null; }
#pragma warning restore 618 public void TestFixtureSetUp() { AnimationManager = MockRepository.GenerateStub <IAnimationManager>(); CollisionManager = MockRepository.GenerateStub <ICollisionManager>(); ConfigManager = MockRepository.GenerateStub <IConfigManager>(); ContentManager = MockRepository.GenerateStub <IContentManager>(); EnemysManager = MockRepository.GenerateStub <IEnemysManager>(); InputManager = MockRepository.GenerateStub <IInputManager>(); LevelManager = MockRepository.GenerateStub <ILevelManager>(); PlayerManager = MockRepository.GenerateStub <IPlayerManager>(); PhysicsManager = MockRepository.GenerateStub <IPhysicsManager>(); RandomManager = MockRepository.GenerateStub <IRandomManager>(); ResolutionManager = MockRepository.GenerateStub <IResolutionManager>(); ScreenManager = MockRepository.GenerateStub <IScreenManager>(); SoundManager = MockRepository.GenerateStub <ISoundManager>(); ScrollManager = MockRepository.GenerateStub <IScrollManager>(); StateManager = MockRepository.GenerateStub <IStateManager>(); TileManager = MockRepository.GenerateStub <ITileManager>(); FileManager = MockRepository.GenerateStub <IFileManager>(); Logger = MockRepository.GenerateStub <ILogger>(); }
#pragma warning restore 618 public void TestFixtureTearDown() { ButtonManager = null; CollisionManager = null; ConfigManager = null; ContentManager = null; DeviceManager = null; ImageManager = null; InputManager = null; QuestionManager = null; RandomManager = null; ResolutionManager = null; ScoreManager = null; ScreenManager = null; SoundManager = null; SpriteManager = null; StorageManager = null; TextManager = null; ThreadManager = null; FileManager = null; Logger = null; }
#pragma warning restore 618 public void TestFixtureSetUp() { ButtonManager = MockRepository.GenerateStub <IButtonManager>(); CollisionManager = MockRepository.GenerateStub <ICollisionManager>(); ConfigManager = MockRepository.GenerateStub <IConfigManager>(); ContentManager = MockRepository.GenerateStub <IContentManager>(); DeviceManager = MockRepository.GenerateStub <IDeviceManager>(); ImageManager = MockRepository.GenerateStub <IImageManager>(); InputManager = MockRepository.GenerateStub <IInputManager>(); QuestionManager = MockRepository.GenerateStub <IQuestionManager>(); RandomManager = MockRepository.GenerateStub <IRandomManager>(); ResolutionManager = MockRepository.GenerateStub <IResolutionManager>(); ScoreManager = MockRepository.GenerateStub <IScoreManager>(); ScreenManager = MockRepository.GenerateStub <IScreenManager>(); SoundManager = MockRepository.GenerateStub <ISoundManager>(); SpriteManager = MockRepository.GenerateStub <ISpriteManager>(); StorageManager = MockRepository.GenerateStub <IStorageManager>(); TextManager = MockRepository.GenerateStub <ITextManager>(); ThreadManager = MockRepository.GenerateStub <IThreadManager>(); FileManager = MockRepository.GenerateStub <IFileManager>(); Logger = MockRepository.GenerateStub <ILogger>(); }
public void PlaceComputerShips(List <Ship> computerShips, IRandomManager randomManager, IShipManager shipManager, IPositionValidator positionValidator, Battlefield battlefield) { foreach (var ship in computerShips) { var randomPosition = randomManager.RandomPosition(battlefield.ColumnSize, battlefield.RowSize); var randomDirection = randomManager.RandomDirection(); var shipPositions = shipManager.WholeShipPositions(randomPosition, ship.Size, randomDirection); for (int i = 0; i < shipPositions.Count; i++) { while (positionValidator.IsValidPosition(shipPositions[i], battlefield.ColumnSize, battlefield.RowSize, computerShips) == false) { randomPosition = randomManager.RandomPosition(battlefield.ColumnSize, battlefield.RowSize); randomDirection = randomManager.RandomDirection(); shipPositions = shipManager.WholeShipPositions(randomPosition, ship.Size, randomDirection); i = -1; break; } } ship.Positions.AddRange(shipPositions); } }
public static void Main() { #region [on] 0. Instance var battlefield = new Battlefield(10, 10); positionParser = new PositionParser(); positionValidator = new PositionValidator(); randomManager = new RandomManager(); shipManager = new ShipManager(); shootManager = new ShootManager(); placeManager = new PlaceManager(); var battleBgm = new WindowsMediaPlayer(); var winnerBgm = new WindowsMediaPlayer(); #endregion #region [off] 1. Welcome Screen //GraphicManager.WelcomeScreen(); #endregion #region [on] 1.1. BGM SoundEffects.BattleBgmPlayer(battleBgm); #endregion #region [on] 2. Ships Topf // instance two players var player = new Player(); player.Positions = new List <Position>(); player.Hits = new List <Hit>(); player.Ships = new List <Ship>(); var computer = new Player(); computer.Positions = new List <Position>(); computer.Hits = new List <Hit>(); computer.Ships = new List <Ship>(); #endregion #region [on] 3. Place PlayerShips and ComputerShips // create player Ships player.Ships = InitializeShips(); // place player ships // [!!] placeManager.PlacePlayerShips(player.Ships, positionParser, positionValidator, shipManager,battlefield); placeManager.PlaceComputerShips(player.Ships, randomManager, shipManager, positionValidator, battlefield); // create ships for pc computer.Ships = InitializeShips(); // place pc ships placeManager.PlaceComputerShips(computer.Ships, randomManager, shipManager, positionValidator, battlefield); // Add positions into Instances foreach (var playerShip in player.Ships) { player.Positions.AddRange(playerShip.Positions); } var allPlayerShipsPositions = player.Positions; foreach (var computerShip in computer.Ships) { computer.Positions.AddRange(computerShip.Positions); } var allComputerShipsPositions = computer.Positions; #endregion #region + [on] display pcShips for Testing Console.Clear(); Console.WriteLine(); Console.WriteLine(); Console.WriteLine(" God Mode"); Console.WriteLine(" PC Ships:"); Console.WriteLine(); Console.WriteLine(GraphicManager.DisplayBattlefield(battlefield.ColumnSize, battlefield.RowSize, computer.Ships).PadRight(20)); Console.ReadKey(); SoundEffects.SetShipSoundPlayer(); #endregion #region + [off] display Win view for Testing //battleBgm.close(); //EndGameManager.WhoWin(player, computer, winnerBgm, shootManager); //EndGameManager.RestartGame(winnerBgm); #endregion #region [on] 4. Game begin view GraphicManager.GameStartView(player, computer, battlefield); #endregion #region [on] 5. Player || PC shots do // End the Game { do // Player == * ==> PC { var iShootPosition = ShootManager.PlayerShoot(player, computer, battlefield, positionParser, positionValidator); if (allComputerShipsPositions.Contains(iShootPosition)) // Hit Ship { computer.Hits.Add(new Hit(HitType.Ship, iShootPosition)); shootManager.HitShip(player, computer, iShootPosition, computer.Ships, battlefield); } else // Hit Water { computer.Hits.Add(new Hit(HitType.Water, iShootPosition)); shootManager.HitWater(player, computer, iShootPosition, battlefield, positionParser); } // Is all Player Ships Sunken if (shootManager.IsAllShipsSunken(computer.Ships)) { break; } } while (computer.Hits.Last().HitType == HitType.Ship); // one more time shoot do // PC == * ==> Player { // if All player ships have Sunked skip all those code if (shootManager.IsAllShipsSunken(computer.Ships)) { break; } var pcShootPosition = ShootManager.ComputerShoot(player, computer, battlefield, randomManager, positionParser); if (allPlayerShipsPositions.Contains(pcShootPosition)) // Hit Ship { player.Hits.Add(new Hit(HitType.Ship, pcShootPosition)); shootManager.HitShip(player, computer, pcShootPosition, player.Ships, battlefield); } else //Hit Water { player.Hits.Add(new Hit(HitType.Water, pcShootPosition)); shootManager.HitWater(player, computer, pcShootPosition, battlefield, positionParser); } // Check if all Player Ship Sunken if (shootManager.IsAllShipsSunken(player.Ships)) { break; } } while (player.Hits.Last().HitType == HitType.Ship); // one more time shoot } while (shootManager.IsAllShipsSunken(computer.Ships) == false && shootManager.IsAllShipsSunken(player.Ships) == false); // End the game #endregion #region [on] 6. Game End View battleBgm.close(); EndGameManager.WhoWin(player, computer, winnerBgm, shootManager); EndGameManager.RestartGame(winnerBgm); #endregion }
public CoordinateManager(IRandomManager randomManager, ILog log) { _randomManager = randomManager ?? throw new ArgumentNullException(nameof(randomManager)); _log = log ?? throw new ArgumentNullException(nameof(log)); }
public GameManager ( IBossManager bossManager, IBulletManager bulletManager, ICollisionManager collisionManager, ICommandManager commandManager, IConfigManager configManager, IContentManager contentManager, IControlManager controlManager, IDebugManager debugManager, IDelayManager delayManager, IDeviceManager deviceManager, IEnemyManager enemyManager, IEventManager eventManager, IExplosionManager explosionManager, IIconManager iconManager, IImageManager imageManager, IInputManager inputManager, ILevelManager levelManager, IMoverManager moverManager, IRandomManager randomManager, IRenderManager renderManager, IResolutionManager resolutionManager, IScoreManager scoreManager, IScreenManager screenManager, ISoundManager soundManager, ISpriteManager spriteManager, IStateManager stateManager, IStopwatchManager stopwatchManager, IStorageManager storageManager, ITextManager textManager, IThreadManager threadManager, IFileManager fileManager, ILogger logger ) { BossManager = bossManager; BulletManager = bulletManager; CollisionManager = collisionManager; CommandManager = commandManager; ConfigManager = configManager; ContentManager = contentManager; ControlManager = controlManager; DebugManager = debugManager; DelayManager = delayManager; DeviceManager = deviceManager; EnemyManager = enemyManager; EventManager = eventManager; ExplosionManager = explosionManager; ImageManager = imageManager; IconManager = iconManager; InputManager = inputManager; LevelManager = levelManager; MoverManager = moverManager; RandomManager = randomManager; RenderManager = renderManager; ResolutionManager = resolutionManager; ScoreManager = scoreManager; ScreenManager = screenManager; SoundManager = soundManager; SpriteManager = spriteManager; StateManager = stateManager; StopwatchManager = stopwatchManager; StorageManager = storageManager; TextManager = textManager; ThreadManager = threadManager; FileManager = fileManager; Logger = logger; }
public static Position ComputerShoot(Player player, Player computer, Battlefield battlefield, IRandomManager randomManager, IPositionParser positionParser) { Console.Clear(); GraphicManager.DisplayBattleView(player, computer, battlefield); // [!!!] should be better Position pcShootPosition = randomManager.RandomPosition(battlefield.ColumnSize, battlefield.RowSize); Console.WriteLine(" \" PC Shoot \" "); Console.WriteLine(); Console.Write(" THINKING"); // imitate Thinking Thread.Sleep(1000); Console.Write("... "); Thread.Sleep(500); Console.Write("[ {0} ]", positionParser.BackParser(pcShootPosition)); Thread.Sleep(500); Console.Write(" ..."); Thread.Sleep(500); return(pcShootPosition); }