Beispiel #1
0
 public SpaceGrid(
     SpaceGridNavigator navigator,
     SpaceGridTileCache spaceGridTileCache)
 {
     _navigator          = navigator;
     _spaceGridTileCache = spaceGridTileCache;
 }
Beispiel #2
0
        public static (IGame, State) Generate(GameConfiguration conf)
        {
            var playerRating = ThreadLocalRandom.Current().Next(conf.MinRating, conf.MaxRating);

            var spaceGridTileCache = new SpaceGridTileCache(
                Mathf.CeilToInt(SystemInfo.processorCount / 2F),
                new SpaceTileIO(Application.persistentDataPath),
                SpaceTileFactory.Construct(playerRating, conf)
                );

            spaceGridTileCache.Init();

            var gridNavigator = new SpaceGridNavigator(conf.TileSize);

            var visibilityManager = new SpaceGridTilesVisibilityManager(
                conf.TileSize,
                gridNavigator,
                spaceGridTileCache
                );

            var playerPosition = new Position(0, 0);

            visibilityManager.Init(gridNavigator.FindTile(playerPosition));

            var game = new Game(
                playerRating,
                new SpaceGrid(gridNavigator, spaceGridTileCache),
                visibilityManager,
                conf
                );

            var initialState = game.Init(playerPosition);

            return(game, initialState);
        }