Пример #1
0
 private void SpreadEnvironment(Point position, IAreaMapCellInternal cell, CellPairsStorage mergedCells)
 {
     TrySpreadEnvironment(position, Direction.North, cell, mergedCells);
     TrySpreadEnvironment(position, Direction.South, cell, mergedCells);
     TrySpreadEnvironment(position, Direction.West, cell, mergedCells);
     TrySpreadEnvironment(position, Direction.East, cell, mergedCells);
 }
Пример #2
0
 private void MergeCellEnvironment(Point position, IAreaMapCellInternal cell, CellPairsStorage mergedCells)
 {
     if (cell.BlocksEnvironment)
     {
         return;
     }
     SpreadEnvironment(position, cell, mergedCells);
 }
Пример #3
0
        private void PostUpdateCells()
        {
            var mergedCells = new CellPairsStorage(Width, Height);

            for (var y = 0; y < cells.Length; y++)
            {
                for (var x = 0; x < cells[y].Length; x++)
                {
                    var position = new Point(x, y);
                    var cell     = GetOriginalCell(x, y);
                    cell.Environment.Update(position, cell);
                    MergeCellEnvironment(position, cell, mergedCells);
                    cell.PostUpdate(this, position);
                    cell.ResetDynamicObjectsState();
                }
            }
        }
Пример #4
0
        private void TrySpreadEnvironment(Point position, Direction direction, IAreaMapCellInternal cell, CellPairsStorage mergedCells)
        {
            var nextPosition = Point.GetPointInDirection(position, direction);

            if (!ContainsCell(nextPosition))
            {
                return;
            }

            var nextCell = GetOriginalCell(nextPosition.X, nextPosition.Y);

            if (mergedCells.ContainsPair(position, direction))
            {
                return;
            }
            mergedCells.RegisterPair(position, direction);

            if (nextCell.BlocksEnvironment)
            {
                return;
            }

            cell.CheckSpreading(nextCell);
            cell.Environment.Balance(cell, nextCell);
        }