//加载场景时加载依赖资源的回调
        private void OnLoadSceneDependencyAsset(object sender, GameEventArgs e)
        {
            LoadSceneDependencyAssetEventArgs ne = e as LoadSceneDependencyAssetEventArgs;

            if (ne.UserData != this)
            {
                return;
            }

            HotLog.Info("Load scene '{0}' dependency asset '{1}', count '{2}/{3}'.", ne.SceneAssetName, ne.DependencyAssetName, ne.LoadedCount.ToString(), ne.TotalCount.ToString());
        }
        //加载场景更新的回调
        private void OnLoadSceneUpdate(object sender, GameEventArgs e)
        {
            LoadSceneUpdateEventArgs args = e as LoadSceneUpdateEventArgs;

            if (args.UserData != this)
            {
                return;
            }

            HotLog.Info("Load scene '{0}' update, progress '{1}'.", args.SceneAssetName, args.Progress.ToString("P2"));
        }
예제 #3
0
 //点击退出按钮
 public void OnQuitButtonClick()
 {
     HotLog.Info("On Click Quit Button");
     //打开对话框
     GameEntry.UI.OpenDialog(new DialogParams()
     {
         Mode           = 2,
         Title          = GameEntry.Localization.GetString("AskQuitGame.Title"),
         Message        = GameEntry.Localization.GetString("AskQuitGame.Message"),
         OnClickConfirm = delegate(object userData) { UnityGameFrame.Runtime.GameEntry.Shutdown(ShutdownType.Quit); },
     });
 }
        //加载场景成功的回调
        private void OnLoadSceneSuccess(object sender, GameEventArgs e)
        {
            LoadSceneSuccessEventArgs args = e as LoadSceneSuccessEventArgs;

            if (args.UserData != this)
            {
                return;
            }

            HotLog.Info("Load scene '{0}' OK.", args.SceneAssetName);
            if (m_BackgroundMusicId > 0)
            {
                GameEntry.Sound.PlayMusic(m_BackgroundMusicId);
            }

            m_IsChangeSceneComplete = true;     //加载完成的标志位
        }
        private Canvas m_CachedCanvas = null;                               //画布

        //这种方法后期可以抽象出去,例如使用接口、使用特性获取调用等
        public HPBarComponent()
        {
            GameObject obj = new GameObject("HP Bar");

            obj.transform.SetParent(HotfixEntry.GlobalObj.transform.Find("Customs"));
            (obj.AddComponent(typeof(ComponentView)) as ComponentView).Component = this;

            GameObject InstaceObj = new GameObject("HP Bar Instance");

            InstaceObj.transform.SetParent(obj.transform);

            m_CachedCanvas            = InstaceObj.AddComponent(typeof(Canvas)) as Canvas;
            m_CachedCanvas.renderMode = RenderMode.ScreenSpaceOverlay;

            CanvasScaler scaler = InstaceObj.AddComponent(typeof(CanvasScaler)) as CanvasScaler;

            scaler.uiScaleMode         = CanvasScaler.ScaleMode.ScaleWithScreenSize;
            scaler.referenceResolution = new Vector2(1080, 1920);
            scaler.screenMatchMode     = CanvasScaler.ScreenMatchMode.MatchWidthOrHeight;
            scaler.matchWidthOrHeight  = 0;

            m_HPBarInstanceRoot = InstaceObj.transform;
            if (m_HPBarInstanceRoot == null)
            {
                HotLog.Error("You must set HP bar instance root first.");
                return;
            }

            m_HPBarItemObjectPool = HotfixEntry.ObjectPool.CreateSingleSpawnObjectPool <HPBarItemObject>("HPBarItem", m_InstancePoolCapacity);
            m_ListActiveHPBar     = new List <HPBarItem>();

            GameEntry.Resource.LoadAsset(HotAssetUtility.GetUIItemsAsset("HPBarItem"), RuntimeConstant.AssetPriority.UIFormAsset,
                                         (assetName, asset, duration, userData) =>
            {
                HotLog.Info("Load HPBarItem OK.");
                m_HPBarItemTemplate = asset as GameObject;
            },
                                         //加载失败的回调
                                         (assetName, status, errorMessage, userData) =>
            {
                HotLog.Error("Can not load HPBarItem from '{0}' with error message '{1}'.", assetName, errorMessage);
            });
        }
예제 #6
0
 //点击关于按钮
 public void OnAboutButtonClick()
 {
     HotLog.Info("On Click About Button");
     GameEntry.UI.OpenUIForm(UIFormID.AboutForm);
 }
예제 #7
0
 //点击设置按钮
 public void OnSettingButtonClick()
 {
     HotLog.Info("On Click Setting Button");
     GameEntry.UI.OpenUIForm(UIFormID.SettingForm);
 }
예제 #8
0
        private ProcedureMenu m_ProcedureMenu = null; //菜单流程管理

        //点击开始游戏按钮
        public void OnStartButtonClick()
        {
            HotLog.Info("On Click Start Button");
            m_ProcedureMenu.StartGame();
        }