Ejemplo n.º 1
0
 public static void SetName(this UIMessageWindow self, string key)
 {
     self.NameBg.SetActive(!string.IsNullOrEmpty(key));
     if (!string.IsNullOrEmpty(key))
     {
         self.Name.SetI18NKey(key);
     }
 }
Ejemplo n.º 2
0
        public static async ETTask SetContent(this UIMessageWindow self, string key, bool play = true, bool clear = true)
        {
            if (string.IsNullOrEmpty(key))
            {
                return;
            }
            I18NComponent.Instance.I18NTryGetText(key, out string text);
            var baseLen = self.showLen;

            // text=text.Replace("{0}", UserDataComponent.Instance.CurUserAssets.Name);
            self.allText += text;
            self.Text.SetText(self.allText);
            self.showLen = self.allText.Length;
            self.token   = new ETCancellationToken();
            self.isPlay  = play;
            self.Arrow.SetActive(false);
            for (int i = baseLen + 1; i <= self.showLen && self.isPlay && self.speed > 0; i++)
            {
                self.Text.SetMaxVisibleCharacters(i);
                await TimerComponent.Instance.WaitAsync((long)(50 / self.speed), self.token);

                self.showLen = self.Text.GetCharacterCount();
            }
            self.Text.SetMaxVisibleCharacters(int.MaxValue);
            self.isPlay = false;
            self.token  = new ETCancellationToken();
            self.Arrow.SetActive(true);
            self.Arrow.GetTransform().localPosition = self.Text.GetLastCharacterLocalPosition() + self.Offset;
            if (GalGameEngineComponent.Instance.AutoPlay || !clear || self.speed <= 0)
            {
                if (self.speed <= 0)
                {
                    await TimerComponent.Instance.WaitAsync(10);
                }
                else
                {
                    await TimerComponent.Instance.WaitAsync((long)(self.waitTime / self.speed), self.token);
                }
            }
            if (!(GalGameEngineComponent.Instance.AutoPlay || !clear || self.speed <= 0))
            {
                while (true)
                {
                    KeyCode keycode = await GalGameEngineComponent.Instance.WaitInput;
                    if (keycode == KeyCode.Mouse0)
                    {
                        break;
                    }
                }
            }
            if (clear)
            {
                self.allText = "";
                self.showLen = 0;
            }
        }
Ejemplo n.º 3
0
        public static async ETTask OnRecordBtnClick(this UIMessageWindow self)
        {
            await UIManagerComponent.Instance.CloseWindow <UIGalGameHelper>();

            //先停掉快进状态
            if (GalGameEngineComponent.Instance.State == GalGameEngineComponent.GalGameEngineState.FastForward)
            {
                await GalGameEngineComponent.Instance.ChangePlayFastModel();
            }
            UIManagerComponent.Instance.OpenWindow <UIReview, bool, List <GalGameEngineComponent.ReviewItem> >(UIReview.PrefabPath,
                                                                                                               GalGameEngineComponent.Instance.AutoPlay, GalGameEngineComponent.Instance.ReviewItems, UILayerNames.TipLayer).Coroutine();
            GalGameEngineComponent.Instance.AutoPlay = false;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 打开对话框
        /// </summary>
        /// <param name="self"></param>
        /// <param name="text"></param>
        /// <param name="name"></param>
        /// <param name="windowType"></param>
        /// <param name="pageCtrl"></param>
        /// <param name="voice"></param>
        /// <returns></returns>
        public static async ETTask ShowMessage(this GalGameEngineComponent self, string text, string name, string windowType, string pageCtrl, string voice, long waitTime = 1000)
        {
            if (string.IsNullOrEmpty(windowType))
            {
                windowType = "MessageWindow";
            }
            if (string.IsNullOrEmpty(pageCtrl))
            {
                pageCtrl = "Page";
            }
            bool refresh = pageCtrl.IndexOf("page", StringComparison.OrdinalIgnoreCase) >= 0;

            if (pageCtrl.IndexOf("br", StringComparison.OrdinalIgnoreCase) >= 0)
            {
                text += "\n";
            }
            await UIManagerComponent.Instance.CloseWindow <UIMessageWindow>();

            await UIManagerComponent.Instance.CloseWindow <UIBaseMessageWindow>();

            if (windowType.Equals("messagewindow", StringComparison.OrdinalIgnoreCase))
            {
                UIMessageWindow win = await UIManagerComponent.Instance.OpenWindow <UIMessageWindow, float, long>(UIMessageWindow.PrefabPath, self.Speed, waitTime);

                self.AppendReviewItem(name, text, !refresh);
                win.SetName(name);
                await win.SetContent(text, clear : refresh);
            }
            else if (windowType.Equals("messagewindowfull", StringComparison.OrdinalIgnoreCase))
            {
                var win = await UIManagerComponent.Instance.OpenWindow <UIBaseMessageWindow, float, long>(UIBaseMessageWindow.UIMessageWindowFull, self.Speed, waitTime);

                await win.SetContent(text, clear : refresh);
            }
            else if (windowType.Equals("messagewindowmiddle", StringComparison.OrdinalIgnoreCase))
            {
                var win = await UIManagerComponent.Instance.OpenWindow <UIBaseMessageWindow, float, long>(UIBaseMessageWindow.UIMessageWindowMiddle, self.Speed, waitTime);

                await win.SetContent(text, clear : refresh);
            }
            else
            {
                return;
            }
        }
Ejemplo n.º 5
0
 public static void OnRunningStateEnd(this UIMessageWindow self)
 {
     self.speed = 0;
     self.OnCancel();
 }
Ejemplo n.º 6
0
 public static void OnAutoBtnClick(this UIMessageWindow self)
 {
     GalGameEngineComponent.Instance.AutoPlay = !GalGameEngineComponent.Instance.AutoPlay;
     self.AutoBtnText.SetI18NKey(GalGameEngineComponent.Instance.AutoPlay?"GalGame_Stop":"Global_AutoPlay");
 }
Ejemplo n.º 7
0
 public static void OnCancel(this UIMessageWindow self)
 {
     self.Text.SetMaxVisibleCharacters(int.MaxValue);
     self.isPlay = false;
     self.token?.Cancel();
 }