// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-08 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using PureMVC.Interfaces; using System.Collections.Generic; namespace G.UI { public partial class MainWindow : KUIWindow { #region Constructor public MainWindow() : base(UILayer.kNormal, UIMode.kSequenceRemove) { this.uiPath = "ui_main/ui_w_main.prefab"; } #endregion #region Method public void RefreshModel() { var openArg = this.data as string; if (string.IsNullOrEmpty(openArg)) { var newCL = LevelProxy.Instance.newCompletedLevel; if (newCL != 0) { var newULItem = ItemProxy.Instance.GetStaticItem(newCL + 1); if (newULItem != null) OpenWindow(newULItem); PostNotification(GlobalDefine.EVENT_MAIN_WINDOW, newCL, "new_level"); } } else if (openArg == "Cha") { _toggles[(int)PageType.Cha].isOn = true; } else if (openArg == "Home") { _toggles[(int)PageType.World].isOn = true; } else if (openArg == "Kungfu") { _toggles[(int)PageType.Kungfu].isOn = true; } else if (openArg == "Shop") { _toggles[(int)PageType.Shop].isOn = true; } } #endregion #region Mediator readonly int[] _notificationInterests = new int[] { GlobalDefine.EVENT_LEVEL_COMPLETED, GlobalDefine.EVENT_MAIN_WINDOW_PAGE, GlobalDefine.EVENT_MISSION_CHANGED, }; public override IList ListNotificationInterests() { return _notificationInterests; } public override void HandleNotification(INotification notification) { if (notification.Name == GlobalDefine.EVENT_LEVEL_COMPLETED) { } else if (notification.Name == GlobalDefine.EVENT_MAIN_WINDOW_PAGE) { OpenPage(notification.Type.ToInt(), notification.Body); } else if (notification.Name == GlobalDefine.EVENT_MISSION_CHANGED) { RefreshUnlock(); RefreshMission(); } } #endregion #region Unity /// /// /// public override void Awake() { this.InitView(); } /// /// /// public override void OnEnable() { this.RegisterThis(); this.RefreshModel(); this.RefreshView(); } public override void OnDisable() { this.UnregisterThis(); } /// /// /// public override void UpdatePerSecond() { } public void Reset() { this.RefreshView(); } #endregion } }