Esempio n. 1
0
        //After bindings are done, you sometimes want to do more stuff to configure your app.
        //Do that sort of stuff here.
        protected override void postBindings()
        {
            //Establish our camera. We do this early since it gets injected in places that help us do layout.
            Camera cam = (contextView as GameObject).GetComponentInChildren <Camera> ();

            if (cam == null)
            {
                throw new Exception("GameContext couldn't find the game camera");
            }
            injectionBinder.Bind <Camera> ().ToValue(cam).ToName(StrangeEtnixElement.GAME_CAMERA);

            // Configure the pools.
            // (Hint: all our pools for this game are identical, but for the content of the InstanceProvider)
            //Strange Pools by default "inflate" as necessary. This means that if you only
            //have one instance in the pool and require another, the pool will instantiate a second.
            //If you have two instances and need another, the pool will inflate again.
            //So long as you keep feeding instances back to the pool, there will always be enough instances,
            //and you'll never create more than you require.
            //The pool can use one of two inflation strategies:
            //1. DOUBLE (the default) is useful when your pool consists of objects that just exist in memory.
            //2. INCREMENT is better for onscreen objects as we're doing here. By INCREMENT-inflating, you'll
            //   get one new GameObject whenever you need one. This minimizes the necessary management of
            //   Views whenever the pool inflates.

            IGameConfig       gameConfig       = (IGameConfig)injectionBinder.GetInstance <IGameConfig>();
            IEnemyPoolManager enemyPoolManager = (IEnemyPoolManager)injectionBinder.GetInstance <IEnemyPoolManager>();

            if (gameConfig != null && enemyPoolManager != null)
            {
                IAssetConfig assectConfig = gameConfig.assetConfig;
                foreach (KeyValuePair <int, ICharAssetVO> asset in assectConfig.enemyAssetList)
                {
                    if (asset.Value != null)
                    {
                        enemyPoolManager.addPool(asset.Value);
                    }
                }
            }

            //Don't forget to call the base version...important stuff happens there!!!
            base.postBindings();

            if (Context.firstContext != this)
            {
                //Disable the AudioListener
                AudioListener listener = (contextView as GameObject).GetComponentInChildren <AudioListener> ();
                listener.enabled = false;
            }
        }
 public GameController(Contexts contexts, IGameConfig gameConfig, IAssetConfig assetConfig)
 {
     contexts.config.SetGameConfig(gameConfig);
     contexts.config.SetAssetConfig(assetConfig);
     _systems = new GameSystems(contexts);
 }