// *********************************************************************** // Assembly : Unity // Author : Kimch // Created : 2017-11-11 // // Last Modified By : Kimch // Last Modified On : // *********************************************************************** // // // *********************************************************************** using System.Collections.Generic; namespace G.UI { public partial class ToastBox : KUIWindow { #region Static API public static void ShowText(string text) { if (_Instance is null) { OpenWindow(); } _Instance.AddInfo(0, text); } public static void ShowText(int textId) { if (_Instance is null) { OpenWindow(); } _Instance.AddInfo(0, KLocalization.GetLocalString(textId)); } public static void ShowText(string text, int type) { if (_Instance is null) { OpenWindow(); } _Instance.AddInfo(type, text); } public static void ShowEffect(string text) { if (_Instance is null) { OpenWindow(); } _Instance.AddInfo(7, text); } public static void ShowCombatValue(int cur, int add, int index) { if (_Instance is null) { OpenWindow(); } _Instance.AddInfo(2, cur, add); } public static void ShowEquipment(string name, int quality, string[] iconInfo) { if (_Instance is null) { OpenWindow(); } _Instance.AddInfo(3, name, quality, iconInfo); } /// /// /// /// /// /// /// public static void ShowProp(string name, int amount, int quality, string[] iconInfo) { if (_Instance is null) { OpenWindow(); } _Instance.AddInfo(8, name, amount, quality, iconInfo); } #endregion #region Model private struct ToastInfo { public int type; public string content; public string[] iconInfo; public int arg1; public int arg2; } private readonly Queue _infoQueue = new Queue(); private void AddInfo(int type, string text) { AddInfo(new ToastInfo { type = type, content = text, }); } private void AddInfo(int type, string text, int quality) { AddInfo(new ToastInfo { type = type, content = text, arg1 = quality, }); } private void AddInfo(int type, string text, int quality, string[] icon) { AddInfo(new ToastInfo { type = type, content = text, arg1 = quality, iconInfo = icon, }); } private void AddInfo(int type, string text, int amount, int quality, string[] icon) { AddInfo(new ToastInfo { type = type, content = text, arg1 = amount, arg2 = quality, iconInfo = icon, }); } private void AddInfo(int type, int zhanli, int zhanliAdd) { AddInfo(new ToastInfo { type = type, arg1 = zhanli, arg2 = zhanliAdd, }); } private void AddInfo(ToastInfo info) { _infoQueue.Enqueue(info); } private void RefreshModel() { } #endregion #region Constructor private static ToastBox _Instance; public ToastBox() : base(UILayer.kPopup, UIMode.kNone) { uiPath = "ui_w_toast"; _Instance = this; } #endregion #region Method public override void Awake() { InitView(); } public override void OnEnable() { RefreshModel(); RefreshView(); } public override void Update() { UpdateView(); } #endregion } }