/// <summary> /// 关闭其他的下拉菜单 /// </summary> /// <param name="id"></param> private void CloseOtherTweenBar(int id) { for (int i = 0; i < _tweenBars.Length; i++) { TweenBar tempBar = _tweenBars[i]; if (tempBar != null) { if (tempBar.ID != id) { tempBar.Tween(true); } } } if (id >= 0) { _stepInfo.ShowOrHide(true); } }
void Start() { Score.text = "0"; LeftTime.text = "30:00"; for (int i = 0; i < 4; i++) { if (i == 1)//教学按钮跳过 { continue; } if (!Trans[i]) { continue; } TweenBar tempBar = new TweenBar(Trans[i], TweenBarId); _tweenBars[i] = tempBar; Button temp = Btns[i]; temp.onClick.AddListener(() => tempBar.Tween()); } Btns[1].onClick.AddListener(() => { EventBase.Instance().EveCloseOtherTweenBar(-1); UIManager.Instance().ShowPanel(UIManager.PanelType.PanelShowDes, false); }); _changeColor = new TweenBar(ChangeColor, TweenBarId); TweenBarBg = transform.Find("Bg").GetComponent <Image>(); _changeColor.AddCallToBtn(0, () => TweenBarBg.color = Color.red); _changeColor.AddCallToBtn(1, () => TweenBarBg.color = Color.green); _changeColor.AddCallToBtn(2, () => TweenBarBg.color = Color.white); _changeColor.AddCallToBtn(3, () => TweenBarBg.color = Color.Lerp(Color.red, Color.white, 0.5f)); _tweenBars[0].AddCallToBtn(1, _changeColor); _tweenBars[0].AddCallToBtn(2, () => UIManager.Instance().ShowPanel(UIManager.PanelType.PanelQuit)); _stepInfo = new StepInfo(transform.Find("StepInfo")); Btns[4].onClick.AddListener(() => _stepInfo.ShowOrHide()); EventBase.Instance().EveCloseOtherTweenBar += CloseOtherTweenBar; EventBase.Instance().StepToNext += _stepInfo.UpdateDesc; EventBase.Instance().StepToNext += UpdateScore; EventBase.Instance().DoGameOver += UpdateScore; }