Beispiel #1
0
        /// <summary>
        /// 计算飞行路径(击球)
        /// </summary>
        /// <param name="Input">输入数据</param>
        /// <param name="startPos">发球点</param>
        /// <returns></returns>
        public GolfPathInfo CalcFlyPath(GolfFlyInput input, Vector3 startPos, Vector3 predictionPos)
        {
            FlyInput = input;
            MotionPath.Clear();
            MotionPath.Init();
            //计算球路径
            ClubparameterConfig clubConfig = ClubparameterDao.Inst.GetCfg(FlyInput.ClubType);

            if (clubConfig == null)
            {
                return(null);
            }
            MotionPath.BattingVelocity     = FlyInput.BattingVelocity;
            MotionPath.Fly.CosElevationRad = clubConfig.AngleCos;
            MotionPath.Fly.SinElevationRad = clubConfig.AngleSin;
            MotionPath.SpinValueList.Clear();
            MotionPath.SpinValueList.Add(FlyInput.Spin.FirstFBSpin);
            MotionPath.SpinValueList.Add(FlyInput.Spin.SecondFBSpin);
            MotionPath.SpinValueList.Add(FlyInput.Spin.ThirdFBSpin);
            MotionPath.SpinValueList.Add(FlyInput.Spin.FourFBSpin);
            MotionPath.SpinLeftRight      = FlyInput.Spin.LRSpin;
            MotionPath.HookAngle          = FlyInput.HookAngle;
            MotionPath.Fly.AccuracyRevise = CalcAccuracy(FlyInput.Accuracy.ClubAccuracy, FlyInput.Accuracy.AccuracyOffset);
            MotionPath.SpinDic            = SpinDic;
            MotionPath.CalcPath(startPos, predictionPos, Time.fixedDeltaTime, false);
            return(MotionPath.PathInfo);
        }
Beispiel #2
0
        /// <summary>
        /// 计算,推荐出来的五环的位置
        /// </summary>
        /// <param name="club">所用的球杆</param>
        /// <param name="ball">所使用的球</param>
        /// <param name="startPos">发球点</param>
        /// <returns></returns>
        public Vector3 CalcPredictionRingPos(GolfFlyInput input, Vector3 startPos)
        {
            Vector3 dir = m_CurMap.BallHolePos - startPos;

            dir.Normalize();
            Vector3 RingPos = startPos + dir * (input.ClubStrength + input.BallStrengthPercent / 100);

            FlyInput = input;
            MotionPath.Clear();
            MotionPath.Init();
            //计算球路径
            ClubparameterConfig clubConfig = ClubparameterDao.Inst.GetCfg(FlyInput.ClubType);

            if (clubConfig == null)
            {
                return(RingPos);
            }
            MotionPath.BattingVelocity     = FlyInput.BattingVelocity;
            MotionPath.Fly.CosElevationRad = clubConfig.AngleCos;
            MotionPath.Fly.SinElevationRad = clubConfig.AngleSin;
            MotionPath.SpinValueList.Clear();
            MotionPath.SpinValueList.Add(FlyInput.Spin.FirstFBSpin);
            MotionPath.SpinValueList.Add(FlyInput.Spin.SecondFBSpin);
            MotionPath.SpinValueList.Add(FlyInput.Spin.ThirdFBSpin);
            MotionPath.SpinValueList.Add(FlyInput.Spin.FourFBSpin);
            MotionPath.SpinLeftRight = FlyInput.Spin.LRSpin;
            MotionPath.HookAngle     = FlyInput.HookAngle;
            MotionPath.SpinDic       = SpinDic;
            MotionPath.CalcPath(startPos, RingPos, Time.fixedDeltaTime, false);
            return(RingPos);
        }
Beispiel #3
0
        /// <summary>
        /// 获取发球仰角正弦余弦弧度值
        /// </summary>
        /// <param name="clubType"></param>
        /// <param name="sinElevationRad"></param>
        /// <param name="cosElevationRad"></param>
        public void GetClubElevationRad(uint clubType, out float sinElevationRad, out float cosElevationRad)
        {
            cosElevationRad = 0;
            sinElevationRad = 0;
            ClubparameterConfig clubConfig = ClubparameterDao.Inst.GetCfg(clubType);

            if (clubConfig != null)
            {
                cosElevationRad = clubConfig.AngleCos;
                sinElevationRad = clubConfig.AngleSin;
            }
        }
Beispiel #4
0
    private void Swing()
    {
        self = BattleM.SelfSel;
        var varWnd = WndManager.FindWnd <MineBallSpinWnd>();

        if (m_swingInfo != null)
        {
            float offset = (m_move.transform.localEulerAngles.z - 180 + 40) / 80 * 100;
            if (offset < 0)
            {
                offset = 0;
            }
            else if (offset > 99)
            {
                offset = 100;
            }
            ClubparameterConfig clubConfig = ClubparameterDao.Inst.GetCfg((uint)self.Club.Type);
            if (BattleM.BallInAra == AreaType.PuttingGreen)
            {
                m_swingInfo.CurAccuracyOffset = 0;
                if (clubConfig != null)
                {
                    m_swingInfo.BattingSpeed = MathUtil.RotateRound(BattleM.GetRollSpeedDir() * clubConfig.MinDistance, m_dragPower, m_ballAngle);
                }
                m_swingInfo.CurHookAngle = m_greenAngle;
            }
            else
            {
                m_swingInfo.CurHookAngle      = m_ballAngle;
                m_swingInfo.CurAccuracyOffset = 50 - offset;
                m_swingInfo.BattingSpeed      = self.NeedSpeed * m_dragPower;
            }


            m_swingInfo.Ball = self.Ball;
            m_swingInfo.Club = self.Club;



            //m_swingInfo.WindSpeed ;
            if (varWnd != null)
            {
                m_swingInfo.CurFBSpin = varWnd.m_CurFBSpin;
                //self.Club.BackSpin = varWnd.m_underSpin;
                m_swingInfo.CurLRSpin = varWnd.m_LRspin;

                //Debug.Log(m_swingInfo.m_dragAngle+".."+ m_swingInfo.m_downSpin+".."+ m_swingInfo.m_upSpin+"..." + m_swingInfo.m_leftSpin+"..."+ m_swingInfo.m_rightSpin);
                // Destroy(varWnd);
            }
            else
            {
                m_swingInfo.CurFBSpin = 0;
                m_swingInfo.CurLRSpin = 0;
            }

            movingValue = m_dragGolfPos;
            dragDis     = Vector3.Distance(m_golfPos, m_dragGolfPos);
            if (m_GolfboxOut != null && m_GolfboxIn != null)
            {
                outScale = m_GolfboxOut.transform.localScale.x;
                inScale  = m_GolfboxIn.transform.localScale.x;
                DOTween.To(() => outScale, x => outScale = x, 0.8f, 0.1f).OnComplete(() =>
                {
                    m_GolfboxOut.SetActive(false);
                });
                DOTween.To(() => inScale, x => inScale = x, 0.6f, 0.1f).OnComplete(() =>
                {
                    m_GolfboxIn.SetActive(false);
                });
            }
            DOTween.To(() => movingValue, x => movingValue = x, m_golfPos, 0.1f);

            isDrag = true;
            WndManager.DestoryWnd <SwingModeWnd>(0.2f);
            WndManager.DestoryWnd <BattleMainWnd>(0.2f);
        }
        BattleM.SetBattleStatus(BattleStatus.Round_FireBall, m_swingInfo);
    }
Beispiel #5
0
    void Update()
    {
        if (isDrag)
        {
            if (m_GolfboxOut != null && m_GolfboxIn != null && m_golf != null)
            {
                m_golf.transform.position         = movingValue;
                m_GolfboxOut.transform.localScale = new Vector3(outScale, outScale, outScale);
                m_GolfboxIn.transform.localScale  = new Vector3(inScale, inScale, inScale);
            }
        }
        if (m_isDrag && m_dragPower > 0.3)
        {
            if (m_backGround.gameObject.activeSelf != true)
            {
                if (m_backGround != null && m_ring != null && m_arrow != null)
                {
                    if (BattleM.BallInAra == AreaType.PuttingGreen)
                    {
                        m_move = m_arrowGreenMove;
                        m_backGround.gameObject.SetActive(false);
                        m_ring.gameObject.SetActive(false);
                        m_arrow.gameObject.SetActive(false);
                        m_arrowGreen.gameObject.SetActive(true);
                        m_arrowGreenMove.gameObject.SetActive(true);
                    }
                    else
                    {
                        m_move = m_arrow;
                        m_backGround.gameObject.SetActive(true);
                        m_ring.gameObject.SetActive(true);
                        m_arrow.gameObject.SetActive(true);
                        m_arrowGreen.gameObject.SetActive(false);
                        m_arrowGreenMove.gameObject.SetActive(false);
                    }
                }
            }


            float moveSpeed = 1;
            if (m_dragPower <= 1.1)
            {
                moveSpeed = 1;
            }
            else
            {
                moveSpeed *= m_dragPower * 2;
            }
            rotate += (m_isRotateLeft ? 100 : -100) * Time.deltaTime * speed * moveSpeed;
            if (rotate > 40)
            {
                m_isRotateLeft = false;
            }
            else if (rotate < -40)
            {
                m_isRotateLeft = true;
            }
            m_move.transform.localEulerAngles = new Vector3(0, 0, 180 + rotate);
            if (m_move == m_arrowGreenMove)
            {
                if (m_swingInfo != null)
                {
                    float offset = (m_move.transform.eulerAngles.z - 180 + 40) / 80 * 100;
                    if (offset < 0)
                    {
                        offset = 0;
                    }
                    else if (offset > 99)
                    {
                        offset = 100;
                    }

                    m_swingInfo.CurAccuracyOffset = offset - 100;


                    self             = BattleM.SelfSel;
                    m_swingInfo.Ball = self.Ball;
                    m_swingInfo.Club = self.Club;

                    ClubparameterConfig clubConfig = ClubparameterDao.Inst.GetCfg((uint)self.Club.Type);
                    if (clubConfig != null)
                    {
                        m_swingInfo.BattingSpeed = BattleM.GetRollSpeedDir() * clubConfig.MinDistance * m_dragPower;
                    }

                    m_swingInfo.CurHookAngle = m_greenAngle;
                    //m_swingInfo.WindSpeed ;

                    m_swingInfo.CurFBSpin = 0;
                    m_swingInfo.CurLRSpin = 0;

                    BattleM.SetRollOperation(m_swingInfo);
                }
            }
            else
            {
                m_move.GetComponent <RectTransform>().localScale = new Vector3(2, 0.7f + m_dragPower * 0.3f, 1);
            }
            // Debug.Log(m_arrow.transform.eulerAngles.z);
            //if(m_arrow.transform.eulerAngles.z > 179.9&& m_arrow.transform.eulerAngles.z < 180.1 )
            //{
            //    Debug.Log("1");
        }
        else
        {
            if (m_arrow != null)
            {
                m_arrow.transform.eulerAngles = new Vector3(0, 0, 180);
                m_arrow.GetComponent <RectTransform>().localScale = new Vector3(2, 0.7f, 1);
            }
            if (m_backGround != null && m_ring != null && m_arrow != null)
            {
                m_backGround.gameObject.SetActive(false);
                m_ring.gameObject.SetActive(false);
                m_arrow.gameObject.SetActive(false);
                m_arrowGreen.gameObject.SetActive(false);
                m_arrowGreenMove.gameObject.SetActive(false);
            }
        }
    }