12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System.Collections.Generic;
- using UI.Common;
- using UnityEngine;
- using FairyGUI;
- using System;
- namespace GFGGame
- {
- public class PromptController : SingletonBase<PromptController>
- {
- private List<GComponent> _uis = new List<GComponent>();
- public PromptController()
- {
- Timers.inst.AddUpdate(Update);
- }
- private void Update(object param)
- {
- if (_uis.Count > 0)
- {
- GComponent ui = _uis[0];
- long endTime = (long)ui.data;
- if (endTime < ET.TimeHelper.ClientNow())
- {
- _uis.Remove(ui);
- GTweener gTweener = ui.TweenFade(0, 0.5f);
- gTweener.OnComplete(() =>
- {
- ui.RemoveFromParent();
- ui.Dispose();
- });
- }
- }
- }
- public void ShowFloatTextPrompt(string message, MessageType messageType = MessageType.ERR)
- {
- GComponent ui;
- // switch(messageType)
- // {
- // case MessageType.WARNING:
- // ui = UI_FloatingTextPromptWarningUI.Proxy().target;
- // break;
- // case MessageType.NORMAL:
- // ui = UI_FloatingTextPromptNarmalUI.Proxy().target;
- // break;
- // case MessageType.SUCCESS:
- // ui = UI_FloatingTextPromptSuccessUI.Proxy().target;
- // break;
- // default:
- // ui = UI_FloatingTextPromptErrUI.Proxy().target;
- // break;
- // }
- ui = UI_FloatingTextPromptNarmalUI.Proxy().target;
- ViewManager.AddChildToFloatLayer(ui);
- GTextField textField = ui.GetChild("txtMessage") as GTextField;
- textField.text = message;
- if (_uis.Count <= 0)
- {
- ui.Center();
- }
- else
- {
- MoveAllUp();
- GComponent preui = _uis[_uis.Count - 1];
- ui.x = preui.x;
- ui.y = preui.y + 100;
- }
- ui.data = ET.TimeHelper.ClientNow() + 3000;
- _uis.Add(ui);
- }
- private void MoveAllUp()
- {
- foreach (GComponent ui in _uis)
- {
- ui.y -= 50;
- }
- }
- }
- }
|