12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- using DG.Tweening;
- using System.Collections.Generic;
- using UnityEngine;
- namespace ET.Client
- {
- [FriendOf(typeof(UICommonServerMsgComponent))]
- public static class UICommonServerMsgComponentSystem
- {
- [ObjectSystem]
- public class UICommonServerMsgComponentAwakeSystem : AwakeSystem<UICommonServerMsgComponent>
- {
- protected override void Awake(UICommonServerMsgComponent self, params object[] param)
- {
- ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
- self.msg_bg = rc.Get<GameObject>("msg_bg");
- self.msg_txt = rc.Get<GameObject>("msg_txt").GetComponent<UnityEngine.UI.Text>();
- string txt = "";
- if (param != null && param.Length > 0)
- {
- Dictionary<string, object> dic = param[0] as Dictionary<string, object>;
- 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);
- }
- }
- }
|