//旋转轮盘 private void Turn(int selectedIndex, bool visible = true) { this.selectedIndex = selectedIndex; if (this.items == null) { Debug.LogError("<><NavigatorView.Turn>Parameter 'items' is null"); return; } else if (selectedIndex < 0 || selectedIndex >= this.items.Count) { Debug.LogErrorFormat("<><NavigatorView.Turn>Parameter 'selectedIndex' is invalid, selectedIndex: {0}, items.Count: {1}", selectedIndex, this.items.Count); return; } if (this.sequence != null) { this.sequence.Kill(true); } this.items.ForEach(t => t.SetStatus(t == this.items[this.selectedIndex])); if (visible) { this.canvasGroup.DOFade(1f, this.indexChanged && !this.displayed ? this.fadeDuration : 0); this.panel.transform.DOScale(1f, this.indexChanged && !this.displayed ? this.fadeDuration : 0); } this.displayed = true; NavigatorItem navigatorItem = this.items[this.selectedIndex]; Vector3 endAngle = new Vector3(0, 0, navigatorItem.Angle); this.sequence = DOTween.Sequence(); if (visible) { if (this.indexChanged) { sequence.Append(this.panel.DOLocalRotate(endAngle, this.rotateDuration)); //SoundPlayer.GetInstance().StopSound("navigator_change_icon"); SoundPlayer.GetInstance().PlaySoundType("navigator_change_icon"); } sequence.AppendInterval(this.reaminSeconds); sequence.Append(this.canvasGroup.DOFade(0f, this.fadeDuration / 2)); sequence.Append(this.panel.transform.DOScale(0.9f, this.fadeDuration / 2)); if (this.viewChanged) { sequence.AppendCallback(() => this.Dispatch(navigatorItem.View)); } } else { sequence.Append(this.panel.DOLocalRotate(endAngle, 0f)); } sequence.AppendCallback(() => this.displayed = false); this.lastSelectedIndex = this.selectedIndex; }
//发送消息 private void Dispatch(TopViewHelper.ETopView selectedView) { if (this.lastNavigatorItem != null && TopViewHelper.Instance.IsOpenedView(this.lastNavigatorItem.View)) { this.CloseLastViewSignal.Dispatch(this.lastNavigatorItem.View);//关闭上一个功能页面 } this.ResetPet(); if (this.ViewSelectedAction != null) { this.ViewSelectedAction(selectedView);//打开新的功能页或关闭所有功能页(目前仅指喂食页和换装页) } if (this.items[this.selectedIndex].View != TopViewHelper.ETopView.eHome) { this.lastNavigatorItem = this.items[this.selectedIndex]; } else { this.lastNavigatorItem = null; } Debug.LogFormat("<><NavigatorView.Dispatch>SelectedView: {0}", selectedView); }
//旋转至Home图标 public void TurnToHomePage() { this.Turn(this.defaultIndex, false); this.ResetPet(); this.lastNavigatorItem = this.items.Find(t => t.View == TopViewHelper.ETopView.eHome); }