Esempio n. 1
0
        //游戏过程中切换场景 向服务器请求场景切换
        public IEnumerator ChangeScene(int sceneId, bool isRelive)
        {
            Log.Sys("ChangeEnterNextScene " + sceneId);
            nextSceneId = sceneId;
            var sdata = CopyController.copyController.GetLevelInfo(nextSceneId);

            BackgroundSound.Instance.PlaySound(sdata.background);

            station = isRelive ? WorldStation.Relive : WorldStation.AskChangeScene;

            //先显示加载界面,首先加载网络资源接着加载静态资源
            loadUI = WindowMng.windowMng.PushView("UI/loading").GetComponent <LoadingUI>();
            //再去清理UI 层深度信息
            MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.ChangeScene);

            Log.Net("EnterScene Process");

            CGEnterScene.Builder es = CGEnterScene.CreateBuilder();
            es.Id = sceneId;
            var packet = new KBEngine.PacketHolder();

            yield return(StartCoroutine(KBEngine.Bundle.sendSimple(this, es, packet)));

            if (packet.packet.responseFlag == 0)
            {
                station = WorldStation.Entering;
                yield return(StartCoroutine(EnterScene(packet.packet.protoBody as GCEnterScene)));
            }
            else
            {
                Debug.LogError("ChangeScene Error ");
            }
        }
Esempio n. 2
0
        //游戏过程中切换场景 向服务器请求场景切换
        public IEnumerator ChangeScene(int sceneId, bool isRelive)
        {
            Log.Sys("ChangeEnterNextScene " + sceneId);
            nextSceneId = sceneId;
            var sdata = CopyController.copyController.GetLevelInfo(nextSceneId);

            Log.Sys("backSound: " + sdata.background);
            BackgroundSound.Instance.PlaySound(sdata.background, sdata.volume / 100.0f);
            GameObject.Destroy(audios);
            if (!string.IsNullOrEmpty(sdata.noise))
            {
                audios = BackgroundSound.Instance.PlayEffectLoop(sdata.noise, sdata.noiseVolume / 100.0f);
                audios.Play();
            }

            station = isRelive ? WorldStation.Relive : WorldStation.AskChangeScene;

            //先显示加载界面,首先加载网络资源接着加载静态资源
            loadUI = WindowMng.windowMng.PushView("UI/loading").GetComponent <LoadingUI>();
            //再去清理UI 层深度信息
            MyEventSystem.myEventSystem.PushEvent(MyEvent.EventType.ChangeScene);

            Log.Net("EnterScene Process");


            /*
             *          CGEnterScene.Builder es = CGEnterScene.CreateBuilder ();
             *          es.Id = sceneId;
             *          var packet = new KBEngine.PacketHolder ();
             *          yield return StartCoroutine (KBEngine.Bundle.sendSimple(this, es, packet));
             */
            yield return(null);

            station = WorldStation.Entering;
            //yield return StartCoroutine(EnterScene(packet.packet.protoBody as GCEnterScene));
            yield return(StartCoroutine(EnterScene(null)));

            /*
             *          if (packet.packet.responseFlag == 0) {
             *          } else {
             *                  Debug.LogError("ChangeScene Error ");
             *          }
             */
        }