using DG.Tweening; using System.Collections.Generic; using UnityEngine; namespace ET.Client { [FriendOf(typeof(UICommonServerMsgComponent))] public static class UICommonServerMsgComponentSystem { [ObjectSystem] public class UICommonServerMsgComponentAwakeSystem : AwakeSystem { protected override void Awake(UICommonServerMsgComponent self, params object[] param) { ReferenceCollector rc = self.GetParent().GameObject.GetComponent(); self.msg_bg = rc.Get("msg_bg"); self.msg_txt = rc.Get("msg_txt").GetComponent(); string txt = ""; if (param != null && param.Length > 0) { Dictionary dic = param[0] as Dictionary; txt = dic["content"] as string; } self.Init(txt); } } private static void Init(this UICommonServerMsgComponent self,string txt) { if (string.IsNullOrEmpty(txt)) { Log.Error("txt == null"); return; } self.listTask.Add(txt); self.PopTask(); } public static void PushTask(this UICommonServerMsgComponent self,string txt) { if (self.isShowingMsg && txt == self.msg_txt.text) { return; } self.listTask.Add(txt); } public static void PopTask(this UICommonServerMsgComponent self) { if (self.listTask.Count <= 0) { self.OnCloseAsync(); return; } string content = self.listTask[0]; self.listTask.RemoveAt(0); self.msg_txt.text = content; self.isShowingMsg = true; self.msg_bg.transform.localPosition = Vector2.zero; self.msg_bg.transform.localScale = new Vector2(0.6f,0.6f); self.msg_bg.transform.DOKill(); self.twScale = self.msg_bg.transform.DOScale(1, 0.3f).onComplete = () => { self.twScale = null; self.twMove = self.msg_bg.transform.DOLocalMoveY(60, 0.8f).onComplete = () => { self.twMove = null; self.PopTask(); }; }; } public static async void OnCloseAsync(this UICommonServerMsgComponent self) { await UIHelper.Remove(self.ClientScene(),UIType.UICommonServerMsg); } } }