Exemplo n.º 1
0
        public override void InstallBindings()
        {
            // シーン読み込みに関する処理群を Install
            //   Generics ナシの SceneInstall の場合 SimpleLoaderUseCase が Bind される
            //   PreLoad/PostUnload の設定を流し込みたいので StrategicLoaderUseCase を用いる
            SceneInstaller <StrategicLoaderUseCase> .Install(Container);

            // ココは再帰的にやらないとダメかも
            Container.QueueForInject(SceneStrategyList);

            // 初期シーン一覧を Bind
            //   CAFU.Scene 的に必要
            Container
            .Bind <IEnumerable <string> >()
            .WithId(CAFU.Scene.Application.Constant.InjectId.InitialSceneNameList)
            .FromInstance(
                Enumerable
                .Range(0, SceneManager.sceneCount)
                .Select(SceneManager.GetSceneAt)
                .Select(x => x.name)
                );
            // シーン読み込み戦略データを Bind
            //   PreLoad/PostUnload の設定を仕込む
            Container
            .Bind <IDictionary <string, ISceneStrategy> >()
            .WithId(CAFU.Scene.Application.Constant.InjectId.UseCase.SceneStrategyMap)
            .FromInstance(SceneStrategyList.AsDictionary());

            // Controllers
            Container.BindInterfacesTo <Controller>().FromComponentOnRoot().AsCached();
        }
Exemplo n.º 2
0
        private void Start()
        {
            if (_sceneInstaller != null)
            {
                _sceneInstaller.Install();
            }

            if (_sceneInstaller.Base != null)
            {
                _sceneInstaller.Base.Damaged   += OnBaseDamaged;
                _sceneInstaller.Base.Destroyed += OnBaseDestroyed;

                if (_uiManager != null)
                {
                    _uiManager.UpdateHealth(_sceneInstaller.Base.Health, _sceneInstaller.Base.MaxHealth);
                }
            }

            if (_unitsController != null)
            {
                _unitsController.UnitDestroyed += OnUnitsControllerUnitDestroyed;
            }

            if (_uiManager != null)
            {
                _uiManager.UpdateGold(_collectedGold);

                _uiManager.Upgraded  += OnUiManagerUpgraded;
                _uiManager.Restarted += OnUiManagerRestarted;
            }

            if (_towersController != null)
            {
                _towersController.TowerSelected += OnTowersControllerTowerSelected;
                _towersController.TowerUpgraded += OnTowersControllerTowerUpgraded;
            }

            StartGame();
        }