Beispiel #1
0
        public DomainFacade(IStorageProvider storageProvider, string baseUri, ILanguageContainerService languageContainerService)
        {
            _storageProvider         = storageProvider;
            LanguageContainerService = languageContainerService;
            TryRestoreLanguageName();

            _grid             = new Grid();
            _toolManager      = new ToolManager();
            _historyManager   = new HistoryManager();
            _hintsProvider    = new HintsProvider();
            _storageManager   = new StorageManager(storageProvider);
            _shareManager     = new ShareManager(baseUri);
            _pasteManager     = new PasteManager();
            _solver           = new BruteForceSolver();
            _gridGenerator    = new PredefinedGridGenerator();
            _colorManager     = new ColorManager();
            _gameTimerManager = new GameTimerManager();

            _modalStateManager = new();
            _modalStateManager.OnModalStateChanged += HandleModalStateChanged;
            SetModalState(ModalState.Loading);

            Load();
            StartAutoSave(TimeSpan.FromSeconds(2));
        }
Beispiel #2
0
        public BattleshipOneSideGameEngine(IGridGenerator gridGenerator)
        {
            _gridGenerator = gridGenerator ?? throw new ArgumentNullException(nameof(gridGenerator));
            Grid           = _gridGenerator.Generate(forPlayer: false);

            Status = GameStatus.PlayerMovement;
        }
Beispiel #3
0
        public BattleshipGameEngine(IGridGenerator gridGenerator, ICpuMovementLogic cpuMovementLogic)
        {
            _gridGenerator    = gridGenerator ?? throw new ArgumentNullException(nameof(gridGenerator));
            _cpuMovementLogic = cpuMovementLogic ?? throw new ArgumentNullException(nameof(cpuMovementLogic));

            CpuGrid    = _gridGenerator.Generate(forPlayer: false);
            PlayerGrid = _gridGenerator.Generate(forPlayer: true);

            Status = new Random().Next(0, 2) == 0 ? GameStatus.PlayerMovement : GameStatus.CpuMovement;
        }
        public MineSweeper(int size, IGridGenerator gridGenerator)
        {
            if (!size.IsInRangeInclusive(GameConfiguration.MinAllowedGridSize, GameConfiguration.MaxAllowedGridSize))
            {
                throw new ArgumentException(
                          $"Size of the game plan has to be between {GameConfiguration.MinAllowedGridSize} " +
                          $"and {GameConfiguration.MaxAllowedGridSize}!");
            }

            this.gridGenerator = gridGenerator;

            InitializeGrid(size);
        }
Beispiel #5
0
 public Game(
     IGridGenerator gridGenerator,
     GridController gridController,
     IUnitSpawner charactersSpawner,
     IUnitSpawner enemiesSpawner,
     ITurnDealer turnDealer,
     GameInitialStateConfig initialStateConfig,
     ICameraPositioner cameraPositioner)
 {
     _gridGenerator      = gridGenerator;
     _gridController     = gridController;
     _charactersSpawner  = charactersSpawner;
     _enemiesSpawner     = enemiesSpawner;
     _turnDealer         = turnDealer;
     _initialStateConfig = initialStateConfig;
     _cameraPositioner   = cameraPositioner;
 }
Beispiel #6
0
        public Program()
        {
            // Game play objects
            List <IShip> ships = new List <IShip> {
                new BattleShip(1), new Destroyer(2), new Destroyer(3)
            };

            playerStats = new PlayerStats();

            // Not using a IoC framework (manual singletons), so it will just get new up a instance here,
            // and injected directly. Once we go out of scope here, allow the GC to clean up behind us
            ISegmentation   segmentation   = Segmentation.Instance();
            IShipRandomiser shipRandomiser = ShipRandomiser.Instance();

            consoleHelper = ConsoleHelper.Instance(playerStats);

            gridGenerator = new GridGenerator(segmentation, shipRandomiser, consoleHelper, ships);

            shipCounter = ships.Count;
            message     = consoleHelper.StartGameMessage;
        }
 public void Setup()
 {
     gridGenerator = new GridGenerator();
 }
Beispiel #8
0
 public BattleshipController()
 {
     this.gridGenerator = GridGenerator.Instance();
     this.gamePlayer    = GamePlayer.Instance();
 }
 public GeneratedGrid(IGridGenerator <T> generator)
 {
     tree           = new();
     this.generator = generator;
 }
Beispiel #10
0
 public GridGeneratorTests()
 {
     shipRandomiser = ShipRandomiser.Instance();
     gridGenerator  = GridGenerator.Instance();
 }
Beispiel #11
0
 public SearchService(AppConfig appConfig, IGridGenerator gridGenerator)
 {
     _appConfig     = appConfig;
     _gridGenerator = gridGenerator;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 /// <param name="implementation">The implementation.</param>
 public GridGeneratorContainer(IGridGenerator <T, TV> implementation)
 {
     this.Implementation = implementation;
 }