/// <summary>
        /// Initializes the Mixed Reality Extension SDK API.
        /// </summary>
        /// <param name="defaultMaterial">The material template used for all SDK-spawned meshes.</param>
        /// <param name="behaviorFactory">The behavior factory to use within the runtime.</param>
        /// <param name="textFactory">The text factory to use within the runtime.</param>
        /// <param name="primitiveFactory">The primitive factory to use within the runtime.</param>
        /// <param name="libraryFactory">The library resource factory to use within the runtime.</param>
        /// <param name="assetCache">The place for this MRE to cache its meshes, etc.</param>
        /// <param name="gltfImporterFactory">The glTF loader factory. Uses default GLTFSceneImporter if omitted.</param>
        /// <param name="materialPatcher">Overrides default material property map (color and mainTexture only).</param>
        /// <param name="userInfoProvider">Provides appId/sessionId scoped IUserInfo instances.</param>
        /// <param name="engineConstants">Engine constants supplied by the host app.</param>
        /// <param name="logger">The logger to be used by the MRE SDK.</param>
        public static void InitializeAPI(
            UnityEngine.Material defaultMaterial,
            IBehaviorFactory behaviorFactory       = null,
            ITextFactory textFactory               = null,
            IPrimitiveFactory primitiveFactory     = null,
            ILibraryResourceFactory libraryFactory = null,
            IAssetCache assetCache = null,
            IGLTFImporterFactory gltfImporterFactory = null,
            IMaterialPatcher materialPatcher         = null,
            IUserInfoProvider userInfoProvider       = null,
            IEngineConstants engineConstants         = null,
            IMRELogger logger = null)
        {
            AppsAPI.DefaultMaterial        = defaultMaterial;
            AppsAPI.BehaviorFactory        = behaviorFactory;
            AppsAPI.TextFactory            = textFactory ?? throw new ArgumentException($"{nameof(textFactory)} cannot be null");
            AppsAPI.PrimitiveFactory       = primitiveFactory ?? new MWPrimitiveFactory();
            AppsAPI.LibraryResourceFactory = libraryFactory;
            AppsAPI.AssetCache             = assetCache ?? new AssetCache();
            AppsAPI.GLTFImporterFactory    = gltfImporterFactory ?? new GLTFImporterFactory();
            AppsAPI.MaterialPatcher        = materialPatcher ?? new DefaultMaterialPatcher();
            AppsAPI.UserInfoProvider       = userInfoProvider ?? new NullUserInfoProvider();
            AppsAPI.EngineConstants        = engineConstants;

#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger();
#else
            Logger = logger ?? new ConsoleLogger();
#endif
        }
Esempio n. 2
0
 public PartialFactory(BehaviorGraph graph, IBehaviorFactory factory, ServiceArguments arguments, ICurrentChain currentChain)
 {
     _graph = graph;
     _factory = factory;
     _arguments = arguments;
     _currentChain = currentChain;
 }
        /// <summary>
        ///   Creates a new <see cref="BehaviorChainConfiguration"/> from this
        ///   template.
        /// </summary>
        // TODO: Comment.
        internal BehaviorChainConfiguration CreateConfiguration(
            IBehaviorFactoryConfiguration factoryConfiguration
            )
        {
            Check.NotNull(factoryConfiguration, nameof(factoryConfiguration));

            var config = new BehaviorChainConfiguration();
            IBehaviorFactory factory = factoryConfiguration.GetFactory(_factoryProvider);

            foreach (BehaviorChainItemTemplate itemTemplate in _itemTemplates)
            {
                BehaviorKey key = itemTemplate.Key;

                if (itemTemplate.State == DefaultBehaviorState.DisabledWithoutFactory)
                {
                    config.Append(key);
                }
                else
                {
                    IBehavior instance = factory.Create(key);
                    config.Append(key, instance);

                    if (itemTemplate.State == DefaultBehaviorState.Enabled)
                    {
                        config.Enable(key);
                    }
                }
            }

            return(config);
        }
        /// <summary>
        /// Initializes the Mixed Reality Extension SDK API.
        /// </summary>
        /// <param name="defaultMaterial">The material template used for all SDK-spawned meshes.</param>
        /// <param name="layerApplicator">The class used to apply MRE layers to Unity colliders.</param>
        /// <param name="behaviorFactory">The behavior factory to use within the runtime.</param>
        /// <param name="textFactory">The text factory to use within the runtime.</param>
        /// <param name="primitiveFactory">The primitive factory to use within the runtime.</param>
        /// <param name="libraryFactory">The library resource factory to use within the runtime.</param>
        /// <param name="gltfImporterFactory">The glTF loader factory. Uses default GLTFSceneImporter if omitted.</param>
        /// <param name="materialPatcher">Overrides default material property map (color and mainTexture only).</param>
        /// <param name="videoPlayerFactory"></param>
        /// <param name="userInfoProvider">Provides appId/sessionId scoped IUserInfo instances.</param>
        /// <param name="dialogFactory"></param>
        /// <param name="logger">The logger to be used by the MRE SDK.</param>
        public static void InitializeAPI(
            UnityEngine.Material defaultMaterial,
            ILayerApplicator layerApplicator,
            IBehaviorFactory behaviorFactory         = null,
            ITextFactory textFactory                 = null,
            IPrimitiveFactory primitiveFactory       = null,
            ILibraryResourceFactory libraryFactory   = null,
            IGLTFImporterFactory gltfImporterFactory = null,
            IMaterialPatcher materialPatcher         = null,
            IVideoPlayerFactory videoPlayerFactory   = null,
            IUserInfoProvider userInfoProvider       = null,
            IDialogFactory dialogFactory             = null,
            IMRELogger logger = null)
        {
            AppsAPI.DefaultMaterial        = defaultMaterial;
            AppsAPI.LayerApplicator        = layerApplicator;
            AppsAPI.BehaviorFactory        = behaviorFactory;
            AppsAPI.TextFactory            = textFactory ?? throw new ArgumentException($"{nameof(textFactory)} cannot be null");
            AppsAPI.PrimitiveFactory       = primitiveFactory ?? new MWPrimitiveFactory();
            AppsAPI.LibraryResourceFactory = libraryFactory;
            AppsAPI.VideoPlayerFactory     = videoPlayerFactory;
            AppsAPI.GLTFImporterFactory    = gltfImporterFactory ?? new GLTFImporterFactory();
            AppsAPI.MaterialPatcher        = materialPatcher ?? new DefaultMaterialPatcher();
            AppsAPI.UserInfoProvider       = userInfoProvider ?? new NullUserInfoProvider();
            AppsAPI.DialogFactory          = dialogFactory;

#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger(null);
#else
            Logger = logger ?? new ConsoleLogger(null);
#endif
        }
Esempio n. 5
0
        public IUnit CreateBlob(string name, int heatlh, int damage,
                                string behaviorType, string attackType,
                                IBehaviorFactory behavior, IAttackFactory attack)
        {
            var blob = new Blob(name, heatlh, damage, behaviorType, attackType, behavior, attack);

            return(blob);
        }
Esempio n. 6
0
 public Engine(IUserInterface userInterface, IAttackFactory attackFactory, IBlobFactory blobFactory, IBehaviorFactory behaviorFactory, IDatabase database)
 {
     this.userInterface = userInterface;
     this.attackFactory = attackFactory;
     this.blobFactory = blobFactory;
     this.behaviorFactory = behaviorFactory;
     this.database = database;
 }
        public void SetUp()
        {
            theFactory = MockRepository.GenerateMock<IBehaviorFactory>();

            var graph = setupActions();
            _actionIds = graph.Actions().Select(x => x.ParentChain().UniqueId);
            _routes = new StandardRoutePolicy().BuildRoutes(graph, theFactory).Cast<Route>();
        }
        public void SetUp()
        {
            theFactory = MockRepository.GenerateMock<IBehaviorFactory>();

            var graph = setupActions();
            _actionIds = graph.Actions().Select(x => x.ParentChain().UniqueId);
            _routes = new StandardRoutePolicy().BuildRoutes(graph, theFactory).Cast<Route>();
        }
Esempio n. 9
0
 public Engine(IUserInterface userInterface, IAttackFactory attackFactory, IBlobFactory blobFactory, IBehaviorFactory behaviorFactory, IDatabase database)
 {
     this.userInterface   = userInterface;
     this.attackFactory   = attackFactory;
     this.blobFactory     = blobFactory;
     this.behaviorFactory = behaviorFactory;
     this.database        = database;
 }
Esempio n. 10
0
        private IList <RouteBase> buildRoutes(IBehaviorFactory factory, BehaviorGraph graph)
        {
            var routes = new List <RouteBase>();

            // Build route objects from route definitions on graph + add packaging routes
            _facility.Value.Get <IRoutePolicy>().BuildRoutes(graph, factory).Each(routes.Add);

            return(routes);
        }
        public DefaultBehaviorProvider(IImplicitBehaviorRegistry implicitBehaviors,
                                       IBehaviorFactory behaviorFactory)
        {
            this.implicitBehaviors = implicitBehaviors ??
                                     throw new ArgumentNullException(nameof(implicitBehaviors));

            this.behaviorFactory = behaviorFactory ??
                                   throw new ArgumentNullException(nameof(behaviorFactory));
        }
Esempio n. 12
0
 public Engine(IBlockFactory blobFactory, IAttackFactory attackFactory,
     IBehaviorFactory behaviorFactory, IReader reader, IWriter writer, IData data)
 {
     this.blobFactory = blobFactory;
     this.attackFactory = attackFactory;
     this.behaviorFactory = behaviorFactory;
     this.reader = reader;
     this.writer = writer;
     this.data = data;
 }
Esempio n. 13
0
 public Engine(IRenderer renderer, IInputController inputController,  ICommandFactory commandFactory, IBlobFactory blobFactory, IAttackFactory attackFactory, IBehaviorFactory behaviorFactory)
 {
     this.renderer = renderer;
     this.inputController = inputController;
     this.CommandFactory = commandFactory;
     this.blobs = new List<IBlob>();
     this.BlobFactory = blobFactory;
     this.AttackFactory = attackFactory;
     this.BehaviorFactory = behaviorFactory;
 }
Esempio n. 14
0
 public BlobEngine(IBlobFactory blobFactory, IAttackFactory attackFactory, IBehaviorFactory behaviorFactory,
     IData data, IInputReader reader, IOutputWriter writer)
 {
     this.blobFactory = blobFactory;
     this.attackFactory = attackFactory;
     this.behaviorFactory = behaviorFactory;
     this.data = data;
     this.reader = reader;
     this.writer = writer;
 }
        public override void Initialize()
        {
            foreach (var behavior in behaviors)
                behavior.Value.Initialize();

            actionManager = GameServiceManager.GetService<IActionManager>();
            ActionFactory = GameServiceManager.GetService<IActionFactory>();
            behaviorFactory = GameServiceManager.GetService<IBehaviorFactory>();

            base.Initialize();
        }
Esempio n. 16
0
        public IList <RouteBase> Bootstrap()
        {
            if (HttpContext.Current != null)
            {
                UrlContext.Live();
            }

            _fubuFacility = new FubuMvcPackageFacility();

            IBehaviorFactory factory = null;
            BehaviorGraph    graph   = null;

            // TODO -- I think Bottles probably needs to enforce a "tell me the paths"
            // step maybe
            PackageRegistry.GetApplicationDirectory = FubuMvcPackageFacility.GetApplicationPath;
            BottleFiles.ContentFolder  = FubuMvcPackageFacility.FubuContentFolder;
            BottleFiles.PackagesFolder = FubuMvcPackageFacility.FubuPackagesFolder;

            PackageRegistry.LoadPackages(x =>
            {
                x.Facility(_fubuFacility);
                _packagingDirectives.Each(d => d(x));


                x.Bootstrap(log =>
                {
                    // container facility has to be spun up here
                    var containerFacility = _facility.Value;

                    registerServicesFromFubuFacility();

                    applyRegistryModifications();

                    applyFubuExtensionsFromPackages();

                    graph = buildBehaviorGraph();

                    bakeBehaviorGraphIntoContainer(graph, containerFacility);

                    // factory HAS to be spun up here.
                    factory = containerFacility.BuildFactory(_registry.Value.DiagnosticLevel);
                    if (_registry.Value.DiagnosticLevel == DiagnosticLevel.FullRequestTracing)
                    {
                        factory = new DiagnosticBehaviorFactory(factory, containerFacility);
                    }

                    return(containerFacility.GetAllActivators());
                });
            });

            PackageRegistry.AssertNoFailures();

            return(buildRoutes(factory, graph));
        }
Esempio n. 17
0
        public Engine(IBlobFactory blobFactory, IAttackFactory attackFactory, IBehaviorFactory behaviorFactory,
                      IInputReader reader, IOutputWriter writer, IBlobData blobData)
        {
            this.blobFactory     = blobFactory;
            this.attackFactory   = attackFactory;
            this.behaviorFactory = behaviorFactory;
            this.reader          = reader;
            this.writer          = writer;
            this.blobData        = blobData;

            this.shouldReportEvents = false;
        }
Esempio n. 18
0
        public FubuRuntime Bootstrap()
        {
            SetupNamingStrategyForHttpHeaders();

            _fubuFacility = new FubuMvcPackageFacility();

            IBehaviorFactory factory = null;
            BehaviorGraph    graph   = null;

            // TODO -- I think Bottles probably needs to enforce a "tell me the paths"
            // step maybe
            PackageRegistry.GetApplicationDirectory = FubuMvcPackageFacility.GetApplicationPath;
            BottleFiles.ContentFolder  = FubuMvcPackageFacility.FubuContentFolder;
            BottleFiles.PackagesFolder = FileSystem.Combine("bin", FubuMvcPackageFacility.FubuPackagesFolder);

            Console.WriteLine("PackageRegistry.ApplicationDirectory:  " + PackageRegistry.GetApplicationDirectory());
            Console.WriteLine("BottleFiles.ContentFolder:  " + BottleFiles.ContentFolder);
            Console.WriteLine("BottleFiles.PackagesFolder:  " + BottleFiles.PackagesFolder);

            PackageRegistry.LoadPackages(x =>
            {
                x.Facility(_fubuFacility);
                _packagingDirectives.Each(d => d(x));


                x.Bootstrap(log =>
                {
                    // container facility has to be spun up here
                    var containerFacility = _facility.Value;

                    applyRegistryModifications();

                    applyFubuExtensionsFromPackages(log);

                    graph = buildBehaviorGraph();

                    bakeBehaviorGraphIntoContainer(graph, containerFacility);

                    // factory HAS to be spun up here.
                    factory = containerFacility.BuildFactory();

                    return(containerFacility.GetAllActivators());
                });
            });

            PackageRegistry.AssertNoFailures();

            var routes = buildRoutes(factory, graph);

            routes.Each(r => RouteTable.Routes.Add(r));

            return(new FubuRuntime(factory, _facility.Value, routes));
        }
Esempio n. 19
0
        public RouteBase BuildRoute(IBehaviorFactory factory, SessionStateRequirement defaultSessionRequirement, BehaviorChain chain)
        {
            var requiresSession = chain.Route.SessionStateRequirement ?? defaultSessionRequirement;

            var route         = chain.Route.ToRoute();
            var handlerSource = DetermineHandlerSource(requiresSession, chain);
            var invoker       = DetermineInvoker(factory, chain);

            route.RouteHandler = new FubuRouteHandler(invoker, handlerSource);

            return(route);
        }
        public Engine(IBlobFactory blobFactory, IAttackFactory attackFactory, IBehaviorFactory behaviorFactory,
            IInputReader reader, IOutputWriter writer, IBlobData blobData)
        {
            this.blobFactory = blobFactory;
            this.attackFactory = attackFactory;
            this.behaviorFactory = behaviorFactory;
            this.reader = reader;
            this.writer = writer;
            this.blobData = blobData;

            this.shouldReportEvents = false;
        }
Esempio n. 21
0
        public RouteBase BuildRoute(IBehaviorFactory factory, SessionStateRequirement defaultSessionRequirement, BehaviorChain chain)
        {
            var requiresSession = chain.Route.SessionStateRequirement ?? defaultSessionRequirement;

            var route = chain.Route.ToRoute();
            var handlerSource = DetermineHandlerSource(requiresSession, chain);
            var invoker = DetermineInvoker(factory, chain);

            route.RouteHandler = new FubuRouteHandler(invoker, handlerSource);

            return route;
        }
        public override void Deserialize(XElement element)
        {
            IEnumerable <XElement> behaviorElements = element.Element("behaviors").Elements("behavior");

            behaviorFactory = GameServiceManager.GetService <IBehaviorFactory>();

            foreach (var behaviorElement in behaviorElements)
            {
                var behavior = behaviorFactory.LoadBehaviorFromXML(behaviorElement);
                AddBehavior(behavior);
            }
        }
Esempio n. 23
0
 public Engine(
     IBlobFactory blobFactory,
     IAttackFactory attackFactory,
     IBehaviorFactory behaviorFactory,
     IInputReader reader,
     IOutputWriter outputWriter)
 {
     this.BlobFactory     = blobFactory;
     this.AttackFactory   = attackFactory;
     this.BehaviorFactory = behaviorFactory;
     this.InputReader     = reader;
     this.OutputWriter    = outputWriter;
 }
Esempio n. 24
0
        public IBlob CreateBlob(
            string name,
            int health,
            int damage,
            string attackType,
            string behaviourType,
            IAttackFactory attackFactory,
            IBehaviorFactory behaviorFactory)
        {
            var blob = new Blob(name, damage, health, attackType, behaviourType, attackFactory, behaviorFactory);

            return blob;
        }
Esempio n. 25
0
    public IBlob CreateBlob(
        string name,
        int health,
        int damage,
        string attackType,
        string behaviourType,
        IAttackFactory attackFactory,
        IBehaviorFactory behaviorFactory)
    {
        IBlob blob = new Blob(name, damage, health, attackType, behaviourType, attackFactory, behaviorFactory);

        return(blob);
    }
Esempio n. 26
0
 public Engine(
     IBlobFactory blobFactory,
     IAttackFactory attackFactory,
     IBehaviorFactory behaviorFactory,
     IInputReader reader,
     IOutputWriter outputWriter)
 {
     this.BlobFactory = blobFactory;
     this.AttackFactory = attackFactory;
     this.BehaviorFactory = behaviorFactory;
     this.InputReader = reader;
     this.OutputWriter = outputWriter;
 }
        public override void Initialize()
        {
            foreach (var behavior in behaviors)
            {
                behavior.Value.Initialize();
            }

            actionManager   = GameServiceManager.GetService <IActionManager>();
            ActionFactory   = GameServiceManager.GetService <IActionFactory>();
            behaviorFactory = GameServiceManager.GetService <IBehaviorFactory>();

            base.Initialize();
        }
Esempio n. 28
0
 public Engine(
     IReader reader,
     IWriter writer,
     IBlobFactory blobFactory,
     IBehaviorFactory behaviorFactory,
     IAttackFactory attackFactory)
 {
     this.reader          = reader;
     this.Writer          = writer;
     this.blobFactory     = blobFactory;
     this.behaviorFactory = behaviorFactory;
     this.attackFactory   = attackFactory;
     this.blobs           = new Dictionary <string, IUnit>();
 }
Esempio n. 29
0
 public IList<RouteBase> BuildRoutes(BehaviorGraph graph, IBehaviorFactory factory)
 {
     var routes = new List<RouteBase>();
     graph.VisitRoutes(x =>
     {
         x.Actions += (routeDef, chain) =>
         {
             var route = routeDef.ToRoute();
             route.RouteHandler = new FubuRouteHandler(factory, chain.UniqueId);
             routes.Add(route);
         };
     });
     return routes;
 }
 public BlobsEngine(IBlobFactory blobFactory,
     IAttackFactory attackFactory,
     IBehaviorFactory behaviorFactory,
     IBlobsData blobsData,
     IInputReader inputReader,
     IOutputWriter outputWriter)
 {
     this.blobFactory = blobFactory;
     this.attackFactory = attackFactory;
     this.behaviorFactory = behaviorFactory;
     this.blobsData = blobsData;
     this.inputReader = inputReader;
     this.outputWriter = outputWriter;
 }
Esempio n. 31
0
        public BleDeviceBase(IDevice device, T id, IDeviceClassProtocol <T> deviceClassProtocol, IBleInfrastructure bleInfrastructure)
        {
            DeviceId        = id;
            BehaviorFactory = new DeviceBehaviorFactory(this, bleInfrastructure.Executor, bleInfrastructure.Logger);

            _device            = device;
            _bleInfrastructure = bleInfrastructure;

            _deviceSearchFilter = new SpecificDeviceFilter <T>(id, deviceClassProtocol);

            _deviceCharacteristics = CreateCharacteristics(deviceClassProtocol, _bleInfrastructure.CharacteristicFactory,
                                                           _bleInfrastructure.ExecutionProvider);

            _bleInfrastructure.ConnectionManager.AddListener(this);
        }
Esempio n. 32
0
        public IList <RouteBase> BuildRoutes(BehaviorGraph graph, IBehaviorFactory factory)
        {
            var routes = new List <RouteBase>();

            graph.VisitRoutes(x =>
            {
                x.Actions += (routeDef, chain) =>
                {
                    var route          = routeDef.ToRoute();
                    route.RouteHandler = new FubuRouteHandler(factory, chain.UniqueId);
                    routes.Add(route);
                };
            });
            return(routes);
        }
Esempio n. 33
0
 public IList<RouteBase> BuildRoutes(BehaviorGraph graph, IBehaviorFactory factory)
 {
     var routes = new List<RouteBase>();
     graph.VisitRoutes(x =>
     {
         x.BehaviorFilters += chain => !chain.IsPartialOnly;
         x.Actions += (routeDef, chain) =>
         {
             var route = routeDef.ToRoute();
             route.RouteHandler = new FubuRouteHandler(new BehaviorInvoker(factory, chain));
             routes.Add(route);
         };
     });
     return routes;
 }
 public IList<RouteBase> BuildRoutes(BehaviorGraph graph, IBehaviorFactory factory)
 {
     var routes = new List<RouteBase>();
     graph.VisitRoutes(x =>
     {
         x.BehaviorFilters += chain => !chain.IsPartialOnly;
         x.Actions += (routeDef, chain) =>
         {
             var route = routeDef.ToRoute();
             var transportationRoute = new TransportationRoute(route, new BehaviorInvoker(factory, chain), chain.InputType());
             routes.Add(transportationRoute);
         };
     });
     return routes;
 }
Esempio n. 35
0
        public IList <RouteBase> BuildRoutes(BehaviorGraph graph, IBehaviorFactory factory)
        {
            var routes = new List <RouteBase>();

            graph.VisitRoutes(x =>
            {
                x.BehaviorFilters += chain => !chain.IsPartialOnly;
                x.Actions         += (routeDef, chain) =>
                {
                    var route          = routeDef.ToRoute();
                    route.RouteHandler = new FubuRouteHandler(new BehaviorInvoker(factory, chain));
                    routes.Add(route);
                };
            });
            return(routes);
        }
Esempio n. 36
0
 public Blob(string name, int health, int damage,
             string behaviorType, string attackType,
             IBehaviorFactory behaviorFactory, IAttackFactory attackFactory)
 {
     this.Name                = name;
     this.Health              = health;
     this.Damage              = damage;
     this.BehaviorType        = behaviorType;
     this.AttackType          = attackType;
     this.behaviorFactory     = behaviorFactory;
     this.attackFactory       = attackFactory;
     this.initialHealth       = health;
     this.isBehaviorActivated = false;
     this.IsBahaviuorIsDone   = false;
     this.isMoreThanOneUpdate = false;
 }
        public void SetUp()
        {
            theFactory = MockRepository.GenerateMock <IBehaviorFactory>();
            theChain   = new BehaviorChain()
            {
                Route = new RouteDefinition("something")
            };

            theRouteData = new Dictionary <string, object>();

            theArguments = new ServiceArguments();
            theBehavior  = MockRepository.GenerateMock <IActionBehavior>();

            theFactory.Stub(x => x.BuildBehavior(theArguments, theChain.UniqueId))
            .Return(theBehavior);

            theInvoker = new AsyncBehaviorInvoker(theFactory, theChain);
        }
Esempio n. 38
0
 public Blob(
     string name,
     int damage,
     int health,
     string attackType,
     string behaviorType,
     IAttackFactory attackFactory,
     IBehaviorFactory behaviorFactory)
 {
     this.Name            = name;
     this.Damage          = damage;
     this.Health          = health;
     this.initialHealth   = health;
     this.AttackType      = attackType;
     this.BehaviorType    = behaviorType + BehaviorSuffix;
     this.AttackFactory   = attackFactory;
     this.BehaviorFactory = behaviorFactory;
 }
Esempio n. 39
0
 public Blob(
     string name,
     int damage,
     int health,
     string attackType,
     string behaviorType,
     IAttackFactory attackFactory,
     IBehaviorFactory behaviorFactory)
 {
     this.Name = name;
     this.Damage = damage;
     this.Health = health;
     this.initialHealth = health;
     this.AttackType = attackType;
     this.BehaviorType = behaviorType + BehaviorSuffix;
     this.AttackFactory = attackFactory;
     this.BehaviorFactory = behaviorFactory;
 }
        public void SetUp()
        {
            theFactory = MockRepository.GenerateMock<IBehaviorFactory>();
            theChain = new BehaviorChain()
            {
                Route = new RouteDefinition("something")
            };

            theRouteData = new Dictionary<string, object>();

            theArguments = new ServiceArguments();
            theBehavior = MockRepository.GenerateMock<IActionBehavior>();

            theFactory.Stub(x => x.BuildBehavior(theArguments, theChain.UniqueId))
                .Return(theBehavior);

            theInvoker = new AsyncBehaviorInvoker(theFactory, theChain);
        }
        /// <summary>
        /// Initializes the Mixed Reality Extension SDK API.
        /// </summary>
        /// <param name="defaultMaterial">The material template used for all SDK-spawned meshes.</param>
        /// <param name="layerApplicator">The class used to apply MRE layers to Unity colliders.</param>
        /// <param name="assetCache">The class responsible for long-term asset caching.</param>
        /// <param name="textFactory">The text factory to use within the runtime.</param>
        /// <param name="permissionManager">The instance responsible for presenting users with permission requests.</param>
        /// <param name="behaviorFactory">The behavior factory to use within the runtime.</param>
        /// <param name="dialogFactory"></param>
        /// <param name="libraryFactory">The library resource factory to use within the runtime.</param>
        /// <param name="videoPlayerFactory"></param>
        /// <param name="primitiveFactory">The primitive factory to use within the runtime.</param>
        /// <param name="gltfImporterFactory">The glTF loader factory. Uses default GLTFSceneImporter if omitted.</param>
        /// <param name="materialPatcher">Overrides default material property map (color and mainTexture only).</param>
        /// <param name="userInfoProvider">Provides appId/sessionId scoped IUserInfo instances.</param>
        /// <param name="logger">The logger to be used by the MRE SDK.</param>
        public static void InitializeAPI(
            // required properties
            SpatialMaterial defaultMaterial,
            ILayerApplicator layerApplicator,
            IAssetCache assetCache,
            ITextFactory textFactory,
            IPermissionManager permissionManager,
            // missing features if omitted
            IBehaviorFactory behaviorFactory = null,
            //IDialogFactory dialogFactory = null,
            ILibraryResourceFactory libraryFactory = null,
            //IVideoPlayerFactory videoPlayerFactory = null,
            // reasonable defaults provided
            IPrimitiveFactory primitiveFactory       = null,
            IGLTFImporterFactory gltfImporterFactory = null,
            IMaterialPatcher materialPatcher         = null,
            IMRELogger logger = null)
        {
            // required properties
            AppsAPI.DefaultMaterial   = defaultMaterial;
            AppsAPI.LayerApplicator   = layerApplicator;
            AppsAPI.AssetCache        = assetCache;
            AppsAPI.TextFactory       = textFactory;
            AppsAPI.PermissionManager = permissionManager;

            // missing features if omitted
            AppsAPI.BehaviorFactory = behaviorFactory;
            //AppsAPI.DialogFactory = dialogFactory;
            AppsAPI.LibraryResourceFactory = libraryFactory;
            //AppsAPI.VideoPlayerFactory = videoPlayerFactory;

            // reasonable defaults provided
            AppsAPI.PrimitiveFactory    = primitiveFactory ?? new MWPrimitiveFactory();
            AppsAPI.GLTFImporterFactory = gltfImporterFactory ?? new GLTFImporterFactory();
            AppsAPI.MaterialPatcher     = materialPatcher ?? new DefaultMaterialPatcher();

#if ANDROID_DEBUG
            Logger = logger ?? new UnityLogger(null);
#else
            Logger = logger ?? new ConsoleLogger(null);
#endif
        }
Esempio n. 42
0
        public Blob(string name, int health, int damage, 
            IAttackFactory attackFactory, IBehaviorFactory behaviorFactory, 
            string attackType, string behaviorType)
        {
            this.Name = name;
            this.Health = health;
            this.Damage = damage;

            this.attackFactory = attackFactory;
            this.behaviorFactory = behaviorFactory;

            this.attack = this.attackFactory.DefineAttack(attackType);
            this.behavior = this.behaviorFactory.DefineBehavior(behaviorType);

            this.initialHealth = health;
            this.initialDamage = damage;

            this.hasTriggeredBehavior = false;
            this.concecutiveBehaviorDeley = DeffaultConcecutiveBehaviorDeley;
        }
        public override void Reallocate()
        {
            //foreach (var behavior in behaviors)
            //{
            //    behavior.Value.Reallocate();
            //}

            //foreach (var behavior in behaviorsToRemove)
            //{
            //    behavior.Reallocate();
            //}

            //behaviors.Clear();
            //behaviorsToRemove.Clear();
            stateComponent  = null;
            behaviorFactory = null;
            actionManager   = null;

            base.Reallocate();
        }
Esempio n. 44
0
 public BehaviorInvoker(IBehaviorFactory factory, BehaviorChain chain)
 {
     _factory = factory;
     _chain = chain;
 }
Esempio n. 45
0
 public IList<RouteBase> BuildRoutes(BehaviorGraph graph, IBehaviorFactory factory)
 {
     var defaultSessionRequirement = graph.Settings.Get<SessionStateRequirement>();
     return graph.Behaviors.Where(x => x.Route != null).OrderBy(x => x.Route.Rank).Select(x => BuildRoute(factory, defaultSessionRequirement, x)).ToList();
 }
Esempio n. 46
0
 public static IBehaviorInvoker DetermineInvoker(IBehaviorFactory factory, BehaviorChain chain)
 {
     return(chain.IsAsynchronous() ? new AsyncBehaviorInvoker(factory, chain) : new BehaviorInvoker(factory, chain));
 }
Esempio n. 47
0
 public BehaviorInvoker(IBehaviorFactory factory, BehaviorChain chain)
 {
     _factory = factory;
     _chain   = chain;
 }
Esempio n. 48
0
 public PartialFactory(BehaviorGraph graph, IBehaviorFactory factory, ServiceArguments arguments)
 {
     _graph = graph;
     _factory = factory;
     _arguments = arguments;
 }
Esempio n. 49
0
 public ChainAuthorizor(IFubuRequest request, IBehaviorFactory factory, ITypeResolver types)
 {
     _request = request;
     _factory = factory;
     _types   = types;
 }
Esempio n. 50
0
 public FubuRuntime(IBehaviorFactory factory, IContainerFacility facility, IList <RouteBase> routes)
 {
     _factory  = factory;
     _facility = facility;
     _routes   = routes;
 }
 public AuthorizationRulesColumn(IBehaviorFactory factory)
 {
     _factory = factory;
 }
Esempio n. 52
0
 public PartialFactory(IBehaviorFactory factory, ServiceArguments arguments, ICurrentChain currentChain)
 {
     _factory = factory;
     _arguments = arguments;
     _currentChain = currentChain;
 }
        public void SetUp()
        {
            container = new Container(x =>
            {
                x.For<IFileSystem>().Use<FileSystem>();
                x.For<IStreamingData>().Use(MockRepository.GenerateMock<IStreamingData>());
                x.For<IHttpWriter>().Use(new NulloHttpWriter());
                x.For<ICurrentChain>().Use(new CurrentChain(null, null));
                x.For<ICurrentHttpRequest>().Use(new StubCurrentHttpRequest{
                    TheApplicationRoot = "http://server"
                });

                x.For<IResourceHash>().Use(MockRepository.GenerateMock<IResourceHash>());
            });

            container.Configure(x => x.For<IContainerFacility>().Use<StructureMapContainerFacility>());

            graph = BehaviorGraph.BuildFrom(x =>
            {
                x.Route("/area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("/area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("/area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>();

                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));
            });

            facility = new StructureMapContainerFacility(container);
            graph.As<IRegisterable>().Register(facility.Register);

            factory = facility.BuildFactory();
        }
 public DiagnosticBehaviorFactory(IBehaviorFactory inner, IContainerFacility container)
 {
     _inner = inner;
     _container = container;
 }
 public AuthorizationDescriptor(IBehaviorFactory factory)
 {
     _factory = factory;
 }
Esempio n. 56
0
 public BehaviorGraphWriter(BehaviorGraph graph, IUrlRegistry urls, IBehaviorFactory factory, ICurrentHttpRequest httpRequest)
 {
     _graph = graph;
     _urls = urls;
     _factory = factory;
     _httpRequest = httpRequest;
     _diagnosticsNamespace = GetType().Namespace;
 }
        public void SetUp()
        {
            container = new Container();
            graph = new FubuRegistry(x =>
            {
                x.Route<InputModel>("/area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route<InputModel>("/area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route<InputModel>("/area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();
                x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>();
            }).BuildGraph();

            facility = new StructureMapContainerFacility(container);
            graph.EachService(facility.Register);

            factory = facility.BuildFactory();
        }
        public void SetUp()
        {
            container = new Container(x => x.For<IFileSystem>().Use<FileSystem>());

            graph = new FubuRegistry(x =>
            {
                x.Route("/area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("/area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("/area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Models.ConvertUsing<ExampleConverter>().ConvertUsing<ExampleConverter2>();

                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));
                x.Services(s => s.AddService<IActivator>(new StubActivator()));

            }).BuildGraph();

            facility = new StructureMapContainerFacility(container);
            graph.As<IRegisterable>().Register(facility.Register);

            factory = facility.BuildFactory(DiagnosticLevel.None);
        }
Esempio n. 59
0
 public FubuRouteHandler(IBehaviorFactory factory, Guid behaviorId)
 {
     _factory    = factory;
     _behaviorId = behaviorId;
 }
Esempio n. 60
0
 public FubuRouteHandler(IBehaviorFactory factory, Guid behaviorId)
 {
     _factory = factory;
     _behaviorId = behaviorId;
 }