Exemplo n.º 1
0
    /// <summary>
    /// 切换场景
    /// </summary>
    /// <param PlayerName="sceneName"></param>
    private void SwitchScene(LoadSceneInfo info)
    {
        Timer.Instance.CancelAllTimer();
        GameMgr.Instance.StopAllCoroutines();
        ResourcesMgr.Instance.ClearPool();
        AudioSystem.Instance.StopAllAudio();
        DOTween.KillAll(true);
        switch (info.type)
        {
        case (LoadSceneType.SYNC):
            LoadSceneSync(info);
            break;

        case (LoadSceneType.ASYNC):
            if (SceneManager.GetActiveScene().buildIndex != ESceneID.SCENE_START.GetHashCode())
            {
                UIManager.Instance.StartSaveScreen(UIManager.Instance.UpdateScreenBg);
            }
            GameMgr.Instance.StartCoroutine(LoadSceneAsync(info));
            break;

        default:
            Debug.LogError("错误信息: SceneName:" + info.sceneID.ToString() + " Type:" + info.type.ToString() + " Model:" + info.mode.ToString());
            break;
        }
    }
Exemplo n.º 2
0
    /// <summary>
    /// 退出播放
    /// </summary>
    private void ReturnHandler()
    {
        Debug.Log("退出");
        var loadInfo = new LoadSceneInfo(ESceneID.SCENE_HALL, LoadSceneType.ASYNC, LoadSceneMode.Additive);

        ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
    }
Exemplo n.º 3
0
        /// <summary>
        /// 取消重连
        /// </summary>
        void CancelReConnect()
        {
            isShowTimeOut = false;
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);

            ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
        }
Exemplo n.º 4
0
    /// <summary>
    /// 异步加载场景
    /// </summary>
    /// <param name="info">场景信息</param>
    /// <returns></returns>
    public IEnumerator LoadSceneAsync(LoadSceneInfo info)
    {
        yield return(new WaitForEndOfFrame());

        UIManager.Instance.UpdateLoadignActive(true);
        UIManager.Instance.InitUI(info.sceneID);
        updateTimerId          = Timer.Instance.AddTimer(0, 0, 0, Update);
        gameManagerProxy.async = SceneManager.LoadSceneAsync((int)info.sceneID, info.mode);
    }
Exemplo n.º 5
0
 /// <summary>
 /// 直接加载场景
 /// </summary>
 /// <param name="info">场景信息</param>
 public void LoadSceneSync(LoadSceneInfo info)
 {
     SceneManager.LoadScene((int)info.sceneID, info.mode);
     //UIManager.Instance.UpdateLoadignActive(true);
     //UIManager.Instance.loadScenePercent = 1;
     UIManager.Instance.InitUI(info.sceneID);
     //Resources.UnloadUnusedAssets();
     //GC.Collect();
 }
Exemplo n.º 6
0
        /// <summary>
        ///     播放关闭窗口动作,并移除窗口
        /// </summary>
        /// <returns></returns>
        private IEnumerator PlayCloseEffect()
        {
            View.ViewRoot.GetComponent <Animator>().Play("RoomResultClose");
            yield return(new WaitForSeconds(0.4f));

            UIManager.Instance.HideUI(UIViewID.ROOM_RESULT_VIEW);
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_HALL, LoadSceneType.ASYNC, LoadSceneMode.Additive);

            SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
        }
Exemplo n.º 7
0
 public override void OnRegister()
 {
     base.OnRegister();
     playerInfoProxy    = ApplicationFacade.Instance.RetrieveProxy(Proxys.PLAYER_PROXY) as PlayerInfoProxy;
     View.UserName.text = playerInfoProxy.userName;
     GameMgr.Instance.StartCoroutine(DownIcon(playerInfoProxy.headIconUrl));
     this.View.ButtonAddListening(this.View.CloseButton,
                                  () =>
     {
         PlayerPrefs.SetFloat(PrefsKey.SOUNDSET, this.View.SoundSlider.value);
         PlayerPrefs.SetFloat(PrefsKey.MUSICSET, this.View.MusicSlider.value);
         PlayerPrefs.SetInt(PrefsKey.LUANAGE, this.View.BackGround.isOn ? 1 : -1);
         UIManager.Instance.HideUI(UIViewID.SETTING_VIEW);
     });
     this.View.ButtonAddListening(this.View.SwitchAccountButton,
                                  () =>
     {
         UIManager.Instance.Background.color = new Color(1, 1, 1, 0);
         UIManager.Instance.Background.gameObject.SetActive(true);
         UIManager.Instance.Background.DOColor(new Color(1, 1, 1, 1), 0.5f).SetEase(Ease.Linear).OnComplete(
             () =>
         {
             if (Application.platform == RuntimePlatform.Android)
             {
                 PlayerPrefs.DeleteKey(PrefsKey.USERMAC);
                 PlayerPrefs.DeleteKey(PrefsKey.USERNAME);
                 PlayerPrefs.DeleteKey(PrefsKey.HEADURL);
                 PlayerPrefs.DeleteKey(PrefsKey.SEX);
             }
             var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);
             ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
         });
     });
     this.View.MusicSlider.onValueChanged.AddListener(
         (float value)
         =>
     {
         PlayerPrefs.SetFloat(PrefsKey.MUSICSET, value);
         AudioSystem.Instance.SetBgmAudioVolume(PlayerPrefs.GetFloat(PrefsKey.MUSICSET));
     });
     this.View.SoundSlider.onValueChanged.AddListener(
         (float value) =>
     {
         PlayerPrefs.SetFloat(PrefsKey.SOUNDSET, value);
         AudioSystem.Instance.SetEffectAudioVolume(PlayerPrefs.GetFloat(PrefsKey.SOUNDSET));
     });
     this.View.CheckMark.onValueChanged.AddListener(
         (bool isOn) =>
     {
     });
     this.View.BackGround.onValueChanged.AddListener(
         (bool isOn) =>
     {
     });
 }
Exemplo n.º 8
0
 /// <summary>
 /// 本地消息发送回调处理
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="channel"></param>
 /// <param name="type"></param>
 /// <param name="tbuff"></param>
 public void SendBuff <T>(int channel, int type, T tbuff)
 {
     if (channel.GetHashCode() == MsgNoC2S.REQUEST_JOINROOM_C2S.GetHashCode())
     {
         StartCoroutine(ClientAIMgr.Instance.ClientJoinRoom());
     }
     else if (channel.GetHashCode() == MsgNoC2S.DISLOVEAPPLY_C2S.GetHashCode())
     {
         var loadInfo = new LoadSceneInfo(ESceneID.SCENE_HALL, LoadSceneType.ASYNC, LoadSceneMode.Additive);
         ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
     }
     else if (channel.GetHashCode() == MsgNoC2S.READY_C2S.GetHashCode())
     {
         curSit   = 1;
         cardPool = new List <int>(GlobalData.CardWare);
         GameMgr.Instance.StartCoroutine(ClientReady());
     }
     else if (channel.GetHashCode() == MsgNoC2S.PLAYAMAHJONG_C2S.GetHashCode())
     {
         var putCard = tbuff as PlayAMahjongC2S;
         GameMgr.Instance.StartCoroutine(ClientPlayAct(putCard.mahjongCode, playerInfoProxy.UserInfo.UserID,
                                                       PlayerActType.PUT_CARD));
     }
     else if (channel.GetHashCode() == MsgNoC2S.EXIT_C2S.GetHashCode())
     {
         var exitS2C = new ExitRoomS2C();
         exitS2C.clientCode = ErrorCode.SUCCESS;
         exitS2C.userId     = 9527;
         NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.EXIT_S2C.GetHashCode(), 0, exitS2C);
     }
     else if (channel.GetHashCode() == MsgNoC2S.DISSOLUTION_C2S.GetHashCode())
     {
         var disloveS2C = new DissolveRoomS2C();
         disloveS2C.clientCode = ErrorCode.SUCCESS;
         NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.DISSOLUTION_S2C.GetHashCode(), 0, disloveS2C);
     }
     else if (channel.GetHashCode() == MsgNoC2S.ZIMOHU_C2S.GetHashCode())
     {
         StartCoroutine(HuHandler());
     }
     else if (channel.GetHashCode() == MsgNoC2S.PENG_C2S.GetHashCode())
     {
         StartCoroutine(PengHandler());
     }
     else if (channel.GetHashCode() == MsgNoC2S.SEND_CHAT_C2S.GetHashCode())
     {
         SendChatHandler(tbuff as SendChatC2S);
     }
     else if (channel.GetHashCode() == MsgNoC2S.SEND_VOICE_C2S.GetHashCode())
     {
         SendVoiceHandler(tbuff as SendVoiceC2S);
     }
 }
Exemplo n.º 9
0
    /// <summary>
    /// 控制器消息
    /// </summary>
    /// <param PlayerName="notification">消息</param>
    public override void Execute(INotification notification)
    {
        switch (notification.Name)
        {
        case (NotificationConstant.COMM_GAMEMGR_INIT):
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);
            SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
            break;

        default:
            break;
        }
    }
Exemplo n.º 10
0
 /// <summary>
 /// 本地消息发送回调处理
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="channel"></param>
 /// <param name="type"></param>
 /// <param name="tbuff"></param>
 public void SendBuff <T>(int channel, int type, T tbuff)
 {
     if (channel.GetHashCode() == MsgNoC2S.C2S_Hall_JOIN_IN_ROOM.GetHashCode())
     {
         StartCoroutine(ClientAIMgr.Instance.ClientJoinRoom());
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_APPLY_DISSOLVE.GetHashCode())
     {
         var loadInfo = new LoadSceneInfo(ESceneID.SCENE_HALL, LoadSceneType.ASYNC, LoadSceneMode.Additive);
         ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_READY.GetHashCode())
     {
         curSit   = 1;
         cardPool = new List <int>(GlobalData.CardWare);
         GameMgr.Instance.StartCoroutine(ClientReady());
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_PLAY_A_MAHJONG.GetHashCode())
     {
         var putCard = tbuff as PlayAMahjongC2S;
         GameMgr.Instance.StartCoroutine(ClientPlayAct(putCard.mahjongCode, playerInfoProxy.userID,
                                                       PlayerActType.PUT_CARD));
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_EXIT.GetHashCode())
     {
         var exitS2C = new ExitRoomS2C();
         exitS2C.clientCode = ErrorCode.SUCCESS;
         exitS2C.userId     = 9527;
         NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.S2C_ROOM_EXIT_BROADCAST.GetHashCode(), 0, exitS2C);
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_DISSOLVE.GetHashCode())
     {
         var disloveS2C = new DissolveRoomS2C();
         disloveS2C.clientCode = ErrorCode.SUCCESS;
         NetMgr.Instance.OnClientReceiveBuff(MsgNoS2C.S2C_ROOM_DISSOLVE_BROADCAST.GetHashCode(), 0, disloveS2C);
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_ZI_MO_HU.GetHashCode())
     {
         StartCoroutine(HuHandler());
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_TEXT_CHAT.GetHashCode())
     {
         SendChatHandler(tbuff as SendChatC2S);
     }
     else if (channel.GetHashCode() == MsgNoC2S.C2S_ROOM_VOICE_CHAT.GetHashCode())
     {
         SendVoiceHandler(tbuff as SendVoiceC2S);
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 绑定顶部UI按钮事件
 /// </summary>
 private void TopMenuAddEvent()
 {
     View.TopView.ButtonAddListening(View.TopView.photoButton,
                                     () => {
         if (GlobalData.LoginServer != "127.0.0.1")
         {
             PlayerInfoProxy playerInfoProxy = Facade.RetrieveProxy(Proxys.PLAYER_PROXY) as PlayerInfoProxy;
             var getPlayerInfoC2S            = new GetUserInfoByIdC2S();
             getPlayerInfoC2S.userId         = playerInfoProxy.userID;
             NetMgr.Instance.SendBuff(SocketType.HALL, MsgNoC2S.C2S_Hall_Get_UserInfo_By_Id.GetHashCode(), 0, getPlayerInfoC2S);
         }
         else
         {
             UIManager.Instance.ShowUI(UIViewID.PLATER_INFO_VIEW);
         }
     });
     View.TopView.ButtonAddListening(View.TopView.roomCardButton,
                                     () => {
         UIManager.Instance.ShowUI(UIViewID.SHOPPINGTIPS_VIEW);
         //PlayerInfoProxy pip = Facade.RetrieveProxy(Proxys.PLAYER_PROXY) as PlayerInfoProxy;
         //if (pip.boundAgency == ErrorCode.SUCCESS)
         //{
         //    UIManager.Instance.ShowUI(UIViewID.SHOPPING_VIEW);
         //}
         //else if (pip.boundAgency == ErrorCode.FAILT)
         //{
         //    UIManager.Instance.ShowUI(UIViewID.INVITE_VIEW);
         //}
     });
     View.TopView.ButtonAddListening(View.TopView.signinButton,
                                     () => {
         UIManager.Instance.ShowUI(UIViewID.SIGNIN_VIEW);
     });
     View.TopView.ButtonAddListening(View.TopView.helpButton,
                                     () => {
         UIManager.Instance.ShowUI(UIViewID.HELP_VIEW);
     });
     View.TopView.ButtonAddListening(View.TopView.backButton,
                                     () => {
         UIManager.Instance.Background.color = new Color(1, 1, 1, 0);
         UIManager.Instance.Background.gameObject.SetActive(true);
         UIManager.Instance.Background.DOColor(new Color(1, 1, 1, 1), 0.5f).SetEase(Ease.Linear).OnComplete(
             () => {
             var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);
             ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
         });
     });
 }
Exemplo n.º 12
0
    /// <summary>
    /// 显示播放结束提示
    /// </summary>
    private void ShowCompleteAlert()
    {
        DialogMsgVO dialogMsgVO = new DialogMsgVO();

        dialogMsgVO.dialogType      = DialogType.ALERT;
        dialogMsgVO.title           = "播放提示";
        dialogMsgVO.content         = "播放结束";
        dialogMsgVO.confirmCallBack = (() =>
        {
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_HALL, LoadSceneType.ASYNC, LoadSceneMode.Additive);
            ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
        });
        DialogView dialogView = UIManager.Instance.ShowUI(UIViewID.DIALOG_VIEW) as DialogView;

        dialogView.data = dialogMsgVO;
    }
Exemplo n.º 13
0
        /// <summary>
        /// 确定重连
        /// </summary>
        void ConfirmReConnect()
        {
            isShowTimeOut = false;
            //foreach (KeyValuePair<SocketType, NSocket> keyValuePair in ConnentionDic)
            //{
            //    keyValuePair.Value.ReConnecting();
            //}
            if (SceneManager.GetActiveScene().name != SceneName.LOGIN)
            {
                LoginProxy loginProxy = ApplicationFacade.Instance.RetrieveProxy(Proxys.LOGIN_PROXY) as LoginProxy;
                loginProxy.autoLogin = true;
            }
            StopAllTcpConnection();
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);

            ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
        }
Exemplo n.º 14
0
    public override void OnInit()
    {
        Transform HallViewTransform = UIManager.Instance.GetUIView(UIViewID.HALL_VIEW).viewRoot.transform;

        viewRoot               = this.LaunchUIView("Prefab/UI/Hall/BottomMenuView", HallViewTransform);
        shopButton             = this.viewRoot.transform.FindChild("Buttons").FindChild("ShopButton").GetComponent <Button> ();
        shareButton            = this.viewRoot.transform.FindChild("Buttons").FindChild("ShareButton").GetComponent <Button> ();
        militaryExploitsButton = this.viewRoot.transform.FindChild("Buttons").FindChild("MilitaryExploitsButton").GetComponent <Button> ();
        newsButton             = this.viewRoot.transform.Find("Buttons/NewsButton").GetComponent <Button> ();
        MenuBtn    = this.viewRoot.transform.FindChild("Buttons").FindChild("MenuButton").GetComponent <Button> ();
        PanelObj   = viewRoot.transform.FindChild("Buttons/MenuButton/Panel").gameObject;
        RuleBtn    = viewRoot.transform.FindChild("Buttons/MenuButton/Panel/RuleBtn/Image").GetComponent <Button>();
        SettingBtn = viewRoot.transform.FindChild("Buttons/MenuButton/Panel/SettingBtn/Image").GetComponent <Button>();
        ExitBtn    = viewRoot.transform.FindChild("Buttons/MenuButton/Panel/ExitBtn/Image").GetComponent <Button>();

        //UIManager.Instance.BringToBottom(UIViewID.BOTTOMMENU_VIEW);

        MenuBtn.onClick.AddListener(() => {
            if (!PanelObj.activeSelf)
            {
                PanelObj.SetActive(true);
            }
        });

        ExitBtn.onClick.AddListener(() => {
            UIManager.Instance.Background.color = new Color(1, 1, 1, 0);
            UIManager.Instance.Background.gameObject.SetActive(true);
            UIManager.Instance.Background.DOColor(new Color(1, 1, 1, 1), 0.5f).SetEase(Ease.Linear).OnComplete(
                () =>
            {
                if (Application.platform == RuntimePlatform.Android)
                {
                    PlayerPrefs.DeleteKey(PrefsKey.USERMAC);
                    PlayerPrefs.DeleteKey(PrefsKey.USERNAME);
                    PlayerPrefs.DeleteKey(PrefsKey.HEADURL);
                    PlayerPrefs.DeleteKey(PrefsKey.SEX);
                }
                var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);
                ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
            });
        }
                                    );
    }
Exemplo n.º 15
0
 private void ExitHall()
 {
     UIManager.Instance.Backgournd.color = new Color(1, 1, 1, 0);
     UIManager.Instance.Backgournd.gameObject.SetActive(true);
     UIManager.Instance.Backgournd.DOColor(new Color(1, 1, 1, 1), 0.5f).SetEase(Ease.Linear).OnComplete(
         () =>
     {
         if (Application.platform == RuntimePlatform.Android)
         {
             PlayerPrefs.DeleteKey(PrefsKey.USERMAC);
             PlayerPrefs.DeleteKey(PrefsKey.USERNAME);
             PlayerPrefs.DeleteKey(PrefsKey.HEADURL);
             PlayerPrefs.DeleteKey(PrefsKey.SEX);
         }
         var loadInfo = new LoadSceneInfo(ESceneID.SCENE_LOGIN, LoadSceneType.SYNC, LoadSceneMode.Single);
         ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
     });
     PlayerPrefs.SetFloat(PrefsKey.SOUNDSET, this.View.SoundSlider.value);
     PlayerPrefs.SetFloat(PrefsKey.MUSICSET, this.View.MusicSlider.value);
     PlayerPrefs.SetInt(PrefsKey.LUANAGE, this.View.LanguageToggle.isOn ? 1 : -1);
 }
Exemplo n.º 16
0
    public override void HandleNotification(INotification notification)
    {
        switch (notification.Name)
        {
        case NotificationConstant.MEDI_LOGIN_SWITCHHALLSCENE:
            if (loginView != null)
            {
                loginView.loginAnimator.SetBool("LoginSucceed", true);
            }
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_HALL, LoadSceneType.ASYNC, LoadSceneMode.Additive);
            ApplicationFacade.Instance.SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
            break;

        case NotificationConstant.MEDI_LOGIN_WXLOGINSUCCEED:
            this.SendLoginSucceed();
            break;

        default:
            break;
        }
    }
Exemplo n.º 17
0
    /// <summary>
    /// 切换场景
    /// </summary>
    /// <param PlayerName="sceneName"></param>
    private void SwitchScene(LoadSceneInfo info)
    {
        Timer.Instance.CancelAllTimer();
        GameMgr.Instance.StopAllCoroutines();
        ResourcesMgr.Instance.ClearPool();
        AudioSystem.Instance.StopAllAudio();
        NetMgr.Instance.waitMsgList.Clear();
        DOTween.KillAll(true);
        switch (info.loadType)
        {
        case (LoadSceneType.SYNC):
            LoadSceneSync(info);
            break;

        case (LoadSceneType.ASYNC):
            GameMgr.Instance.StartCoroutine(LoadSceneAsync(info));
            break;

        default:
            Debug.LogError("错误信息: SceneName:" + info.sceneID.ToString() + " Type:" + info.loadType.ToString() + " Model:" + info.mode.ToString());
            break;
        }
    }
        //更新加载场景
        private void UpdateLoadSceneInfos()
        {
            if (m_LoadSceneInfos.Count > 0)
            {
                for (index = 0; index < m_LoadSceneInfos.Count;)
                {
                    LoadSceneInfo loadSceneInfo = m_LoadSceneInfos[index];
                    if (loadSceneInfo.AsyncOperation.isDone)    //判断是否异步完成
                    {
                        if (loadSceneInfo.AsyncOperation.allowSceneActivation)
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback.Invoke(loadSceneInfo.SceneAssetName, (float)(DateTime.Now - loadSceneInfo.StartTime).TotalSeconds, loadSceneInfo.UserData);
                            }
                        }
                        else
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback.Invoke(loadSceneInfo.SceneAssetName, LoadResourceStatus.NotExist, "Can not load this scene from asset database.", loadSceneInfo.UserData);
                            }
                        }

                        m_LoadSceneInfos.RemoveAt(index);   //移除
                    }
                    else
                    {
                        index++;
                        if (loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback != null)
                        {
                            loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback.Invoke(loadSceneInfo.SceneAssetName, loadSceneInfo.AsyncOperation.progress, loadSceneInfo.UserData);
                        }
                    }
                }
            }
        }
Exemplo n.º 19
0
        private void Update()
        {
            if (m_LoadAssetInfos.Count > 0)
            {
                int count = 0;
                LinkedListNode <LoadAssetInfo> current = m_LoadAssetInfos.First;
                while (current != null && count < m_LoadAssetCountPerFrame)
                {
                    LoadAssetInfo loadAssetInfo = current.Value;
                    float         elapseSeconds = (float)(DateTime.Now - loadAssetInfo.StartTime).TotalSeconds;
                    if (elapseSeconds >= loadAssetInfo.DelaySeconds)
                    {
                        UnityEngine.Object asset = null;
#if UNITY_EDITOR
                        if (loadAssetInfo.AssetType != null)
                        {
                            asset = UnityEditor.AssetDatabase.LoadAssetAtPath(loadAssetInfo.AssetName, loadAssetInfo.AssetType);
                        }
                        else
                        {
                            asset = UnityEditor.AssetDatabase.LoadMainAssetAtPath(loadAssetInfo.AssetName);
                        }
#endif

                        if (asset != null)
                        {
                            if (loadAssetInfo.LoadAssetCallbacks.LoadAssetSuccessCallback != null)
                            {
                                loadAssetInfo.LoadAssetCallbacks.LoadAssetSuccessCallback(loadAssetInfo.AssetName, asset, elapseSeconds, loadAssetInfo.UserData);
                            }
                        }
                        else
                        {
                            if (loadAssetInfo.LoadAssetCallbacks.LoadAssetFailureCallback != null)
                            {
                                loadAssetInfo.LoadAssetCallbacks.LoadAssetFailureCallback(loadAssetInfo.AssetName, LoadResourceStatus.NotExist, "Can not load this asset from asset database.", loadAssetInfo.UserData);
                            }
                        }

                        LinkedListNode <LoadAssetInfo> next = current.Next;
                        m_LoadAssetInfos.Remove(loadAssetInfo);
                        current = next;
                        count++;
                    }
                    else
                    {
                        if (loadAssetInfo.LoadAssetCallbacks.LoadAssetUpdateCallback != null)
                        {
                            loadAssetInfo.LoadAssetCallbacks.LoadAssetUpdateCallback(loadAssetInfo.AssetName, elapseSeconds / loadAssetInfo.DelaySeconds, loadAssetInfo.UserData);
                        }

                        current = current.Next;
                    }
                }
            }

            if (m_LoadSceneInfos.Count > 0)
            {
                LinkedListNode <LoadSceneInfo> current = m_LoadSceneInfos.First;
                while (current != null)
                {
                    LoadSceneInfo loadSceneInfo = current.Value;
                    if (loadSceneInfo.AsyncOperation.isDone)
                    {
                        if (loadSceneInfo.AsyncOperation.allowSceneActivation)
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback(loadSceneInfo.SceneAssetName, (float)(DateTime.Now - loadSceneInfo.StartTime).TotalSeconds, loadSceneInfo.UserData);
                            }
                        }
                        else
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback(loadSceneInfo.SceneAssetName, LoadResourceStatus.NotExist, "Can not load this scene from asset database.", loadSceneInfo.UserData);
                            }
                        }

                        LinkedListNode <LoadSceneInfo> next = current.Next;
                        m_LoadSceneInfos.Remove(loadSceneInfo);
                        current = next;
                    }
                    else
                    {
                        if (loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback != null)
                        {
                            loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback(loadSceneInfo.SceneAssetName, loadSceneInfo.AsyncOperation.progress, loadSceneInfo.UserData);
                        }

                        current = current.Next;
                    }
                }
            }

            if (m_UnloadSceneInfos.Count > 0)
            {
                LinkedListNode <UnloadSceneInfo> current = m_UnloadSceneInfos.First;
                while (current != null)
                {
                    UnloadSceneInfo unloadSceneInfo = current.Value;
                    if (unloadSceneInfo.AsyncOperation.isDone)
                    {
                        if (unloadSceneInfo.AsyncOperation.allowSceneActivation)
                        {
                            if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback != null)
                            {
                                unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
                            }
                        }
                        else
                        {
                            if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback != null)
                            {
                                unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
                            }
                        }

                        LinkedListNode <UnloadSceneInfo> next = current.Next;
                        m_UnloadSceneInfos.Remove(unloadSceneInfo);
                        current = next;
                    }
                    else
                    {
                        current = current.Next;
                    }
                }
            }
        }
Exemplo n.º 20
0
        private void Update()
        {
            if (m_LoadSceneInfos.Count > 0)
            {
                LinkedListNode <LoadSceneInfo> current = m_LoadSceneInfos.First;
                while (current != null)
                {
                    LoadSceneInfo loadSceneInfo = current.Value;
                    if (loadSceneInfo.AsyncOperation.isDone)
                    {
                        if (loadSceneInfo.AsyncOperation.allowSceneActivation)
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback(loadSceneInfo.SceneAssetName, (float)(DateTime.Now - loadSceneInfo.StartTime).TotalSeconds, loadSceneInfo.UserData);
                            }
                        }
                        else
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback(loadSceneInfo.SceneAssetName, LoadResourceStatus.NotExist, "Can not load this scene from asset database.", loadSceneInfo.UserData);
                            }
                        }

                        LinkedListNode <LoadSceneInfo> next = current.Next;
                        m_LoadSceneInfos.Remove(loadSceneInfo);
                        current = next;
                    }
                    else
                    {
                        if (loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback != null)
                        {
                            loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback(loadSceneInfo.SceneAssetName, loadSceneInfo.AsyncOperation.progress, loadSceneInfo.UserData);
                        }

                        current = current.Next;
                    }
                }
            }

            if (m_UnloadSceneInfos.Count > 0)
            {
                LinkedListNode <UnloadSceneInfo> current = m_UnloadSceneInfos.First;
                while (current != null)
                {
                    UnloadSceneInfo unloadSceneInfo = current.Value;
                    if (unloadSceneInfo.AsyncOperation.isDone)
                    {
                        if (unloadSceneInfo.AsyncOperation.allowSceneActivation)
                        {
                            if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback != null)
                            {
                                unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
                            }
                        }
                        else
                        {
                            if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback != null)
                            {
                                unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
                            }
                        }

                        LinkedListNode <UnloadSceneInfo> next = current.Next;
                        m_UnloadSceneInfos.Remove(unloadSceneInfo);
                        current = next;
                    }
                    else
                    {
                        current = current.Next;
                    }
                }
            }
        }
Exemplo n.º 21
0
 /// <summary>
 /// 直接加载场景
 /// </summary>
 /// <param name="info">场景信息</param>
 public void LoadSceneSync(LoadSceneInfo info)
 {
     UIManager.Instance.InitUI();
     SceneManager.LoadScene((int)info.sceneID, info.mode);
 }
Exemplo n.º 22
0
        private void Update()
        {
            if (m_LoadAssetInfos.Count > 0)
            {
                LinkedListNode <LoadAssetInfo> current = m_LoadAssetInfos.First;
                while (current != null)
                {
                    LoadAssetInfo loadAssetInfo = current.Value;
                    float         elapseSeconds = (float)(DateTime.Now - loadAssetInfo.StartTime).TotalSeconds;
                    if (elapseSeconds >= loadAssetInfo.DelaySeconds)
                    {
                        UnityEngine.Object asset = null;
#if UNITY_EDITOR
                        if (loadAssetInfo.AssetType != null)
                        {
                            asset = AssetDatabase.LoadAssetAtPath(loadAssetInfo.AssetName, loadAssetInfo.AssetType);
                        }
                        else
                        {
                            asset = AssetDatabase.LoadMainAssetAtPath(loadAssetInfo.AssetName);
                        }
#endif

                        if (asset != null)
                        {
                            if (loadAssetInfo.LoadAssetCallbacks.LoadAssetSuccessCallback != null)
                            {
                                loadAssetInfo.LoadAssetCallbacks.LoadAssetSuccessCallback(loadAssetInfo.AssetName, asset, elapseSeconds, loadAssetInfo.UserData);
                            }
                        }
                        else
                        {
                            if (loadAssetInfo.LoadAssetCallbacks.LoadAssetFailureCallback != null)
                            {
                                loadAssetInfo.LoadAssetCallbacks.LoadAssetFailureCallback(loadAssetInfo.AssetName, LoadResourceStatus.NotExist, "Can not load this asset from asset database.", loadAssetInfo.UserData);
                            }
                        }

                        LinkedListNode <LoadAssetInfo> next = current.Next;
                        m_LoadAssetInfos.Remove(loadAssetInfo);
                        current = next;
                    }
                    else
                    {
                        if (loadAssetInfo.LoadAssetCallbacks.LoadAssetUpdateCallback != null)
                        {
                            loadAssetInfo.LoadAssetCallbacks.LoadAssetUpdateCallback(loadAssetInfo.AssetName, elapseSeconds / loadAssetInfo.DelaySeconds, loadAssetInfo.UserData);
                        }

                        current = current.Next;
                    }
                }
            }
            else
            {
                if (_startLoadAssets)
                {
                    _startLoadAssets = false;
                    _loadAssetsComplete(this,
                                        new GameFramework.Resource.
                                        LoadAssetsCompleteEventArgs
                                            (_assetNames.ToArray(), _assets.ToArray(), _duration, _userData));
                    _clerCache();
                }
            }

            if (m_LoadSceneInfos.Count > 0)
            {
                LinkedListNode <LoadSceneInfo> current = m_LoadSceneInfos.First;
                while (current != null)
                {
                    LoadSceneInfo loadSceneInfo = current.Value;
                    if (loadSceneInfo.AsyncOperation.isDone)
                    {
                        if (loadSceneInfo.AsyncOperation.allowSceneActivation)
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneSuccessCallback(loadSceneInfo.SceneAssetName, (float)(DateTime.Now - loadSceneInfo.StartTime).TotalSeconds, loadSceneInfo.UserData);
                            }
                        }
                        else
                        {
                            if (loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback != null)
                            {
                                loadSceneInfo.LoadSceneCallbacks.LoadSceneFailureCallback(loadSceneInfo.SceneAssetName, LoadResourceStatus.NotExist, "Can not load this scene from asset database.", loadSceneInfo.UserData);
                            }
                        }

                        LinkedListNode <LoadSceneInfo> next = current.Next;
                        m_LoadSceneInfos.Remove(loadSceneInfo);
                        current = next;
                    }
                    else
                    {
                        if (loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback != null)
                        {
                            loadSceneInfo.LoadSceneCallbacks.LoadSceneUpdateCallback(loadSceneInfo.SceneAssetName, loadSceneInfo.AsyncOperation.progress, loadSceneInfo.UserData);
                        }

                        current = current.Next;
                    }
                }
            }

            if (m_UnloadSceneInfos.Count > 0)
            {
                LinkedListNode <UnloadSceneInfo> current = m_UnloadSceneInfos.First;
                while (current != null)
                {
                    UnloadSceneInfo unloadSceneInfo = current.Value;
                    if (unloadSceneInfo.AsyncOperation.isDone)
                    {
                        if (unloadSceneInfo.AsyncOperation.allowSceneActivation)
                        {
                            if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback != null)
                            {
                                unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneSuccessCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
                            }
                        }
                        else
                        {
                            if (unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback != null)
                            {
                                unloadSceneInfo.UnloadSceneCallbacks.UnloadSceneFailureCallback(unloadSceneInfo.SceneAssetName, unloadSceneInfo.UserData);
                            }
                        }

                        LinkedListNode <UnloadSceneInfo> next = current.Next;
                        m_UnloadSceneInfos.Remove(unloadSceneInfo);
                        current = next;
                    }
                    else
                    {
                        current = current.Next;
                    }
                }
            }
        }
Exemplo n.º 23
0
        private void OnGetOutRoomBtnClick()
        {
            var loadInfo = new LoadSceneInfo(ESceneID.SCENE_HALL, LoadSceneType.ASYNC, LoadSceneMode.Additive);

            SendNotification(NotificationConstant.MEDI_GAMEMGR_LOADSCENE, loadInfo);
        }