using System; using System.Collections.Generic; using Framework.Audio; using Framework.Timer; using Game; using UnityEngine; using UnityEngine.UI; using IcecreamView; using MintAnimation.Runtime.Components; using TMPro; namespace Views { public class PropTipPanel : IcecreamView.IC_AbstractModule { [SerializeField] private MintAnimator _mintAnimator; [SerializeField] private MintAnimator _mint2Animator; [SerializeField] private TMP_Text _propText; [SerializeField] private TMP_Text _prop2Text; public int MaxQueue = 1; private float _mintAnimatorDuration = 0.35f; private bool _hasLock = false; private bool _hasLock2 = false; private TimeHandler _timeHandler; private TimeHandler _timeHandler2; private Queue _propQueue = new Queue (); private Queue _prop2Queue = new Queue (); public override void OnOpenView (IC_ViewData msgData) { // this._mintAnimator.StopAnim (); // this._mint2Animator.StopAnim (); if (msgData is { MsgCount: > 0 }) { EventManager.Instance.SendEvent (GameEventCode.PropTip , msgData.GetValue ()); } } [BindUIEvent (GameEventCode.PropTip)] private void OnPropTip (EventArg arg) { //将数据存入队列 this._propQueue.Enqueue (arg.GetValue (0)); // if (!this._hasLock) // { // CheckAndShow (); // } // else // { // MinListener (); // } if (this._mintAnimator.HasPlaying) { this._mintAnimator.StopAnim (); } this._hasLock = false; CheckAndShow (); } [BindUIEvent (GameEventCode.Prop2Tip)] private void OnPropTip2 (EventArg arg) { //将数据存入队列 this._prop2Queue.Enqueue (arg.GetValue (0)); if (!this._hasLock2) { CheckAndShow2 (); } else { MinListener2 (); } } private void MinListener2 () { this._timeHandler2?.Kill (); this._timeHandler2 = GameUpdateMgr.Instance.CreateTimer (this._mintAnimatorDuration , () => { if (this._mint2Animator.HasPlaying && this._prop2Queue.Count >= MaxQueue) { this._mint2Animator.StopAnim (); } }); } private void CheckAndShow2 () { if (this._prop2Queue.Count > 0 && !this._hasLock2) { this._hasLock2 = true; this._prop2Text.text = this._prop2Queue.Dequeue (); AudioManager.Instance.PlaySoundEffect (SeAudio.PropTip , 0.5f); this._mint2Animator.StartAnim (() => { this._hasLock2 = false; CheckAndShow2 (); }); MinListener2 (); } } private void CheckAndShow () { if (this._propQueue.Count > 0 && !this._hasLock) { this._hasLock = true; this._propText.text = this._propQueue.Dequeue (); AudioManager.Instance.PlaySoundEffect (SeAudio.PropTip , 0.5f); this._mintAnimator.StartAnim (() => { this._hasLock = false; CheckAndShow (); }); MinListener (); } } private void MinListener () { this._timeHandler?.Kill (); this._timeHandler = GameUpdateMgr.Instance.CreateTimer (this._mintAnimatorDuration , () => { if (this._mintAnimator.HasPlaying && this._propQueue.Count >= MaxQueue) { this._mintAnimator.StopAnim (); } }); } } }