Beispiel #1
0
        /// <summary>
        /// 检测球滚动停止
        /// </summary>
        /// <param name="rollPoint"></param>
        /// <param name="acc"></param>
        /// <returns></returns>
        public bool CheckStop(GolfRollPoint rollPoint, Vector3 acc)
        {
            bool isStop = rollPoint.Velocity.magnitude < LogicConstantData.FLOAT_PERCISION_FIX && acc == Vector3.zero;

            if (isStop || rollPoint.ColType == CollisionType.Out)
            {
                return(true);
            }
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// 计算滚动路径(推杆)
        /// </summary>
        /// <param name="input">输入数据</param>
        /// <param name="startPos">发球点</param>
        /// <returns></returns>
        public GolfPathInfo CalcRollPath(GolfPushInput input, Vector3 startPos, Vector3 predictionPos)
        {
            PushInput = input;
            MotionPath.Clear();
            MotionPath.Init();
            MotionPath.PathInfo.ListPt.Clear();

            GolfRollPoint rollPoint = new GolfRollPoint();

            rollPoint.Position = startPos;
            SearchResult sr = null;

            m_CurMap.SearchMapTriangle(rollPoint.Position, ref sr);
            rollPoint.Velocity = PushInput.BattingVelocity;
            rollPoint.IsRoll   = true;
            rollPoint.Poly     = sr.Poly;
            rollPoint.AType    = sr.Type;
            rollPoint.ColType  = CollisionType.Normal;
            rollPoint.Status   = BallRunStatus.Roll;
            MotionPath.PathInfo.AddPathPoint(rollPoint);
            MotionPath.CalcPath(startPos, predictionPos, Time.fixedDeltaTime, true);
            return(MotionPath.PathInfo);
        }
Beispiel #3
0
        /// <summary>
        /// 计算下一个真正的滚动点
        /// </summary>
        /// <param name="startPoint"></param>
        /// <param name="nextPosition"></param>
        /// <param name="nextVelocity"></param>
        /// <param name="acc"></param>
        /// <param name="time"></param>
        /// <returns></returns>
        public GolfRollPoint CalcRealRollPoint(GolfRollPoint startPoint, Vector3 nextPosition, Vector3 nextVelocity, Vector3 acc, float time)
        {
            GolfRollPoint        nextPoint = new GolfRollPoint();
            GolfIntoTriCollision collision = null;
            bool isChangeTri = m_CurMap.CheckIntoNearTriangle(startPoint.Position, nextPosition, startPoint.Poly, ref collision);

            if (isChangeTri)
            {
                //切换三角面,这里返回的collision是预测滚动路径与三角面对应边的交点,即真正的下一个点
                nextPoint.Position = collision.Point;
                float realTime = time;
                nextPoint.Velocity = CalcRealRollVelocity(startPoint.Position, collision.Point, startPoint.Velocity, startPoint.AType, startPoint.Poly, time, acc, out realTime);;
                nextPoint.Poly     = collision.Poly;
                nextPoint.AType    = collision.Type;
                nextPoint.IsRoll   = true;
                nextPoint.ColType  = collision.ColType;
                nextPoint.Interval = realTime;
                nextPoint.IsRoll   = true;
                nextPoint.Status   = BallRunStatus.Roll;
                //Debug.Log("Change   TriCalcRollP: " + " Position:" + nextPoint.Position + " Vel:" + nextPoint.Velocity + " acc:" + acc + " Tri:" + nextPoint.MapTri + " SubMap:" + nextPoint.SubMap);
            }
            else
            {
                //在同一个三角面,按正常跑
                nextPoint.Position = nextPosition;
                nextPoint.Velocity = nextVelocity;
                nextPoint.Poly     = startPoint.Poly;
                nextPoint.AType    = startPoint.AType;
                nextPoint.IsRoll   = true;
                nextPoint.ColType  = startPoint.ColType;
                nextPoint.Interval = time;
                nextPoint.IsRoll   = true;
                nextPoint.Status   = BallRunStatus.Roll;
                //Debug.Log("No   ChangeTriCalcRollP: " + " Position:" + nextPoint.Position + " Vel:" + nextPoint.Velocity + " acc:" + acc + " Tri:" + nextPoint.MapTri + " SubMap:" + nextPoint.SubMap);
            }
            return(nextPoint);
        }