/// <summary>
        /// Generates a random underground world.
        /// </summary>
        /// <param name="contentProvider">
        /// The content provider.
        /// </param>
        /// <param name="notifyWorldChangeRequested">
        /// The notify world change requested.
        /// </param>
        /// <returns>
        /// A random underground world.
        /// </returns>
        public static WorldData Make(ContentProvider contentProvider, INotifyWorldChangeRequested notifyWorldChangeRequested)
        {
            var boundary = new Rectangle(0, 0, 40, 30);

            var surfaceData = new List<GameEntityBase>();

            // depth
            // NOTE underworld generator doesn't generate top 2 rows
            for (var i = boundary.Top + 2; i < boundary.Height; i++)
            {
                // breadth
                for (var j = boundary.Left; j < boundary.Width; j++)
                {
                    surfaceData.Add(TerrainGenerator.MakeUnderground(contentProvider, new Point(j, i)));
                }
            }

            var player = YellowAntEntity.Create(contentProvider, new Point(5, 1), notifyWorldChangeRequested);

            var spriteData = new List<GameEntityBase> { player };

            var cpuSpriteData = new List<GameEntityBase>();

            return new WorldData(surfaceData, spriteData, cpuSpriteData, player, boundary);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ScreenControlHost"/> class.
        /// </summary>
        /// <param name="worldManager">
        /// The world Manager.
        /// </param>
        /// <param name="contentProvider">
        /// The content provider.
        /// </param>
        /// <param name="worldBoundary">
        /// The world Boundary.
        /// </param>
        public ScreenControlHost(IWorldManager worldManager, ContentProvider contentProvider, Rectangle worldBoundary)
        {
            this.worldManager = worldManager;

            // TODO state machine flips between screens
            // TODO subscribe to engine change events
            this.screens = new List<IScreen>();
            this.screens.Add(new OverworldScreen(worldManager, contentProvider, worldBoundary));

            // this.screens.Add(new UndergroundScreen(contentProvider));
            this.currentEngine = 0;
        }
        /// <summary>
        /// Creates a new yellow ant entity.
        /// </summary>
        /// <param name="contentProvider">
        /// The content provider.
        /// </param>
        /// <param name="position">
        /// The position.
        /// </param>
        /// <returns>
        /// A yellow ant.
        /// </returns>
        public static GameEntityBase Create(ContentProvider contentProvider, Point position)
        {
            var animation = new Texture2D[2];
            animation[0] = contentProvider.GetSpriteTexture(SpriteResource.YellowAntWalk1);
            animation[1] = contentProvider.GetSpriteTexture(SpriteResource.YellowAntWalk2);

            // apply interactive elements first
            var baseEntity = new GameEntityBase(EntityType.Ant, new Rectangle(position.X, position.Y, 1, 1), Player.Black);
            baseEntity = new PrecisionMovingEntity(baseEntity);
            baseEntity = new AnimationRenderEntity(baseEntity, animation);
            baseEntity = new CollisionBarrierEntity(baseEntity);
            return new InteractionEffectEntity(baseEntity);
        }
        /*
         * Methods
         */
        public Interface(DeviceController.IController controller,
                          ContentProvider.Providers providers)
        {
            Controller = controller;
            Providers = providers;
            Clients = new Dictionary<IWebClient, IDevice>();
            KnownDevices = new Dictionary<string, IDevice>();

            WebSocketManager = new WebSocket.Manger(WEBSOCKET_PORT);
            WebSocketManager.ClientConnect += HandleClientConnect;
            WebSocketManager.ClientDisconnect += HandleClientDisconnect;
            WebSocketManager.ClientMessage += HandleClientMessage;

            Controller.DeviceDiscovery += HandleDeviceDiscovery;
        }
Beispiel #5
0
        public void BeforeTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment setup -----");

            // Set environment directory to Duality binary directory
            this.oldEnvDir = Environment.CurrentDirectory;
            string codeBaseURI  = typeof(DualityApp).Assembly.CodeBase;
            string codeBasePath = codeBaseURI.StartsWith("file:") ? codeBaseURI.Remove(0, "file:".Length) : codeBaseURI;

            codeBasePath = codeBasePath.TrimStart('/');
            Environment.CurrentDirectory = Path.GetDirectoryName(codeBasePath);

            // Add some Console logs manually for NUnit
            if (!Log.Game.Outputs.OfType <ConsoleLogOutput>().Any())
            {
                Log.Game.AddOutput(new ConsoleLogOutput(ConsoleColor.DarkGray));
                Log.Core.AddOutput(new ConsoleLogOutput(ConsoleColor.DarkBlue));
                Log.Editor.AddOutput(new ConsoleLogOutput(ConsoleColor.DarkMagenta));
            }

            // Initialize Duality
            DualityApp.Init(DualityApp.ExecutionEnvironment.Launcher, DualityApp.ExecutionContext.Game);

            // Manually register pseudo-plugin for the Unit Testing Assembly
            DualityApp.AddPlugin(typeof(DualityTestsPlugin).Assembly, codeBasePath);

            // Create a dummy window, to get access to all the device contexts
            if (this.dummyWindow == null)
            {
                this.dummyWindow = new GameWindow(800, 600);
                this.dummyWindow.Context.LoadAll();
                this.dummyWindow.Visible = true;
                this.dummyWindow.Context.Update(this.dummyWindow.WindowInfo);
                this.dummyWindow.MakeCurrent();
                this.dummyWindow.ProcessEvents();
                DualityApp.TargetResolution = new Vector2(this.dummyWindow.Width, this.dummyWindow.Height);
                DualityApp.TargetMode       = this.dummyWindow.Context.GraphicsMode;
                ContentProvider.InitDefaultContent();
            }

            Console.WriteLine("----- Duality environment setup complete -----");
        }
    void OnGUI()
    {
        if(manager == null) {
            Type asset = Type.GetType("AccessorManager");
            if(asset == null) return;
            manager = (IAccessorManager) Activator.CreateInstance(asset);
        }

        GameObject gameObject = Selection.activeGameObject;
        if(!gameObject){
            return;
        }

        TableViewerInfo viewerInfo = gameObject.GetComponent<TableViewerInfo>();
        if(!viewerInfo){
            return;
        }

        string folderPath = viewerInfo.folderPath;

        IList<ICellData> datas = new List<ICellData>();

        try {
            foreach(string filePath in Directory.GetFiles(folderPath)) {
                GameObject prefab = (GameObject) AssetDatabase.LoadAssetAtPath(filePath, typeof(GameObject));
                if(prefab != null) {
                    IDataAccessor accessor =  manager.GetDataAccessor(prefab);
                    ICellData data = new PrefabData(accessor, prefab, folderPath);
                    datas.Add (data);
                }
            }

            IContentProvider contentProvider = new ContentProvider(datas);
            viewer.ContentProvider = contentProvider;

            ICellProvider cellProvider = new TableCellProvider(viewerInfo.labels);
            viewer.CellProvider = cellProvider;

            viewer.OnGUI();
        } catch {
        }
    }
Beispiel #7
0
        public static void PlaySFX(SoundType soundType)
        {
            Random r = new Random(Time.GameTimer.Milliseconds);

            switch (soundType)
            {
            case SoundType.buttonPress:
                var bp = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "buttonPress.Sound.res"));
                Player(bp, r);
                break;

            case SoundType.eatApple:
                var ea = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "eatApple.Sound.res"));
                Player(ea, r);
                break;

            case SoundType.walking:
                var w = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "walking.Sound.res"));
                Player(w);
                break;

            case SoundType.applePhaseShift:
                break;

            case SoundType.drown:
                var dr = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "drown.Sound.res"));
                Player(dr);
                break;

            case SoundType.ping:
                break;

            default:
                break;

            case SoundType.Intro:
                var i = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "itsMo.Sound.res"));
                Player(i);

                break;
            }
        }
Beispiel #8
0
        public ContentProvider FindContentProvider(int id)
        {
            ContentProvider provider = null;

            try
            {
                provider = _dbContext.ContentProviders.Find(id);
            }
            catch (Exception exception)
            {
                string message = $"Failure Finding Content Provider by Id={id}";

                Debug.Assert(false, message);
                Debug.Assert(false, exception.Message);

                Logger.LogError(exception, message, null);
            }

            return(provider);
        }
Beispiel #9
0
        public void AfterTest(ITest details)
        {
            Console.WriteLine("----- Beginning Duality Editor environment teardown -----");

            // Remove NUnit Console logs
            Logs.RemoveGlobalOutput(this.consoleLogOutput);
            this.consoleLogOutput = null;

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }

            DualityEditorApp.Terminate(false);
            Environment.CurrentDirectory = this.oldEnvDir;

            Console.WriteLine("----- Duality Editor environment teardown complete -----");
        }
Beispiel #10
0
        public static void Init()
        {
            // load custom shortcuts first
            if (!File.Exists(CustomShortcutsPath))
            {
                File.WriteAllText(CustomShortcutsPath, "[\n]");
            }

            _watcher = new FileSystemWatcher
            {
                Path                = Editor.Current.EditorDocumentsPath,
                Filter              = "KeyboardShortcuts.json",
                NotifyFilter        = NotifyFilters.LastWrite,
                EnableRaisingEvents = true,
            };
            _watcher.Changed += (s, e) => ReloadKeymap();

            _defaultShortcutsJson = ContentProvider.DownloadString("editor://KeyboardShortcuts.json");
            ReloadKeymap();
        }
Beispiel #11
0
        [Test] public void RenameContent()
        {
            Pixmap resource = new Pixmap();
            string aliasA   = "Foo";
            string aliasB   = "Bar";

            // Register the resource with one alias, then rename it to use another
            ContentProvider.AddContent(aliasA, resource);
            ContentProvider.RenameContent(aliasA, aliasB);

            // Expect the resource to use the second alias only, and the first to be unused
            Assert.AreEqual(aliasB, resource.Path);
            Assert.IsTrue(ContentProvider.HasContent(aliasB));
            Assert.AreSame(resource, ContentProvider.RequestContent <Pixmap>(aliasB).Res);
            Assert.AreSame(resource, ContentProvider.RequestContent(aliasB).Res);
            Assert.IsFalse(ContentProvider.HasContent(aliasA));
            Assert.IsNull(ContentProvider.RequestContent <Pixmap>(aliasA).Res);
            Assert.IsNull(ContentProvider.RequestContent(aliasA).Res);
            CollectionAssert.Contains(ContentProvider.GetLoadedContent <Pixmap>(), (ContentRef <Pixmap>)resource);
        }
        internal static void InitDefaultContent()
        {
            const string VirtualContentPath = ContentProvider.VirtualContentPath + "Texture:";

            const string ContentPath_White        = VirtualContentPath + "White";
            const string ContentPath_Checkerboard = VirtualContentPath + "Checkerboard";

            ContentProvider.AddContent(ContentPath_White, new Texture(Pixmap.White, keepPixmapDataResident: true));
            ContentProvider.AddContent(ContentPath_Checkerboard, new Texture(
                                           Pixmap.Checkerboard,
                                           SizeMode.Default,
                                           TextureMagFilter.Nearest,
                                           TextureMinFilter.Nearest,
                                           TextureWrapMode.Repeat,
                                           TextureWrapMode.Repeat,
                                           keepPixmapDataResident: true));

            White        = ContentProvider.RequestContent <Texture>(ContentPath_White);
            Checkerboard = ContentProvider.RequestContent <Texture>(ContentPath_Checkerboard);
        }
        protected override ViewModel EnrichModel(ViewModel sourceModel)
        {
            DynamicList model = base.EnrichModel(sourceModel) as DynamicList;

            if (model == null || model.QueryResults.Any())
            {
                return(model);
            }

            //we need to run a query to populate the list
            if (model.Id == Request.Params["id"])
            {
                //we only take the start from the query string if there is also an id parameter matching the model entity id
                //this means that we are sure that the paging is coming from the right entity (if there is more than one paged list on the page)
                model.Start = GetRequestParameter <int>("start");
            }
            ContentProvider.PopulateDynamicList(model, WebRequestContext.Localization);

            return(model);
        }
Beispiel #14
0
        /// <summary>
        /// Shredding an object into an Rest Request
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        internal RestRequest ObjectShredder(IRESTfulRequest obj, Method method, DataFormat dataFormat)
        {
            var request = new RestRequest(obj.Url, method, dataFormat);

            var content    = ContentProvider.Provider((RESTFulRequest)obj);
            var acceptType = obj.AcceptType.GetDescription();
            var headers    = HeaderProvider.GetRestHeaders(obj.RequestHeaders.ToArray());

            request.Parameters.AddRange(headers);

            //request.Parameters.AddRange(content);

            //request.AddJsonBody((RESTFulRequest)obj);

            request.AddParameter("application/json; charset=utf-8", content, ParameterType.RequestBody);



            return(request);
        }
Beispiel #15
0
        private static void RestoreTemporaryData(WorkerInterface workInterface, Stream strScene, Stream strData)
        {
            StreamReader strDataReader = new StreamReader(strData);

            // Read back current scene path, account for Write/ReadLine transforming
            // null values into an empty string.
            string scenePath = strDataReader.ReadLine();

            if (string.IsNullOrEmpty(scenePath))
            {
                scenePath = null;
            }

            workInterface.MainForm.Invoke((Action)(() => workInterface.TempScene = Resource.Load <Scene>(strScene, scenePath)));
            if (!workInterface.TempScene.IsRuntimeResource)
            {
                // Register the reloaded Scene in the ContentProvider, if it wasn't just a temporary one.
                workInterface.MainForm.Invoke((Action)(() => ContentProvider.AddContent(scenePath, workInterface.TempScene)));
            }
        }
Beispiel #16
0
        [Test] public void DisposeRemovesContent()
        {
            Pixmap resource = new Pixmap();
            string alias    = "Foo";

            // Register the new resource with the provider
            ContentProvider.AddContent(alias, resource);

            // Dispose the resource
            resource.Dispose();

            // Expect the resource to be disposed and no longer show up in API calls
            Assert.IsTrue(resource.Disposed);
            Assert.IsFalse(ContentProvider.HasContent(alias));
            Assert.IsNull(ContentProvider.RequestContent <Pixmap>(alias).Res);
            Assert.IsNull(ContentProvider.RequestContent(alias).Res);
            CollectionAssert.DoesNotContain(ContentProvider.GetLoadedContent <Pixmap>(), (ContentRef <Pixmap>)resource);

            // Expect the resource path to remain unchanged, in order to allow reload-recovery
            Assert.AreEqual(alias, resource.Path);
        }
Beispiel #17
0
        private static void Initialize()
        {
            if (!_initialized)
            {
                lock (_lock)
                {
                    if (!_initialized)
                    {
                        try
                        {
                            ContentSection section = ConfigurationManager.GetSection("lionsguard/content") as ContentSection;
                            if (section != null)
                            {
                                _providers = new ContentProviderCollection();
                                ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(ContentProvider));
                                _provider = _providers[section.DefaultProvider];
                                if (_provider == null)
                                {
                                    throw new ConfigurationErrorsException("Default ContentProvider not found in application configuration file.", section.ElementInformation.Properties["defaultProvider"].Source, section.ElementInformation.Properties["defaultProvider"].LineNumber);
                                }

                                if (!String.IsNullOrEmpty(section.SourceName))
                                {
                                    _sourceName = section.SourceName;
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            _initException = ex;
                        }
                        _initialized = true;
                    }
                }
            }
            if (_initException != null)
            {
                throw _initException;
            }
        }
Beispiel #18
0
        /// <summary> Creates list view items and groups for the given data <paramref name="elements"/>. </summary>
        /// <param name="elements">Data element collection</param>
        private void CreateGroupsAndItems(object[] elements)
        {
            Items.Clear();
//            Groups.Clear();

            for (int i = -1; ++i != elements.Length;)
            {
                object element     = elements[i];
                bool   hasChildren = ContentProvider.HasChildren(element);
                if (hasChildren)
                {
                    object[] children = ContentProvider.GetChildren(element);

                    // Don't create empty groups
                    if (children == null || children.Length == 0)
                    {
                        continue;
                    }

                    // Try to re-use existing groups
                    ListViewGroup group = Groups.Cast <ListViewGroup>().FirstOrDefault(grp => Equals(grp.Tag, element));
                    if (group == null)
                    {
                        group = new ListViewGroup {
                            Tag = element
                        };
                        Groups.Add(group);
                    }

                    for (int j = -1; ++j != children.Length;)
                    {
                        CreateListViewItem(children[j], group);
                    }
                }
                else
                {
                    CreateListViewItem(element, null);
                }
            }
        }
        public void AfterTest(TestDetails details)
        {
            Console.WriteLine("----- Beginning Duality environment teardown -----");

            // Remove NUnit Console logs
            Log.Game.RemoveOutput(this.consoleLogOutput);
            Log.Core.RemoveOutput(this.consoleLogOutput);
            Log.Editor.RemoveOutput(this.consoleLogOutput);
            this.consoleLogOutput = null;

            if (this.dummyWindow != null)
            {
                ContentProvider.ClearContent();
                ContentProvider.DisposeDefaultContent();
                this.dummyWindow.Dispose();
                this.dummyWindow = null;
            }
            DualityApp.Terminate();
            Environment.CurrentDirectory = this.oldEnvDir;

            Console.WriteLine("----- Duality environment teardown complete -----");
        }
Beispiel #20
0
        /// <summary>
        /// Given the specified <see cref="Pixmap"/> reference, this method enumerates all
        /// loaded <see cref="Tileset"/> instances that are candidates for a runtime recompile
        /// to account for potential changes.
        /// </summary>
        /// <param name="pixmapRef"></param>
        /// <returns></returns>
        private List <Tileset> GetRecompileTilesets(ContentRef <Pixmap> pixmapRef)
        {
            List <Tileset> recompileTilesets = new List <Tileset>();

            foreach (ContentRef <Tileset> tilesetRef in ContentProvider.GetLoadedContent <Tileset>())
            {
                Tileset tileset = tilesetRef.Res;

                // Early-out, if the tileset is unavailable, or we didn't compile it yet anyway
                if (tileset == null)
                {
                    continue;
                }
                if (!tileset.Compiled)
                {
                    continue;
                }

                // Determine whether this tileset uses the modified pixmap
                bool usesModifiedPixmap = false;
                foreach (TilesetRenderInput input in tileset.RenderConfig)
                {
                    if (input.SourceData == pixmapRef)
                    {
                        usesModifiedPixmap = true;
                        break;
                    }
                }
                if (!usesModifiedPixmap)
                {
                    continue;
                }

                // This tileset is a candidate for recompiling due to pixmap changes
                recompileTilesets.Add(tileset);
            }

            return(recompileTilesets);
        }
Beispiel #21
0
        protected override void OnBeforeUpdate()
        {
            base.OnBeforeUpdate();

            // Load all available content so we don't need on-demand loading during runtime.
            // It's probably not a good idea for content-rich games, consider having a per-level
            // loading screen instead, or something similar.
            if (!this.contentLoaded)
            {
                Log.Game.Write("Loading game content...");
                Log.Game.PushIndent();
                {
                    List <ContentRef <Resource> > availableContent = ContentProvider.GetAvailableContent <Resource>();
                    foreach (ContentRef <Resource> resourceReference in availableContent)
                    {
                        resourceReference.MakeAvailable();
                    }
                }
                Log.Game.PopIndent();
                this.contentLoaded = true;
            }
        }
Beispiel #22
0
        public virtual ActionResult NotFound()
        {
            string notFoundPageUrl = WebRequestContext.Localization.Path + "/error-404"; // TODO TSI-775: No need to prefix with WebRequestContext.Localization.Path here (?)

            PageModel pageModel;

            try
            {
                pageModel = ContentProvider.GetPageModel(notFoundPageUrl, WebRequestContext.Localization);
            }
            catch (DxaItemNotFoundException ex)
            {
                Log.Error(ex);
                throw new HttpException(404, ex.Message);
            }

            SetupViewData(pageModel);
            ViewModel model = EnrichModel(pageModel) ?? pageModel;

            Response.StatusCode = 404;
            return(View(model.MvcData.ViewName, model));
        }
Beispiel #23
0
        private void Awake()
        {
            Log             = new Log(Logger);
            contentProvider = new ContentProvider();

#if DEBUG
            Chen.Helpers.GeneralHelpers.MultiplayerTest.Enable(Log);
#endif
            Log.Debug("Initializing config file...");
            cfgFile = new ConfigFile(Path.Combine(Paths.ConfigPath, ModGuid + ".cfg"), true);

            Log.Debug("Loading asset bundle...");
            BundleInfo bundleInfo = new BundleInfo("Chen.Qb.assetbundle", BundleType.UnityAssetBundle);
            assetBundle = new AssetsManager(bundleInfo).Register();
            assetBundle.ConvertShaders();

            Log.Debug("Registering Qb Drone...");
            dronesList = DroneCatalog.Initialize(ModGuid, cfgFile);
            DroneCatalog.ScopedSetupAll(dronesList);

            contentProvider.Initialize();
        }
Beispiel #24
0
        public void SaveFile(string filePath)
        {
            this.filePath = filePath;

            using (FileStream fileStream = File.Open(this.filePath, FileMode.Create, FileAccess.Write))
            {
                using (var formatter = Formatter.CreateMeta(fileStream))
                {
                    foreach (DataTreeNode dataNode in this.dataModel.Nodes)
                    {
                        formatter.WriteObject(dataNode.Data);
                    }
                }
            }

            // Assure reloading the modified resource
            if (PathHelper.IsPathLocatedIn(this.filePath, "."))
            {
                string dataPath = PathHelper.MakeFilePathRelative(this.filePath);
                ContentProvider.RemoveContent(dataPath, true);
            }
        }
Beispiel #25
0
        public void MakeRandomlyPositionedDrone()
        {
            ContentRef <Prefab> droneRef = ContentProvider.RequestContent <Prefab>(@"Data\drone.Prefab.res");
            Prefab dronePrefab           = droneRef.Res;

            float startX = (random.Next(0, 51) <= 50) ? WORLD_WIDTH : -WORLD_WIDTH;
            float endX   = -startX;

            Vector3 startingPosition = new Vector3(startX, random.Next(-2000, -1000), 0);
            Vector3 targetPosition   = new Vector3(endX, random.Next(-2000, -1000), 0);

            GameObject   drone        = dronePrefab.Instantiate(startingPosition);
            DroneControl droneControl = drone.GetComponent <DroneControl>();

            droneControl.TargetPosition = targetPosition;

            var body = drone.GetComponent <RigidBody>();

            //if (startX < 0)
            //    body.LinearVelocity = new Vector2(200, 0);
            //else
            //    body.LinearVelocity = new Vector2(-200 , 0);

            droneControl.SetFixedAngle(true);

            // Add package
            {
                ContentRef <Prefab> packageRef = ContentProvider.RequestContent <Prefab>(@"Data\package.Prefab.res");
                Prefab         packagePrefab   = packageRef.Res;
                GameObject     package         = packagePrefab.Instantiate();
                PackageControl packageControl  = package.GetComponent <PackageControl>();
                packageControl.AttachToDrone(droneControl);
                droneControl.AttachPackage(packageControl);

                Scene.Current.AddObject(package);
            }

            Scene.Current.AddObject(drone);
        }
Beispiel #26
0
        public virtual void SetData(LoadParcelScenesMessage.UnityParcelScene data)
        {
            this.sceneData = data;

            contentProvider          = new ContentProvider();
            contentProvider.baseUrl  = data.baseUrl;
            contentProvider.contents = data.contents;
            contentProvider.BakeHashes();

            parcels.Clear();
            for (int i = 0; i < sceneData.parcels.Length; i++)
            {
                parcels.Add(sceneData.parcels[i]);
            }

            if (DCLCharacterController.i != null)
            {
                gameObject.transform.position = PositionUtils.WorldToUnityPosition(Utils.GridToWorldPosition(data.basePosition.x, data.basePosition.y));
            }

            OnSetData?.Invoke(data);
        }
Beispiel #27
0
        public static void PlayMusic(MusicType musicType)
        {
            switch (musicType)
            {
            case MusicType.Happy:
                var haps = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "Waves.Sound.res"));
                BeginIntro(haps, Vol * File.Res.musicVol);
                break;

            case MusicType.Mad:
                var mad = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "Anger.Sound.res"));
                BeginIntro(mad, Vol * File.Res.musicVol);
                break;

            case MusicType.Haunting:
                var h = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "Haunting.Sound.res"));
                BeginIntro(h, Vol * File.Res.musicVol);
                break;

            case MusicType.Boss:
                var boss = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "Boss.Sound.res"));
                BeginIntro(boss, Vol * File.Res.musicVol);
                break;

            case MusicType.Unusual:
                var u = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "Unusual.Sound.res"));
                BeginIntro(u, Vol * File.Res.musicVol);
                break;

            case MusicType.Bell:
                var bl = ContentProvider.RequestContent <Sound>(Combine(DataDirectory, "Sounds", "Bells.Sound.res"));
                BeginIntro(bl, Vol * File.Res.musicVol);
                break;

            default:
                break;
            }
        }
Beispiel #28
0
        public MvcHtmlString Render()
        {
            Tag result = new Tag(this.TagName, this.Attributes);

            if (!_contentReady)
            {
                if (ContentProvider.TakesTooLong(
                        (mvchtml) =>
                {
                    Content = mvchtml;
                    _contentReady = true;
                    return(Content);
                }, this.Name, this, this.MillisecondsToRender))     // will allow ContentProvider MillisecondsToRender before unblocking
                {
                    result.Data("view-name", this.Name)
                    .Data("plugin", "deferredView")
                    .Html(Content);
                }
            }

            result.Html(Content);
            return(MvcHtmlString.Create(result.ToHtmlString()));
        }
Beispiel #29
0
        public Viewer()
        {
            // Declaracao dos objetos-recursos usados para o jogo definidos no Editor

            //Bloco(s)
            DefaultBlock_Texture_Ref  = ContentProvider.RequestContent <Texture>(@"Data\DefaultBlock.Texture.res");
            DefaultBlock_Pixmap_Ref   = ContentProvider.RequestContent <Pixmap>(@"Data\DefaultBlock.Pixmap.res");
            DefaultBlock_Material_Ref = ContentProvider.RequestContent <Material>(@"Data\DefaultBlock.Material.res");
            //Bola
            Ball_Texture_Ref  = ContentProvider.RequestContent <Texture>(@"Data\red_ball.Texture.res");
            Ball_Pixmap_Ref   = ContentProvider.RequestContent <Pixmap>(@"Data\red_ball.Pixmap.res");
            Ball_Material_Ref = ContentProvider.RequestContent <Material>(@"Data\red_ball.Material.res");
            //Bloco principal/ativo
            ShipBlock_Texture_Ref  = ContentProvider.RequestContent <Texture>(@"Data\ShipBlock.Texture.res");
            ShipBlock_Pixmap_Ref   = ContentProvider.RequestContent <Pixmap>(@"Data\ShipBlock.Pixmap.res");
            ShipBlock_Material_Ref = ContentProvider.RequestContent <Material>(@"Data\ShipBlock.Material.res");
            //Imagem de fundo
            SpaceBg_Texture_Ref  = ContentProvider.RequestContent <Texture>(@"Data\SpaceBg.Texture.res");
            SpaceBg_Pixmap_Ref   = ContentProvider.RequestContent <Pixmap>(@"Data\SpaceBg.Pixmap.res");
            SpaceBg_Material_Ref = ContentProvider.RequestContent <Material>(@"Data\SpaceBg.Material.res");
            //Scene
            TheWallScene_Scene_Ref = ContentProvider.RequestContent <Scene>(@"Data\TheWallScene.Scene.res");
        }
        /// <summary>
        /// Resolve Template Page
        /// </summary>
        /// <param name="searchPath"></param>
        /// <returns></returns>
        protected PageModel ResolveTemplatePage(IList <string> searchPath)
        {
            PageModel templatePage = null;

            foreach (var templatePagePath in searchPath)
            {
                try
                {
                    Log.Info("Trying to find page template: " + templatePagePath);
                    templatePage = ContentProvider.GetPageModel(templatePagePath, WebRequestContext.Localization);
                }
                catch (DxaItemNotFoundException) {}
                if (templatePage != null)
                {
                    break;
                }
            }
            if (templatePage != null)
            {
                WebRequestContext.PageModel = templatePage;
            }
            return(templatePage);
        }
Beispiel #31
0
		void ICmpUpdatable.OnUpdate()
		{
			if (DualityApp.Keyboard.KeyHit(Key.Escape))
			{
				DualityApp.Terminate();
			}
			if (DualityApp.Keyboard.KeyHit(Key.Space))
			{
				//preloading materials and sounds
				foreach (ContentRef<Material> m in ContentProvider.GetAvailableContent<Material>())
				{
					m.EnsureLoaded();
				}
				foreach (ContentRef<Sound> s in ContentProvider.GetAvailableContent<Sound>())
				{
					s.EnsureLoaded();
				}

				GameScene.Res.FindComponent<GameController>().Reset();

				Scene.SwitchTo(GameScene);
			}
		}
Beispiel #32
0
        [Test] public void RemoveContentTree()
        {
            Pixmap resource1 = new Pixmap();
            Pixmap resource2 = new Pixmap();
            Pixmap resource3 = new Pixmap();
            string dirA      = "Foo";
            string dirB      = "Bar";
            string alias1    = dirA + "/" + "Resource1";
            string alias2    = dirA + "/" + "Resource2";
            string alias3    = dirB + "/" + "Resource3";

            // Register all resources, then remove one of their directories
            ContentProvider.AddContent(alias1, resource1);
            ContentProvider.AddContent(alias2, resource2);
            ContentProvider.AddContent(alias3, resource3);
            ContentProvider.RemoveContentTree(dirA, true);

            // Expect the resources from the removed directory to be disposed, but not any other resource
            Assert.AreEqual(alias1, resource1.Path);
            Assert.AreEqual(alias2, resource2.Path);
            Assert.AreEqual(alias3, resource3.Path);
            Assert.IsFalse(ContentProvider.HasContent(alias1));
            Assert.IsFalse(ContentProvider.HasContent(alias2));
            Assert.IsTrue(ContentProvider.HasContent(alias3));
            Assert.IsNull(ContentProvider.RequestContent <Pixmap>(alias1).Res);
            Assert.IsNull(ContentProvider.RequestContent <Pixmap>(alias2).Res);
            Assert.AreSame(resource3, ContentProvider.RequestContent <Pixmap>(alias3).Res);
            Assert.IsNull(ContentProvider.RequestContent(alias1).Res);
            Assert.IsNull(ContentProvider.RequestContent(alias2).Res);
            Assert.AreSame(resource3, ContentProvider.RequestContent(alias3).Res);
            Assert.IsFalse(ContentProvider.HasContent(alias1));
            Assert.IsFalse(ContentProvider.HasContent(alias2));
            Assert.IsTrue(ContentProvider.HasContent(alias3));
            CollectionAssert.DoesNotContain(ContentProvider.GetLoadedContent <Pixmap>(), (ContentRef <Pixmap>)resource1);
            CollectionAssert.DoesNotContain(ContentProvider.GetLoadedContent <Pixmap>(), (ContentRef <Pixmap>)resource2);
            CollectionAssert.Contains(ContentProvider.GetLoadedContent <Pixmap>(), (ContentRef <Pixmap>)resource3);
        }
Beispiel #33
0
        public virtual void SetData(LoadParcelScenesMessage.UnityParcelScene data)
        {
            this.sceneData = data;

            contentProvider          = new ContentProvider();
            contentProvider.baseUrl  = data.baseUrl;
            contentProvider.contents = data.contents;
            contentProvider.BakeHashes();

            state = State.WAITING_FOR_INIT_MESSAGES;
            RefreshName();

            parcels.Clear();
            for (int i = 0; i < sceneData.parcels.Length; i++)
            {
                parcels.Add(sceneData.parcels[i]);
            }

            if (DCLCharacterController.i != null)
            {
                gameObject.transform.position = DCLCharacterController.i.characterPosition.WorldToUnityPosition(Utils.GridToWorldPosition(data.basePosition.x, data.basePosition.y));
            }

#if UNITY_EDITOR
            //NOTE(Brian): Don't generate parcel blockers if debugScenes is active and is not the desired scene.
            if (SceneController.i.debugScenes && SceneController.i.debugSceneCoords != data.basePosition)
            {
                SetSceneReady();
                return;
            }
#endif

            if (isTestScene)
            {
                SetSceneReady();
            }
        }
Beispiel #34
0
        /// <summary>
        /// Shuts down the engine, cleaning up resources.
        /// </summary>
        public static void Shutdown(int exitCode = 1)
        {
            if (IsExiting)
            {
                return;
            }

            Logger.Warn("Shutting down...");

            AnalyticsService.EndSession();

            ContentProvider.DeleteDirectory(TempPath);

            IsExiting = true;

            var dataModel = Game.DataModel;

            try
            {
                dataModel.OnClose();
            }
            catch (Exception)
            {
                Logger.Error("DataModel OnClose callback errored.");
            }

            Settings.Save();
            UserSettings.Save();

            Exiting?.Invoke(null, null);

            CancelTokenSource.Cancel();

            Logger.Info("dEngine has been shutdown.");

            Environment.Exit(0);
        }
Beispiel #35
0
        public void OnInit(InitContext context)
        {
            if (context == InitContext.Loaded)
            {
                //Load audio
                _musicPlayer = GameObj.GetComponent <SoundEmitter>();

                if (_musicPlayer.Sources.Count != 4)
                {
                    //Reset audio sources
                    _musicPlayer.Sources.Clear();

                    //Add new audio sources
                    ContentRef <Sound> rightSideUpReference = ContentProvider.RequestContent <Sound>("Data\\MazeGenerator\\Audio\\Soliloquy - RightSideUp.Sound.res");
                    Source             rightSideUpSource    = new Source(rightSideUpReference, false);
                    rightSideUpSource.Volume = 1.0f;
                    _musicPlayer.Sources.Add(rightSideUpSource);

                    ContentRef <Sound> upsideDownReference = ContentProvider.RequestContent <Sound>("Data\\MazeGenerator\\Audio\\The Dark Amulet - game.Sound.res");
                    Source             upsideDownSource    = new Source(upsideDownReference, false);
                    upsideDownSource.Volume = 0.0f;
                    _musicPlayer.Sources.Add(upsideDownSource);

                    ContentRef <Sound> winReference = ContentProvider.RequestContent <Sound>("Data\\MazeGenerator\\Audio\\Movie Theater Intro - Win.Sound.res");
                    Source             winSource    = new Source(winReference, false);
                    winSource.Volume = 0.0f;
                    winSource.Paused = true;
                    _musicPlayer.Sources.Add(winSource);

                    ContentRef <Sound> loseReference = ContentProvider.RequestContent <Sound>("Data\\MazeGenerator\\Audio\\noise - Lose.Sound.res");
                    Source             loseSource    = new Source(loseReference, false);
                    loseSource.Volume = 0.0f;
                    loseSource.Paused = true;
                    _musicPlayer.Sources.Add(loseSource);
                }
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="OverworldScreen"/> class.
 /// </summary>
 /// <param name="worldManager">
 /// The world Manager.
 /// </param>
 /// <param name="contentProvider">
 /// The content Provider.
 /// </param>
 /// <param name="worldBoundary">
 /// The world Boundary.
 /// </param>
 public OverworldScreen(IWorldManager worldManager, ContentProvider contentProvider, Rectangle worldBoundary)
     : base(worldManager, contentProvider, worldBoundary)
 {
 }
        public override void LoadContent(ContentProvider provider)
        {
            base.LoadContent(provider);

            if (_vertexBuffer == null)
            {
                _vertexBuffer = new VertexBuffer(provider.Device, typeof(VertexPositionColor), _vertices.Length, BufferUsage.WriteOnly);
                _vertexBuffer.SetData<VertexPositionColor>(_vertices);
            }

            if (_indexBuffer == null)
            {
                _indexBuffer = new IndexBuffer(provider.Device, typeof(short), _indices.Length, BufferUsage.WriteOnly);
                _indexBuffer.SetData<short>(_indices);
            }

            if (_indexWFBuffer == null)
            {
                _indexWFBuffer = new IndexBuffer(provider.Device, typeof(short), _indicesWF.Length, BufferUsage.WriteOnly);
                _indexWFBuffer.SetData<short>(_indicesWF);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EntityFactory"/> class.
 /// </summary>
 /// <param name="contentProvider">
 /// The content provider.
 /// </param>
 public EntityFactory(ContentProvider contentProvider)
 {
     this.contentProvider = contentProvider;
 }
            public void setup()
            {
                bool isFileNew = true;
                var fileProvider = new Mock<IFileProvider>();
                fileProvider.Setup(x => x.GetWriter(out isFileNew))
                        .Returns(new MemoryStream());

                var productsSample = SampleProductsGenerator.Generate(10);
                Func<IEnumerable<Dictionary<string, string>>> content = () => new SampleProductToDictionaryTransformer().Transform(productsSample);

                _contentProvider = new ContentProvider(fileProvider.Object, content);
            }