public static void InitializeCustomCells(int width, int height, EmberCell[] cells)
        {
            Grid = new EmberGrid(width, height, cells);

            // After map is created, we calibrate the light engine
            Grid.CalibrateLightEngine();
        }
        public static void InitializeBlueprint <T>() where T : Blueprint <EmberCell>, new()
        {
            Grid = new EmberGrid(new T());

            // After map is created, we calibrate the light engine
            Grid.CalibrateLightEngine();
        }
        public static void InitializeCustomGrid(EmberGrid grid)
        {
            Grid = grid;

            // After map is created, we calibrate the light engine
            Grid.CalibrateLightEngine();
        }
Exemple #4
0
        private static void SetMapArea(int gridSizeX, int gridSizeY)
        {
            var cells = new EmberCell[gridSizeX * gridSizeY];

            for (int x = 0; x < gridSizeX; x++)
            {
                for (int y = 0; y < gridSizeY; y++)
                {
                    cells[y * gridSizeX + x] = new EmberCell(new Point(x, y), '.', Color.Green);
                }
            }
            Grid = new EmberGrid(gridSizeX, gridSizeY, cells);
            Grid.RenderObject(Map);
        }
        public void CellsAreExplored_WhenEntityIsNear_LightSource()
        {
            // Initialize a blueprint for testing
            _grid = BaseGrid.Create(new BaseBlueprint());
            GridManager.InitializeCustomGrid(_grid);

            // Create entity and calculate fov + draw it
            var entity = EntityManager.Create <BaseEntity>(_grid.GetCell(a => a.LightProperties.Brightness > 0f && a.CellProperties.Walkable).Position, _grid);

            EntityManager.RecalculatFieldOfView(entity);
            GridManager.Grid.DrawFieldOfView(entity);

            var cellsWithBrightness = _grid.GetCells(a => a.LightProperties.Brightness > 0f).ToList();

            foreach (var cell in cellsWithBrightness)
            {
                Assert.IsTrue(cell.CellProperties.IsExplored);
            }
        }
        public void CellsAreNotExplored_EvenWhen_AreaHasLights()
        {
            // Initialize a blueprint for testing
            _grid = BaseGrid.Create(new BaseBlueprint());
            GridManager.InitializeCustomGrid(_grid);

            // Create entity and calculate fov + draw it
            var entity = EntityManager.Create <BaseEntity>(new Point(1, 1), _grid);

            EntityManager.RecalculatFieldOfView(entity);
            GridManager.Grid.DrawFieldOfView(entity);

            var cellsWithBrightness = _grid.GetCells(a => a.LightProperties.Brightness > 0f).ToList();

            foreach (var cell in cellsWithBrightness)
            {
                Assert.IsFalse(cell.CellProperties.IsExplored);
            }
        }
Exemple #7
0
        public static void InitializeBlueprint <T>(bool saveGridData) where T : Blueprint <EmberCell>, new()
        {
            if (!saveGridData)
            {
                Grid = new EmberGrid(new T());
                Grid.CalibrateLightEngine();
                return;
            }

            if (_blueprintGridCache.TryGetValue(typeof(T), out EmberGrid grid))
            {
                Grid = grid;
            }
            else
            {
                Grid = new EmberGrid(new T());
                Grid.CalibrateLightEngine();

                _blueprintGridCache.Add(typeof(T), Grid);
            }
        }
Exemple #8
0
        public static void InitializeBlueprint <T>(Blueprint <T> blueprint, bool saveGridData) where T : EmberCell, new()
        {
            if (!saveGridData)
            {
                Grid = new EmberGrid(blueprint.GridSizeX, blueprint.GridSizeY, blueprint.GetCells(), blueprint as Blueprint <EmberCell>);
                Grid.CalibrateLightEngine();
                return;
            }

            if (_blueprintGridCache.TryGetValue(blueprint.GetType(), out EmberGrid grid))
            {
                Grid = grid;
            }
            else
            {
                Grid = new EmberGrid(blueprint.GridSizeX, blueprint.GridSizeY, blueprint.GetCells(), blueprint as Blueprint <EmberCell>);
                Grid.CalibrateLightEngine();

                _blueprintGridCache.Add(blueprint.GetType(), Grid);
            }
        }
 protected virtual void Setup()
 {
     _grid = BaseGrid.Create(20, 20);
     GridManager.InitializeCustomGrid(_grid);
 }
 protected override void Setup()
 {
     // Setup a grid based on a blueprint
     _grid = new EmberGrid(new GroundFloorBlueprint());
     GridManager.InitializeCustomGrid(_grid);
 }
Exemple #11
0
 protected virtual void Setup()
 {
     _grid = EmberGridTests.BuildCustomGrid(20, 20);
     GridManager.InitializeCustomGrid(_grid);
 }
 protected override void Setup()
 {
     // Setup a grid based on a blueprint
     _grid = new EmberGrid(new GroundFloorBlueprint());
 }
Exemple #13
0
 protected override void Setup()
 {
     // Setup a grid based on a blueprint
     _grid = new EmberGrid(new HouseBlueprint());
 }
Exemple #14
0
 protected virtual void Setup()
 {
     _grid = BuildCustomGrid(Constants.Map.Width, Constants.Map.Height);
 }
 /// <summary>
 /// Returns a new entity or null, if the position is already taken.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="position"></param>
 /// <param name="grid">Custom grid, for tests</param>
 /// <returns></returns>
 public static T Create <T>(Point position, EmberGrid grid = null) where T : IEntity
 {
     if (EntityExistsAt(position))
     {
         return(default);
 protected virtual void Setup()
 {
     _grid = BuildCustomGrid(10, 10);
     GridManager.InitializeCustomGrid(_grid);
 }
Exemple #17
0
 public void SetUp()
 {
     _grid = EmberGridTests.BuildCustomGrid(10, 10);
 }
Exemple #18
0
 public static void InitializeCustomGrid(EmberGrid grid)
 {
     Grid = grid;
 }
Exemple #19
0
 public static void InitializeCustomCells(int width, int height, EmberCell[] cells)
 {
     Grid = new EmberGrid(width, height, cells);
 }
Exemple #20
0
 public static void InitializeBlueprint <T>() where T : Blueprint <EmberCell>, new()
 {
     Grid = new EmberGrid(new T());
 }