Esempio n. 1
0
        void ICompositionRoot.OnContextCreated(UnityContext contextHolder)
        {
            var tasksCount = NumberOfEntities.value;

#if FIRST_TIER_EXAMPLE || SECOND_TIER_EXAMPLE || THIRD_TIER_EXAMPLE
            var boidDescriptor = new BoidEntityDescriptor(new[] { new Boid() });
#else
            var boidDescriptor = new BoidEntityDescriptor();
#endif
#if DONT_TRY_THIS_AT_HOME
            for (int i = 0; i < tasksCount; i++)
            {
                GameObject crazyness = new GameObject();
                crazyness.AddComponent <UnityWay>();
            }
#else
            IEnginesRoot   enginesRoot;
            IEntityFactory entityFactory = (enginesRoot = new EnginesRoot(new UnitySumbmissionNodeScheduler())) as IEntityFactory;

            var boidsEngine = new BoidsEngine();
            enginesRoot.AddEngine(boidsEngine);
            _contextNotifier.AddFrameworkDestructionListener(boidsEngine);

            for (int i = 0; i < tasksCount; i++)
            {
                entityFactory.BuildEntity(i, boidDescriptor);
            }

            entityFactory.BuildEntity(0, new GenericEntityDescriptor <PrintTimeNode>(contextHolder.GetComponentInChildren <PrintIteration>()));
#endif
        }
Esempio n. 2
0
        void ICompositionRoot.OnContextCreated(UnityContext contextHolder)
        {
#if FIRST_TIER_EXAMPLE || SECOND_TIER_EXAMPLE || THIRD_TIER_EXAMPLE || FOURTH_TIER_EXAMPLE
            var tasksCount = NumberOfEntities.value;
#if DONT_TRY_THIS_AT_HOME
            for (int i = 0; i < tasksCount; i++)
            {
                GameObject crazyness = new GameObject();
                crazyness.AddComponent <UnityWay>();
            }
#else
            _enginesRoot = new EnginesRoot(new Schedulers.Unity.UnitySumbmissionEntityViewScheduler());
            IEntityFactory entityFactory = _enginesRoot.GenerateEntityFactory();

            var boidsEngine = new BoidsEngine();
            _enginesRoot.AddEngine(boidsEngine);

            _contextNotifier.AddFrameworkDestructionListener(boidsEngine);
#if FIRST_TIER_EXAMPLE || SECOND_TIER_EXAMPLE || THIRD_TIER_EXAMPLE
            var implementorArray = new object[1];
#endif
            for (int i = 0; i < tasksCount; i++)
            {
#if FIRST_TIER_EXAMPLE || SECOND_TIER_EXAMPLE || THIRD_TIER_EXAMPLE
                implementorArray[0] = new Boid();
                entityFactory.BuildEntity <BoidEntityDescriptor>(i, implementorArray);
#else
                entityFactory.BuildEntity <BoidEntityDescriptor>(i);
#endif
            }

            entityFactory.BuildEntity <GUITextEntityDescriptor>(0,
                                                                contextHolder.GetComponentsInChildren <PrintIteration>());
#endif
#endif
        }