internal TileMatrix(int sizeX, int sizeY, OwnerTypeEnum ownerTypeEnum, ITileFactory tileFactory)
 {
     OwnerType = ownerTypeEnum;
     SizeX     = sizeX;
     SizeY     = sizeY;
     Fill(tileFactory);
 }
Example #2
0
 public TextFileTileRepository(
     ISettings settings,
     FileUtility fileUtility,
     ITileFactory tileFactory) : base(settings, fileUtility)
 {
     _tileFactory = tileFactory;
 }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SectorMapLoader"/> class.
        /// </summary>
        /// <param name="logger">A reference to the logger instance in use.</param>
        /// <param name="itemFactory">A reference to the item factory.</param>
        /// <param name="tileFactory">A reference to the tile factory.</param>
        /// <param name="sectorMapLoaderOptions">The options for this map loader.</param>
        public SectorMapLoader(
            ILogger <SectorMapLoader> logger,
            IItemFactory itemFactory,
            ITileFactory tileFactory,
            IOptions <SectorMapLoaderOptions> sectorMapLoaderOptions)
        {
            logger.ThrowIfNull(nameof(logger));
            itemFactory.ThrowIfNull(nameof(itemFactory));
            tileFactory.ThrowIfNull(nameof(tileFactory));
            sectorMapLoaderOptions.ThrowIfNull(nameof(sectorMapLoaderOptions));

            DataAnnotationsValidator.ValidateObjectRecursive(sectorMapLoaderOptions.Value);

            this.mapDirInfo = new DirectoryInfo(sectorMapLoaderOptions.Value.LiveMapDirectory);

            if (!this.mapDirInfo.Exists)
            {
                throw new ApplicationException($"The map directory '{sectorMapLoaderOptions.Value.LiveMapDirectory}' could not be found.");
            }

            this.logger      = logger;
            this.itemFactory = itemFactory;
            this.tileFactory = tileFactory;

            this.totalTileCount   = 1;
            this.totalLoadedCount = default;

            this.loadLock = new object();

            this.sectorsLengthX = 1 + SectorXMax - SectorXMin;
            this.sectorsLengthY = 1 + SectorYMax - SectorYMin;
            this.sectorsLengthZ = 1 + SectorZMax - SectorZMin;

            this.sectorsLoaded = new bool[this.sectorsLengthX, this.sectorsLengthY, this.sectorsLengthZ];
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GrassOnlyDummyMapLoader"/> class.
        /// </summary>
        /// <param name="itemFactory">A reference to the item factory.</param>
        /// <param name="tileFactory">A reference to the tile factory.</param>
        public GrassOnlyDummyMapLoader(IItemFactory itemFactory, ITileFactory tileFactory)
        {
            itemFactory.ThrowIfNull(nameof(itemFactory));
            tileFactory.ThrowIfNull(nameof(tileFactory));

            this.itemFactory = itemFactory;
            this.tileFactory = tileFactory;
        }
Example #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GrassOnlyDummyMapLoader"/> class.
        /// </summary>
        /// <param name="itemFactory">A reference to the item factory.</param>
        /// <param name="tileFactory">A reference to the tile factory.</param>
        public GrassOnlyDummyMapLoader(IItemFactory itemFactory, ITileFactory tileFactory)
        {
            itemFactory.ThrowIfNull(nameof(itemFactory));
            tileFactory.ThrowIfNull(nameof(tileFactory));

            this.ItemFactory = itemFactory;
            this.TileFactory = tileFactory;

            this.tilesAndLocations = new ConcurrentDictionary <Location, ITile>();
        }
 private void Fill(ITileFactory tileFactory)
 {
     for (int x = 0; x < SizeX; x++)
     {
         for (int y = 0; y < SizeY; y++)
         {
             _gameTiles.Add(tileFactory.Create(new Coordinate(x, y), OwnerType));
         }
     }
 }
Example #7
0
        public void TestTileFactory()
        {
            ITileFactory f = new ITileFactory();

            Assert.IsTrue(f.makeTile(1) is TileDesert);
            Assert.IsTrue(f.makeTile(2) is TileForest);
            Assert.IsTrue(f.makeTile(3) is TileMountain);
            Assert.IsTrue(f.makeTile(4) is TilePlain);
            Assert.IsTrue(f.makeTile(5) is TileMarsh);
        }
Example #8
0
 public Engine(IMap map, IMapFactory mapFactory, ITileFactory tileFactory)
 {
     this.graphics              = new GraphicsDeviceManager(this);
     this.collisionHandler      = new NewCollisionHandler();
     this.monsters              = new MonsterData();
     this.players               = new PlayerData();
     this.Content.RootDirectory = "Content";
     this.map         = map;
     this.MapFactory  = mapFactory;
     this.TileFactory = tileFactory;
 }
Example #9
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Map"/> class.
    /// </summary>
    /// <param name='tileFactory'>
    /// Tile factory.
    /// </param>
    /// <param name='m'>
    /// M is the length of 1st dimension of the map.
    /// </param>
    /// <param name='n'>
    /// N is the length of 2nd dimemsion of the map.
    /// </param>
    public Map(List<ITile> tiles, ITileFactory tileFactory, ITileLoadingStrategy loadingStrategy, TileView prefab, int m, int n)
    {
        this.prefab = prefab;
        this.factory = tileFactory;
        this.loadingStrategy = loadingStrategy;
        this.size = new Vec2 (m, n);
        this.root = new GameObject ("Map");
        this.tileSet = new Dictionary<Vec2, TileView> (m * n);
        this.visibleTiles = new List<ITile> (m * n);

        LoadCachedTiles (tiles);
    }
Example #10
0
File: Map.cs Project: hnjm/tilemap
    /// <summary>
    /// Initializes a new instance of the <see cref="Map"/> class.
    /// </summary>
    /// <param name='tileFactory'>
    /// Tile factory.
    /// </param>
    /// <param name='m'>
    /// M is the length of 1st dimension of the map.
    /// </param>
    /// <param name='n'>
    /// N is the length of 2nd dimemsion of the map.
    /// </param>
    public Map(List <ITile> tiles, ITileFactory tileFactory, ITileLoadingStrategy loadingStrategy, TileView prefab, int m, int n)
    {
        this.prefab          = prefab;
        this.factory         = tileFactory;
        this.loadingStrategy = loadingStrategy;
        this.size            = new Vec2(m, n);
        this.root            = new GameObject("Map");
        this.tileSet         = new Dictionary <Vec2, TileView> (m * n);
        this.visibleTiles    = new List <ITile> (m * n);

        LoadCachedTiles(tiles);
    }
Example #11
0
        private void create_grid(MinefieldSize minefield_size, ITileFactory tile_factory, Guid game_id)
        {
            _tiles = new List<ITile>();

            var row_count = 0;
            while (row_count < minefield_size.rows)
            {
                var column_count = 0;
                while (column_count < minefield_size.columns)
                {
                    _tiles.Add(tile_factory.create_for(new Coordinate(row_count, column_count),game_id));
                    column_count++;
                }
                row_count++;
            }
        }
Example #12
0
        private void create_grid(MinefieldSize minefield_size, ITileFactory tile_factory, Guid game_id)
        {
            _tiles = new List <ITile>();

            var row_count = 0;

            while (row_count < minefield_size.rows)
            {
                var column_count = 0;
                while (column_count < minefield_size.columns)
                {
                    _tiles.Add(tile_factory.create_for(new Coordinate(row_count, column_count), game_id));
                    column_count++;
                }
                row_count++;
            }
        }
Example #13
0
        public Tile MakeTile(ETileType tileType, EDirection direction = EDirection.NONE)
        {
            switch (tileType)
            {
            case ETileType.ADDTILE: return(AddTileFactory.Instance().MakeTile(direction));

            case ETileType.ITILE: return(ITileFactory.Instance().MakeTile(direction));

            case ETileType.LTILE: return(LTileFactory.Instance().MakeTile(direction));

            case ETileType.SQUARETILE: return(SquareTileFactory.Instance().MakeTile(direction));

            case ETileType.ZTILE: return(ZTileFactory.Instance().MakeTile(direction));

            default: return(null);
            }
        }
Example #14
0
        public Engine(IFovStrategy fovStrategy, ITileFactory tileFactory, World world, IInputHandler input, ILogController gameLog, ConsoleWindow console)
        {
            FovStrategy = fovStrategy;
            TileFactory = tileFactory;
            World = world;
            InputHandler = input;
            Console = console;

            if (ActorControllers == null)
            {
                ActorControllers = new List<IController>();
            }

            if (FurnitureControllers == null)
            {
                FurnitureControllers = new List<IController>();
            }

            GameLogController = gameLog;
        }
Example #15
0
        public TileFetcher(TileSource source, MemoryCache <T> memoryCache, ITileFactory <T> tileFactory)
        {
            if (source == null)
            {
                throw new ArgumentException("TileProvider can not be null");
            }
            this.tileSource = source;

            if (memoryCache == null)
            {
                throw new ArgumentException("MemoryCache can not be null");
            }
            this.memoryCache = memoryCache;

            if (tileFactory == null)
            {
                throw new ArgumentException("ITileFactory can not be null");
            }
            this.tileFactory = tileFactory;
        }
        public ITile[,] Generate(ITileFactory _tileGenerator, BoxCollider _planeCollider, int _width = 100, int _height = 100)
        {
            width  = _width;
            height = _height;

            tiles = new ITile[width, height];
            _planeCollider.transform.position += new Vector3(width / 2, height / 2, 0);
            _planeCollider.size = new Vector3(width, height, _planeCollider.size.z);

            for (int y = 0; y < _height; y++)
            {
                for (int x = 0; x < _width; x++)
                {
                    tiles[x, y] = _tileGenerator.Create(x, y);
                }
            }

            FillRandomTiles(10);

            return(tiles);
        }
Example #17
0
        public void Initialize(IMap map, string source, ITileFactory tileFactory)
        {
            StreamReader reader = new StreamReader(source);

            using (reader)
            {
                string[] line = reader.ReadLine().Split();
                int      rows = int.Parse(line[0]);
                int      cols = int.Parse(line[1]);

                map.Tiles = new ITile[rows, cols];


                string getLine     = reader.ReadLine();
                int    currentLine = 0;
                while (getLine != null)
                {
                    for (int i = 0; i < getLine.Length; i++)
                    {
                        switch (getLine[i])
                        {
                        case 'G':
                            var newTile = tileFactory.Make("grass_tile", true, new Vector2(i * map.TileWidth, currentLine * map.TileHeight));
                            map.Tiles[currentLine, i] = newTile;
                            map.AddTile(newTile);
                            continue;

                        case 'R':
                            var newTile2 = tileFactory.Make("rock_tile", false, new Vector2(i * map.TileWidth, currentLine * map.TileHeight));
                            map.Tiles[currentLine, i] = newTile2;
                            map.AddTile(newTile2);
                            continue;
                        }
                    }

                    getLine = reader.ReadLine();
                    currentLine++;
                }
            }
        }
Example #18
0
 public RegisterTileFactorySystem(Contexts contexts, ITileFactory tileFactory)
 {
     _contexts    = contexts;
     _tileFactory = tileFactory;
 }
Example #19
0
 public GridFactory(ITileFactory tile_factory)
 {
     _tile_factory = tile_factory;
 }
Example #20
0
 public Grid(ITileFactory tile_factory, MinefieldSize minefield_size, Guid game_id)
 {
     create_grid(minefield_size, tile_factory, game_id);
 }
Example #21
0
 public Board(GameSettings gameSettings, TileCallbacks tileCallbacks)
 {
     GameSettings = gameSettings;
     _board       = new ITile[gameSettings.Columns, gameSettings.Rows];
     _tileFactory = new TileFactory(gameSettings, tileCallbacks, this);
 }
 public AppManager(IMatrixFactory matrixFactory, ITileFactory tileFactory)
 {
     _matrixFactory = matrixFactory;
     _tileFactory   = tileFactory;
     Initialize();
 }
Example #23
0
 public TileService(ITileFactory tileFactory, IAdaptiveTileFactory adaptiveTileFactory)
 {
     _tileFactory         = tileFactory;
     _adaptiveTileFactory = adaptiveTileFactory;
 }
Example #24
0
 public GameFactories(ITileFactory tile)
 {
     Tile = tile;
 }
Example #25
0
 public GridFactory(ITileFactory tile_factory)
 {
     _tile_factory = tile_factory;
 }
Example #26
0
 public static LevelMap LoadMap(ITileFactory tileFactory)
 {
     var levelMap = new LevelMap() { Name = "Test Map", Tiles = tileFactory.GetTiles()};
     levelMap.Id = Guid.NewGuid();
     return levelMap;
 }
Example #27
0
 public TileStorage(ITileFactory factory)
 {
     this.factory = factory;
 }
 public TileLayer(TileSource source, ITileFactory <T> tileFactory)
 {
     this.schema              = source.Schema;
     tileFetcher              = new TileFetcher <T>(source, memoryCache, tileFactory);
     tileFetcher.DataChanged += new DataChangedEventHandler(tileFetcher_DataChanged);
 }
 //TODO: Create interface IMatrix
 public TileMatrix Create(int sizeX, int sizeY, OwnerTypeEnum ownerTypeEnum, ITileFactory tileFactory)
 {
     return(new TileMatrix(sizeX, sizeY, ownerTypeEnum, tileFactory));
 }
Example #30
0
 public Grid(ITileFactory tile_factory, MinefieldSize minefield_size, Guid game_id)
 {
     create_grid(minefield_size, tile_factory, game_id);
 }
Example #31
0
 public TileStorage(ITileFactory factory)
 {
     this.factory = factory;
 }
Example #32
0
 public void Initialize(IMapFactory mapFactory, ITileFactory tileFactory)
 {
     mapFactory.Initialize(this, this.Src, tileFactory);
 }