public void Init(IBootConfig bootConfig = null)
        {
            if (bootConfig == null)
            {
                bootConfig = new DefaultBootConfig();
            }

            _gameObject = new GameObject("GameContext");

            resourceStore = new ResourceStore();

            sceneDirector = _gameObject.AddComponent <SceneDirectorMock>();
            sceneDirector.Init(_gameObject, bootConfig, resourceStore);

            timeKeeper = new TimeKeeper(sceneDirector);

            bgmPlayer = new BgmPlayer();
            bgmPlayer.Init(_gameObject, bootConfig.numBgmSourcePool, sceneDirector, resourceStore);

            sePlayer = new SePlayer();
            sePlayer.Init(_gameObject, bootConfig.numSeSourcePool, sceneDirector, resourceStore);

            signalHub = new SignalHub(sceneDirector);

            tweenerHub = new TweenerHub(sceneDirector, timeKeeper);

            objectPoolHub = new ObjectPoolHub(sceneDirector);

            bootConfig.OnGameBoot();
        }
Пример #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.Q))
     {
         BgmPlayer.Init(Bgms);
         BgmPlayer.AutoPlay();
     }
     else if (Input.GetKey(KeyCode.R))
     {
         BgmPlayer.Release();
     }
 }
Пример #3
0
    /// <summary>
    /// 初始化,挂载舞台上
    /// </summary>
    /// <param name="root"></param>
    public static void InitRoot(Transform root)
    {
        if (_instance != null)
        {
            return;
        }

        GameObject go = new GameObject();

        go.name             = "SoundManager";
        go.transform.parent = root;
        _instance           = go.AddComponent <SoundManager>();

        _bgmPlayer = new BgmPlayer();
        _bgmPlayer.Init(go.transform);

        _soundPlayer = new SoundPlayer();
        _soundPlayer.Init(go.transform);
    }
Пример #4
0
        public void Init(IBootConfig bootConfig = null)
        {
            if (bootConfig == null)
            {
                bootConfig = new DefaultBootConfig();
            }

            _contextGameObj     = new GameObject("AltoGlobalContext");
            _audioSourceGameObj = new GameObject("AltoAudioSource");
            GameObject.DontDestroyOnLoad(_contextGameObj);
            GameObject.DontDestroyOnLoad(_audioSourceGameObj);

            resourceStore = new ResourceStore();

            sceneDirector = _contextGameObj.AddComponent <SceneDirector>();
            sceneDirector.Init(_contextGameObj, bootConfig, resourceStore);
            sceneDirector.sceneUpdate += OnSceneUpdate;

            timeKeeper = new TimeKeeper(sceneDirector);

            bgmPlayer = new BgmPlayer();
            bgmPlayer.Init(_audioSourceGameObj, bootConfig.numBgmSourcePool, sceneDirector, resourceStore);

            sePlayer = new SePlayer();
            sePlayer.Init(_audioSourceGameObj, bootConfig.numSeSourcePool, sceneDirector, resourceStore);

            if (bootConfig.useGlobalAudioListener)
            {
                _contextGameObj.AddComponent <AudioListener>();
            }

            signalHub = new SignalHub(sceneDirector);

            tweenerHub = new TweenerHub(sceneDirector, timeKeeper);

            objectPoolHub = new ObjectPoolHub(sceneDirector);

            bootConfig.OnGameBoot();
        }