Пример #1
0
        private static MindField GetMindField(ITileGenerator itg, Point startingPoint)
        {
            var mf = new MindField(itg);

            mf.SetStartPosition(startingPoint);
            return(mf);
        }
Пример #2
0
 public MindField(ITileGenerator tileGenerator)
 {
     _tileGenerator         = tileGenerator;
     _movers                = new IMover[] { new NorthMover(), new SouthMover(), new EastMover(), new WestMover(), };
     TurtlesCurrentPosition = new Point(0, 0);
     Tiles = _tileGenerator.GenerateTiles();
 }
Пример #3
0
 public void ScheduleLoadTile(ITileGenerator tileGenerator, BackgroundWorker backgroundWorker)
 {
     if (State == TileState.Pending)
     {
         this.tileGenerator = tileGenerator;
         State = TileState.Loading;
         backgroundWorker.DoWork += LoadTileInBackground;
     }
 }
Пример #4
0
    public void GenerateMap()
    {
        tileGenerator = new TileGenerate(mapSize, transform, typeOftiles, scale);
        tileMap       = tileGenerator.Generate();

        settlementGenerotor = new SettlementGenerator(mapSize, transform, townLocalization, tileMap, scale);
        settlementMap       = settlementGenerotor.Generate();

        routeGenerator = new RouteGenerator(settlementMap, transform, routeLocalization, scale);
        routeGenerator.Generate();
    }
Пример #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 Construct(ITileGenerator a_refTileGenrator)
 {
     m_refTileGenrator = a_refTileGenrator;
 }
Пример #7
0
 public AIModule(ITileGenerator tileGenerator)
 {
     this._tileGenerator = tileGenerator;
     this.m_rand = new Random();
 }
Пример #8
0
 public Game(IBoard board, ITileGenerator generator)
 {
     this.board    = board ?? throw new ArgumentNullException();
     tileGenerator = generator ?? throw new ArgumentNullException();
     Score         = 0;
 }
Пример #9
0
 private static IMindField GetMindField(GameSettings gs, ITileGenerator tileGenerator)
 {
     return(new MindField(tileGenerator));
 }