当前位置: 首页>>代码示例>>C#>>正文


C# IPackageRepository.GetAssetData方法代码示例

本文整理汇总了C#中IPackageRepository.GetAssetData方法的典型用法代码示例。如果您正苦于以下问题:C# IPackageRepository.GetAssetData方法的具体用法?C# IPackageRepository.GetAssetData怎么用?C# IPackageRepository.GetAssetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPackageRepository的用法示例。


在下文中一共展示了IPackageRepository.GetAssetData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WorldEditorTerrainToolsViewModel

        public WorldEditorTerrainToolsViewModel(IPackageRepository repository, SpriteLoader spriteLoader)
        {
            this._repository = repository;
            this._spriteLoader = spriteLoader;
            this._isGridVisible = false;

            this._tiles = new ObservableCollection<TileViewModel>();

            foreach (var asset in repository.Assets.Where(x => x.Type == EditorAssetTypes.TerrainTileDefinition).OrderBy(x => x.Key))
            {
                var tileData = _repository.GetAssetData<TerrainTileDefinitionResource>(asset.Id);
                _tiles.Add(new TileViewModel() { Key = tileData.Key, Sprite = _spriteLoader.LoadSprite(tileData.SpriteKey) });
            }

            this.SelectedTile = _tiles.FirstOrDefault();
            this.SelectedTool = TerrainEditorTools.Paint;

            SetToolCommand = new DelegateCommand<String>(x =>
                {
                    if (x == "Fill")
                        SelectedTool = TerrainEditorTools.Fill;
                    else if (x == "Paint")
                        SelectedTool = TerrainEditorTools.Paint;
                    else if (x == "EyeDropper")
                        SelectedTool = TerrainEditorTools.EyeDropper;
                });
        }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:27,代码来源:WorldEditorTerrainToolsViewModel.cs

示例2: WorldEditorWorldViewModel

        public WorldEditorWorldViewModel(CompositionContainer container, IPackageRepository packageRepository)
        {
            this._objectTypes = new ObservableCollection<WorldObjectTypeViewModel>();
            this._packageRepository = packageRepository;
            this._worldObjects = new ObservableCollection<WorldObjectViewModel>();
            this._worldObjectModelToObjectTypeDefinitionMapping = new Dictionary<Type, WorldObjectDefinition>();

            this.SelectedObjectName = "No Object Selected";

            this._editSelectedObjectCommand = new DelegateCommand(EditSelectedObjectExecute, EditSelectedObjectCanExecute);
            this._deleteSelectedObjectCommand = new DelegateCommand(DeleteSelectedObjectExecute, DeleteSelectedObjectCanExecute);
            this._copyCommand = new DelegateCommand(CopyExecute, CopyCanExecute);
            this._pasteCommand = new DelegateCommand(PasteExecute, PasteCanExecute);

            var worldObjectTypeExports = container.GetExports<IWorldEditorTypeDefinition, IWorldEditorTypeMetaData>();

            foreach (var export in worldObjectTypeExports)
            {
                var definition = new WorldObjectTypeViewModel(this, export.Metadata, export.Value);
                _objectTypes.Add(definition);
                _worldObjectModelToObjectTypeDefinitionMapping[export.Value.WorldObjectType] = definition;
            }

            var archetypeBasedWorldObjectTypeExports = container.GetExports<IArchetypeBasedWorldEditorTypeDefinition, IArchetypeBasedWorldEditorTypeMetaData>();
            foreach (var export in archetypeBasedWorldObjectTypeExports)
            {
                var definition = new ExistingWorldObjectArchetypeViewModel(this, export.Metadata, export.Value);
                _worldObjectModelToObjectTypeDefinitionMapping[export.Value.WorldObjectType] = definition;
            }

            this._archetypes = new ObservableCollection<NewWorldObjectArchetypeViewModel>();
            foreach (var asset in _packageRepository.Assets.Where(x => x.Type == EditorAssetTypes.Archetype).OrderBy(x => x.Key))
            {
                var data = _packageRepository.GetAssetData<ArchetypeResource>(asset.Id);

                if (!(data.Data is WorldObjectArchetypeData))
                    continue;

                IArchetypeBasedWorldEditorTypeDefinition typeDefinition = null;
                IArchetypeBasedWorldEditorTypeMetaData metaData = null;

                foreach (var export in archetypeBasedWorldObjectTypeExports)
                {
                    if (export.Value.ArchetypeDataType == data.Data.GetType())
                    {
                        typeDefinition = export.Value;
                        metaData = export.Metadata;
                        break;
                    }
                }

                var definition = new NewWorldObjectArchetypeViewModel(
                    this, asset.Key.Split('.').Last(),
                    (WorldObjectArchetypeData)data.Data, 
                    asset.Key,
                    metaData,
                    typeDefinition);

                this._archetypes.Add(definition);
            }
        }
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:61,代码来源:WorldEditorWorldViewModel.cs


注:本文中的IPackageRepository.GetAssetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。