Esempio n. 1
0
        public void GoToIndex(int tarInd)
        {
            tarInd = Mathf.Clamp(tarInd, 0, MajorLevelSectorList.Count);
            var tr = MorlnTweenRotation.Begin(gameObject, 0.322f, new Vector3(0, 0, OffsetAngle * tarInd));

            tr.from = new Vector3(0, 0, _totalAngle);
            EventDelegate.Add(tr.onFinished, RotationFinish);
        }
Esempio n. 2
0
 public void OnGoLeftClick()
 {
     if (CurIndex > 0)
     {
         var tr = MorlnTweenRotation.Begin(gameObject, 0.322f, new Vector3(0, 0, OffsetAngle * (CurIndex - 1)));
         tr.from = new Vector3(0, 0, _totalAngle);
         EventDelegate.Add(tr.onFinished, RotationFinish);
     }
 }
Esempio n. 3
0
 public void OnGoRightClick()
 {
     if (CurIndex < MajorLevelSectorList.Count - 1)
     {
         var tr = MorlnTweenRotation.Begin(gameObject, 0.322f, new Vector3(0, 0, OffsetAngle * (CurIndex + 1)));
         tr.from = new Vector3(0, 0, _totalAngle);
         EventDelegate.Add(tr.onFinished, RotationFinish);
     }
 }
Esempio n. 4
0
        private void LateUpdate()
        {
            float delta          = RealTime.deltaTime;
            bool  willButNotStop = false;
            bool  doDampen       = true;

            if (_pressed)
            {
            }
            else//已经松开
            {
                if (Mathf.Abs(mMomentum) > 0.5f)//动得很快
                {
                    if (Mathf.Abs(mMomentum) > 0.0001f)
                    {
                        PlanetTra.eulerAngles += new Vector3(0, 0, SpringDampen(ref mMomentum, 9f, delta));//控制旋转

                        doDampen = false;
                    }
                }
                else//快停了
                {
                    if (Mathf.Abs(mMomentum) > 0.0001f)//没停
                    {
                        willButNotStop = true;
                        mMomentum      = 0;
                    }
                }
            }

            // Dampen the momentum
            if (doDampen)
            {
                SpringDampen(ref mMomentum, 9f, delta);
            }

            //计算_totalAngle
            var curEulerZ = PlanetTra.localEulerAngles.z;

            if (_lastEulerZ < 90 && curEulerZ > 270)
            {
                _totalAngle -= _lastEulerZ + 360 - curEulerZ;
            }
            else if (_lastEulerZ > 270 && curEulerZ < 90)
            {
                _totalAngle += curEulerZ + 360 - _lastEulerZ;
            }
            else
            {
                _totalAngle += curEulerZ - _lastEulerZ;
            }
            _lastEulerZ = curEulerZ;

            if (willButNotStop)
            {
                var index = Mathf.RoundToInt(_totalAngle / OffsetAngle);
                index = Mathf.Clamp(index, 0, MajorLevelSectorList.Count - 1);
                var displacementAng = OffsetAngle * index - PlanetTra.localEulerAngles.z;
                var duration        = Mathf.Clamp(Mathf.Abs(displacementAng) / 90 + 0.1f, 0.1f, 0.5f);
                var tr = MorlnTweenRotation.Begin(gameObject, duration, new Vector3(0, 0, OffsetAngle * index));
                tr.from = new Vector3(0, 0, _totalAngle);
                EventDelegate.Add(tr.onFinished, RotationFinish);
            }

            // 根据角度判断所有岛屿显示与隐藏
            for (int i = 0; i < MajorLevelSectorList.Count; i++)
            {
                if (Mathf.Abs(i * OffsetAngle - _totalAngle) <= OffsetAngle * 1.1f)
                {
                    if (!MajorLevelSectorList[i].activeSelf)
                    {
                        MajorLevelSectorList[i].SetActive(true);
                    }
                }
                else
                {
                    if (MajorLevelSectorList[i].activeSelf)
                    {
                        MajorLevelSectorList[i].SetActive(false);
                    }
                }
            }

            //根据角度判断名称Label的显示
            var floatIndex   = _totalAngle / OffsetAngle;
            var closestIndex = Mathf.RoundToInt(floatIndex);

            if (closestIndex != _closestIndex)
            {
                PushLevelUI.LblMajorLevelName.text = _challengeLevelConfig != null && closestIndex >= 0 &&
                                                     closestIndex < _challengeLevelConfig.MajorLevelList.Count
                                                         ? _challengeLevelConfig.MajorLevelList[closestIndex].Title
                                                         : null;
                _closestIndex = closestIndex;
            }
            var d = Mathf.Abs(floatIndex - closestIndex);

            PushLevelUI.LblMajorLevelName.alpha = 1 - 4 * d * d;
        }