public void SetData(Vector3 targetPos, float speed, LuaFunction cb, int objID, float fOffset, bool autopathing) { if (_ObjectComponent == null) { _ObjectComponent = _Owner.GetComponent <ObjectBehaviour>(); } _TargetPos = targetPos; #region 主角自动寻路判断逻辑 if (_OwnerType == ObjectBehaviour.OBJ_TYPE.HOSTPLAYER) { if (fOffset > 0.0f && Util.DistanceH(_Owner.transform.position, targetPos) < fOffset) //检查是否距离过近, 取消寻路,走直线逻辑 { CHostPathFindingInfo.Instance.Clear(); } else { CalcHostPathFindingInfo(); SetCameraQuickFollow(autopathing); } } #endregion _MoveSpeed = speed; _TargetPos.y = CUnityUtil.GetMapHeight(_TargetPos) + _ObjectComponent.OffsetY; // 只需要在设置目标点时,计算一次高度 _DestOffset = fOffset; if (OnFinishCallbackRef != null) { OnFinishCallbackRef.Release(); } OnFinishCallbackRef = cb; _BlockOccurCount = 0; }
public void SetData(Vector3 dir, float speed, LuaFunction cb, bool continued = false, float continued_angle = 0) { if (speed < 0.00001f) { speed = 300f; } dir.y = 0; bool bIsValidDir = Util.IsValidDir(ref dir); Vector3 forward = _Owner.forward; _StartDir = forward; _StartDir.y = 0; _Continue = continued; if (!_Continue) { if (bIsValidDir) { _DestDir = dir; _TotalTime = Vector3.Angle(_StartDir, _DestDir) / speed; } else { _DestDir = _StartDir; _TotalTime = 0; } } else //continue { Quaternion rotation = _Owner.rotation; _StepTime = Mathf.Abs((int)(continued_angle / 60)); _LastAngle = continued_angle % 60; _TurnDirect = (continued_angle > 0.0001f); _ContinueAngle = continued_angle; _TargetRotation = rotation * Quaternion.Euler(0, _LastAngle, 0); _StartRotation = rotation; _TotalTime = Mathf.Abs(continued_angle / speed); _DestDir = Quaternion.Euler(0, continued_angle, 0) * forward; } _TimeStepPassed = 0; _TimePassed = 0; if (OnFinishCallbackRef != null) { OnFinishCallbackRef.Release(); } OnFinishCallbackRef = cb; }