Пример #1
0
        public void SetClip(AudioClip audio, BackGroundType type)
        {
            BackGroundAudio backGroundAudio = GetBackGroundAudio();

            if (backGroundAudio != null)
            {
                backGroundAudio.SetClip(audio, type);
            }
        }
Пример #2
0
        public void TransferOut()
        {
            //GameDebug.LogError("-----TransferOut");
            BackGroundAudio audio = GetBackGroundAudio();

            if (audio != null)
            {
                audio.TransferOut();
            }
        }
Пример #3
0
 private void LoadMusicFinish(AudioClip audioClip)
 {
     if (audioClip != null)
     {
         BackGroundAudio audio = GetBackGroundAudio();
         if (audio != null)
         {
             audio.TransferInMusic(audioClip);
         }
     }
 }
Пример #4
0
 private BackGroundAudio GetBackGroundAudio()
 {
     if (mBackGroundAudio == null)
     {
         GameObject core_object = xc.MainGame.CoreObject;
         if (core_object == null)
         {
             return(null);
         }
         mBackGroundAudio = core_object.GetComponent <BackGroundAudio>();
     }
     return(mBackGroundAudio);
 }
Пример #5
0
        /// <summary>
        /// 设置音乐的音量
        /// </summary>
        /// <param name="volume"></param>
        public void SetMusicVolume(float volume)
        {
            //GameObject core_object = xc.MainGame.CoreObject;
            //if (core_object == null)
            //    return;

            //var core_audio = core_object.GetComponent<AudioSource>();
            //if (core_audio != null)
            //{
            //    core_audio.volume = volume;
            //}

            BackGroundAudio audio = GetBackGroundAudio();

            if (audio != null)
            {
                audio.SetMusicVolume(volume);
            }
        }
Пример #6
0
        public void KillMusic()
        {
            //GameObject core_object = xc.MainGame.CoreObject;
            //if (core_object == null)
            //    return;

            //var core_audio = core_object.GetComponent<AudioSource>();
            //if (core_audio != null)
            //{
            //    core_audio.clip = null;
            //}

            BackGroundAudio audio = GetBackGroundAudio();

            if (audio != null)
            {
                audio.KillMusic();
            }
        }
Пример #7
0
        /// <summary>
        /// 播放/暂停音乐
        /// </summary>
        /// <param name="play"></param>
        public void PauseMusic(bool pause)
        {
            //GameObject core_object = xc.MainGame.CoreObject;
            //if (core_object == null)
            //    return;

            //var core_audio = core_object.GetComponent<AudioSource>();
            //if(core_audio != null)
            //{
            //    if (!pause)
            //        core_audio.Play();
            //    else
            //        core_audio.Pause();
            //}

            BackGroundAudio audio = GetBackGroundAudio();

            if (audio != null)
            {
                audio.PauseMusic(pause);
            }
        }
Пример #8
0
        public static IEnumerator EnterGame()
        {
            // 预加载资源
            ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.PreloadResStart, "", false);

#if UNITY_EDITOR
            MikuLuaProfiler.HookLuaSetup.OnStartGame();
#endif

            // 创建Core物体
            mCoreObject = new GameObject("Core");
            GameObject.DontDestroyOnLoad(mCoreObject);

            // 实例化Game
            Game mGame = Game.GetInstance();
            mHeartBehavior = mCoreObject.AddComponent <Heart>();
            AssemblyBridge.Instance.TimelinePlayableEmployee = new TimelinePlayableEmployee();

            ClientEventMgr.GetInstance();

            // 增加各种Component
            var resource_loader = mCoreObject.AddComponent <ResourceLoader>();
            resource_loader.BundleVersion    = NewInitSceneLoader.Instance.BundleVersion;
            resource_loader.ServerBundleInfo = NewInitSceneLoader.Instance.g_server_bundle_info;

            mCoreObject.AddComponent <ResourceUtilEx> ();
            ResourceLoader.Instance.init();
            mCoreObject.AddComponent <ObjCachePoolMgr>();

            // 因为部分表格资源放在bundle资源中,因此要尽早进行加载
            yield return(GlobalMono.StartCoroutine(DBTableManager.Instance.Preload()));

            mCoreObject.AddComponent <ActorManager>();
            HttpRequest.Instance = mCoreObject.AddComponent <HttpRequest>();
            mCoreObject.AddComponent <QuadTreeSceneManager>();
            mCoreObject.AddComponent <PushManager>();
            xc.RedPointDataMgr.GetInstance();   //小红点实例化
            xc.LockIconDataMgr.GetInstance();
            xc.NewMarkerDataMgr.GetInstance();  //New标记
#if !DISABLE_LUA
            //mCoreObject.AddComponent<LuaClient>().Init();
            LuaClient luaClient = mCoreObject.AddComponent <LuaClient>();
            yield return(GlobalMono.StartCoroutine(luaClient.InitRoutine()));
#endif

#if (TEST_HOST && !PERFORMANCE_TEST) || HD_RESOURCE
            //mCoreObject.AddComponent<DebugFPS>();// 因为gc的问题暂时屏蔽
            mDebugUI = mCoreObject.AddComponent <DebugUI>();
            mDebugUI.UnsubscribeAllProcessCmd();
            mDebugUI.SubscribeProcessCmd(DebugCommand.OnProcessCmd);
            //测试环境打开DebugWindow,取消仅在编辑器打开的判断
            //#if UNITY_EDITOR
            var window = GameObject.Instantiate(Resources.Load <GameObject>("Debug/DebugWindow"));

            GameObject.DontDestroyOnLoad(window);
            debugWindow = window.AddComponent <DebugWindow>();
            //#endif
#endif

            CullManager.Instance.Factor = 1.0f;

            QualitySetting.DeviceAdaptation();

            AssetResource ar = new AssetResource();
            // 加载混音设置
            yield return(GetGlobalMono().StartCoroutine(ResourceLoader.Instance.load_asset("Assets/Res/Sound/AudioMixer.mixer", typeof(UnityEngine.Object), ar)));

            AudioManager.Instance.InitMixer(ar.asset_ as AudioMixer);
            AudioSource audio = mCoreObject.AddComponent <AudioSource>();
            audio.playOnAwake           = true;
            audio.loop                  = true;
            audio.outputAudioMixerGroup = AudioManager.Instance.GetAudioMixerGroup("Music");


            BackGroundAudio backAudio = mCoreObject.AddComponent <BackGroundAudio>();
            backAudio.Init();

            if (Const.Language != LanguageType.SIMPLE_CHINESE)
            {
                string localizeData = LocalizeManager.Instance.GetLocalizationDataPath(Const.Language);
                yield return(GetGlobalMono().StartCoroutine(GameLocalizeHelper.CoLoadLocalizeFile(localizeData)));
            }

            // 加载Font
            ar = new AssetResource();
            yield return(GetGlobalMono().StartCoroutine(ResourceLoader.Instance.load_asset("Assets/Res/UI/Textures/Emoji/Output/emoji.txt", typeof(UnityEngine.Object), ar)));

            mEmojiTxt = ar.asset_;
            if (mEmojiTxt == null)
            {
                Debug.LogError("emmoji.txt load failed.");
            }
            ar = new AssetResource();
            yield return(GetGlobalMono().StartCoroutine(ResourceLoader.Instance.load_asset(EmojiText.GetEmojiTextName(EmojiText.EmojiMaterialType.EquipTips), typeof(UnityEngine.Object), ar)));

            mEmojiTxt_equipTips = ar.asset_;
            if (mEmojiTxt_equipTips == null)
            {
                Debug.LogError("emoji_equipTips.txt load failed.");
            }

            // 加载UIMain,程序中只加载一次
            PrefabResource pr = new PrefabResource();
            yield return(GetGlobalMono().StartCoroutine(ResourceLoader.Instance.load_prefab("Assets/Res/UI/Widget/Preset/UIRoot.prefab", pr, false)));

            pr.obj_.transform.position = new Vector3(0, 1000.0f, 0);
            GameObject.DontDestroyOnLoad(pr.obj_);
            mGame.Init();

            // 加载Start场景
            if (Game.Instance.IsSkillEditorScene)
            {
                var scene_asset_path = string.Format("Assets/Res/Map/scenes/{0}.unity", GlobalConst.DefaultTestScene);
                yield return(GetGlobalMono().StartCoroutine(ResourceLoader.Instance.load_scene(scene_asset_path, GlobalConst.DefaultTestScene, null)));
            }

            // destroy initscenloader
            GameObject.DestroyImmediate(NewInitSceneLoader.Instance.gameObject, true);

            // 初始化Game的状态机
            mGame.InitFSM();
            mGame.mIsInited = true;

            Application.targetFrameRate = Const.G_FPS;

            var fps_respond = mCoreObject.AddComponent <FPSRespond>();
            fps_respond.FPSUpdateWaitTime = 15.0f;

            var fps_notice = mCoreObject.AddComponent <FPSNotice>();

            // 预加载资源
            ControlServerLogHelper.Instance.PostPlayerFollowRecord(PlayerFollowRecordSceneId.PreloadResEnd);
            ControlServerLogHelper.Instance.PostCloudLadderEventAction(CloudLadderMarkEnum.load_res);

            // 向后台请求渠道信息列表和服务器列表
#if !UNITY_IPHONE
            ControlServerLogHelper.Instance.GetChannelList();
#endif
            ControlServerLogHelper.Instance.GetServerList();
        }