Пример #1
0
 private void Setup(int setupNumber)
 {
     cpFactory            = new KingCheckMatedTestPieceFactory(setupNumber);
     chessBoard           = new StandardChessBoard(cpFactory);
     game                 = new Game(chessBoard, new StandardChessTimer());
     checkedKingCondition = new CheckedKingCondition(game);
 }
Пример #2
0
        public static Engine GetEngine(
            IEnumerable <IFighterStats> fighters,
            IBattlefield battlefield,
            IBounds bounds,
            ICollection <IEngineFeature> features,
            IMoveOrder moveOrder,
            IFighterPositionGenerator positionGenerator,
            IWinCondition winCondition,
            IStaleCondition staleCondition,
            int actionsPerRound)
        {
            return(new Engine(
                       cfg =>
            {
                cfg.ActionsPerRound = actionsPerRound;
                cfg.Battlefield = battlefield;
                cfg.Bounds = bounds;
                cfg.Features = features;
                cfg.MoveOrder = moveOrder;
                cfg.PositionGenerator = positionGenerator;
                cfg.WinCondition = winCondition;
                cfg.StaleCondition = staleCondition;

                return cfg;
            }, fighters));
        }
Пример #3
0
 public GameController(IWinCondition winner, IPlayer player1, IPlayer player2, ITicTacToeIO gameIO)
 {
     _winner    = winner;
     _player1   = player1;
     _player2   = player2;
     _gameIO    = gameIO;
     _gameBoard = new Board();
 }
Пример #4
0
 public Game(IChessBoard ChessBoard       = null, IChessTimer ChessTimer       = null
             , IWinCondition WinCondition = null, IEndGameResult EndGameResult = null)
 {
     chessBoard    = ChessBoard;
     chessTimer    = ChessTimer;
     winCondition  = WinCondition;
     endGameResult = EndGameResult;
 }
Пример #5
0
    // Vygeneruje mapu, jako parametry přijíma Maze Settings a IWinCondition, jinými slovy pravidla, jak se má mapa generovat, a podmínku pro splnění úrovně
    public PathfindingNode[] GenerateMaze(MazeSettingsSO mazeSettings, IWinCondition winCondition, out int nodeCount)
    {
        _mazeSettings     = mazeSettings;
        _winCondition     = winCondition;
        _generationsRules = _winCondition.SpecialGenerationRules();

        // Vygeneruje buňky, pokud jich vygeneruje málo může generaci opakovat
        ICellGenerator cellGenerator = GetComponent <ICellGenerator>();

        _startPoint = new Vector3(_mazeSettings.centerPoint.x - ((float)_mazeSettings.width / 2f) * _mazeSettings.distanceBetweenCells, _mazeSettings.centerPoint.y, _mazeSettings.centerPoint.z - ((float)_mazeSettings.length / 2f) * _mazeSettings.distanceBetweenCells); // RLpos

        int generationCounter = 0;

        while (generationCounter < _mazeSettings.triesToGenerateMaze)
        {
            _cellData = cellGenerator.GenerateCells(_mazeSettings, _startPoint);
            if ((float)_cellData.CellCount / (float)(_mazeSettings.length * _mazeSettings.width) >= _mazeSettings.minCellPercentage)
            {
                break;
            }
            generationCounter++;
        }

        // Rozdělí buňky na podbuňky
        ISubcellGenerator subcellGenerator = GetComponent <ISubcellGenerator>();

        _subcellData = subcellGenerator.GenerateSubcells(_mazeSettings, _cellData, _startPoint, 1);

        // Pokud je u podmínky k zvítězení pravidlo na vedlejší místnost, tak ji vygeneruje
        if (_generationsRules.Contains(GenerationRule.OuterRoom))
        {
            CreateOuterRoom();
        }

        // Vytvoří na mapě části místností pro všechny podbuňky
        ITileGenerator tileGenerator = GetComponent <TileGenerator>();

        tileGenerator.GenerateTiles(_subcellData, _generationsRules.Contains(GenerationRule.OuterRoom) ? (_subcellData.EmptySpotInArray - 1) : _subcellData.EmptySpotInArray);

        // Vytvoří vrcholy pro hledání cesty
        PathfindingNodeGenerator pathfindingNodeGenerator = GetComponent <PathfindingNodeGenerator>();

        _pathfindingNodes = pathfindingNodeGenerator.GenerateNodes(_mazeSettings, _subcellData);

        GetComponent <Spawner>().SpawnReturnPortal(_subcellData.SpawnPoint);
        GameManager.Instance.Player.transform.position = new Vector3(_subcellData.SpawnPoint.x, _subcellData.SpawnPoint.y + _playerYOffset, _subcellData.SpawnPoint.z);

        SpawnEnemies();

        nodeCount = _pathfindingNodes.Length;
        return(_pathfindingNodes);
    }
Пример #6
0
 private void Setup()
 {
     cpFactory            = new KingsToKillChessPieceFactory();
     chessBoard           = new StandardChessBoard(cpFactory);
     deadKingWinCondition = new DeadKingCondition(chessBoard.ChessPiecesOnBoard);
 }
Пример #7
0
        public Player CreatePlayer(Position startPosition, Direction initialDirection)
        {
            var winConditions = new IWinCondition[] { new PlayerReachesOtherSide() };

            return(new Player(startPosition, new GtkPlayerRenderer(_area), initialDirection, GameConfig.PLAYER_SPEED, _playerKeyMapper, winConditions));
        }
Пример #8
0
 public GameEngine(IStrategy player1Strategy, IStrategy player2Strategy, IWinCondition winCondition)
 {
     _player1Strategy = player1Strategy;
     _player2Strategy = player2Strategy;
     _winCondition    = winCondition;
 }
Пример #9
0
 private void DisplayWonMessage(IWinCondition item)
 {
     print($"Won:  {item.Reason()}");
     _gameWonScreen.SetActive(true);
 }