예제 #1
0
            public MatrixBounds Prepare(CellMatrix matrix, bool block)
            {
                MatrixBounds combinedCoverage;

                //The bounds used last check
                _oldBounds.Mirror(_actualBounds);

                if (!block)
                {
                    //Only unblock is required, so the affected area is the most recent coverage
                    combinedCoverage = _cellCoverage;
                    _actualBounds.Reset();
                    _cellCoverage = MatrixBounds.nullBounds;

                    return(combinedCoverage);
                }

                var velocity = _parent.GetVelocity();

                var obstacleSensitivityRange = _parent.useGridObstacleSensitivity ? matrix.obstacleSensitivityRange : _parent.customSensitivity;

                PrepareHull(velocity, obstacleSensitivityRange);

                //Get the axis-aligned bounding box
                var bounds = _actualBounds.CalculateBounds();

                //Get the new coverage, combine it with the old for coverage of both those to unblock and block
                var newCoverage = matrix.GetMatrixBounds(bounds, matrix.cellSize / 2f, true);

                combinedCoverage = MatrixBounds.Combine(_cellCoverage, newCoverage);
                _cellCoverage    = newCoverage;

                return(combinedCoverage);
            }
예제 #2
0
            public MatrixBounds Prepare(CellMatrix matrix, bool block)
            {
                _lastCoverage = _newCoverage;

                if (!block)
                {
                    _newCoverage = MatrixBounds.nullBounds;
                    return(_lastCoverage);
                }

                var velocity = _parent.GetVelocity();

                var sensitivity = (matrix.cellSize / 2f) - (_parent.useGridObstacleSensitivity ? matrix.obstacleSensitivityRange : _parent.customSensitivity);

                var bounds = GrowBoundsByVelocity(_collider.bounds, velocity);

                _newCoverage = matrix.GetMatrixBounds(bounds, sensitivity, true);

                return(MatrixBounds.Combine(_lastCoverage, _newCoverage));
            }