public Cell(FlowField flowField, int r, int c) { _flowField = flowField; row = r; col = c; _halfSize = _flowField.cellSize / 2; if (SteeringManager.Instance.useXYPlane) { _cellCenter = _flowField.StartPosition + Vector3.right * row * _flowField.cellSize + Vector3.up * col * _flowField.cellSize; _botLeft = new Vector2(_cellCenter.x - _halfSize, _cellCenter.y - _halfSize); _botRight = new Vector2(_cellCenter.x + _halfSize, _cellCenter.y - _halfSize); _topLeft = new Vector2(_cellCenter.x - _halfSize, _cellCenter.y + _halfSize); _topRight = new Vector2(_cellCenter.x + _halfSize, _cellCenter.y + _halfSize); } else { _cellCenter = _flowField.StartPosition + Vector3.right * row * _flowField.cellSize + Vector3.forward * col * _flowField.cellSize; _botLeft = new Vector2(_cellCenter.x - _halfSize, _cellCenter.z - _halfSize); _botRight = new Vector2(_cellCenter.x + _halfSize, _cellCenter.z - _halfSize); _topLeft = new Vector2(_cellCenter.x - _halfSize, _cellCenter.z + _halfSize); _topRight = new Vector2(_cellCenter.x + _halfSize, _cellCenter.z + _halfSize); } _cellRect = new Rect(_botLeft.x, _botLeft.y, _halfSize * 2, _halfSize * 2); }
override public void InitForFrame() { if (_flowField != null) { if (_flowField.IsValid()) { targetPos = _flowField.GetFuturePosition(_steeringCharacter.Position, targetPos, ref _useArrival); } } else { _flowField = SteeringManager.Instance.GetFlowField(); } base.InitForFrame(); }
public void RegisterFlowField(FlowField flowField) { _flowField = flowField; }