public EntitySelectorViewModel(IEnumerable<Entity> entities, InMemoryResourceCache<Texture2D> cache, Action<Entity, bool> invokeCancel)
 {
     this.cache = cache;
     Entities = entities.ToList();
     this.entityKeys = Entities.Select(e => e.EditorName).ToList();
     this.invokeCancel = invokeCancel;
 }
 public StaticMeshSelector(IEnumerable<string> tiles, InMemoryResourceCache<Texture2D> cache)
 {
     InitializeComponent();
     DataContext = new TileSelectorViewModel(
         tiles,
         (string s, bool b) =>
         {
             this.SelectedKey = s;
             this.DialogResult = b;
         });
 }
 public EntitySelector(IEnumerable<Entity> entities, InMemoryResourceCache<Texture2D> cache)
 {
     InitializeComponent();
     DataContext = new EntitySelectorViewModel(
         entities,
         cache,
         (Entity s, bool b) =>
         {
             this.SelectedEntity = s;
             this.DialogResult = b;
         });
 }
Beispiel #4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteFont = Content.Load<SpriteFont>("font");

            // instantiate the container
            var builder = new ContainerBuilder();
            builder.RegisterModule<EntityBootstrapper>();

            Tiles = new TileBootstrapper().GetTiles(Content);

            // setup caches
            TextureCache = new InMemoryResourceCache<Texture2D>(
                new ContentManagerProvider<Texture2D>(Content));
            SoundCache = new InMemoryResourceCache<SoundEffect>(
                new ContentManagerProvider<SoundEffect>(Content));
            builder.RegisterInstance(TextureCache).As<IResourceCache<Texture2D>>();
            builder.RegisterInstance(SoundCache).As<IResourceCache<SoundEffect>>();

            TextureCache.LoadResources(Tiles);
            var blank = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            blank.SetData(new[] { Color.White });
            TextureCache.AddResource("blank", blank);
            SoundCache.LoadResource("Audio/Sounds/Hop");
            SoundCache.LoadResource("Audio/Music/Four");

            builder.RegisterType<PhysicsManager>().AsSelf().SingleInstance();
            builder.RegisterType<RenderManager>().AsSelf().SingleInstance();
            builder.RegisterType<LevelManager>().AsSelf().SingleInstance();

            builder.RegisterType<SQLiteDatabase>().AsSelf().SingleInstance();

            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDeviceManager.GraphicsDevice);

            Container = builder.Build();

            foreach (var entity in Container.Resolve<IEnumerable<Entity>>())
            {
                entity.Load(Container);
            }
        }
Beispiel #5
0
        protected override void LoadContent()
        {
            // instantiate the container
            var builder = new ContainerBuilder();

            // setup caches
            TextureCache = new InMemoryResourceCache<Texture2D>(
                new ContentManagerProvider<Texture2D>(Content));
            SoundCache = new InMemoryResourceCache<SoundEffect>(
                new ContentManagerProvider<SoundEffect>(Content));
            builder.RegisterInstance(TextureCache).As<IResourceCache<Texture2D>>();
            builder.RegisterInstance(SoundCache).As<IResourceCache<SoundEffect>>();

            SpriteBatch = new SpriteBatch(GraphicsDevice);

            TextureCache.LoadResource("Textures/circle");
            var blank = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            blank.SetData(new[] { Color.White });
            TextureCache.AddResource("blank", blank);

            builder.RegisterType<PhysicsManager>().AsSelf().SingleInstance();
            builder.RegisterType<RenderManager>().AsSelf().SingleInstance();
            builder.RegisterType<LevelManager>().AsSelf().SingleInstance();
            builder.RegisterType<ScreenManager>().AsSelf().SingleInstance();

            builder.RegisterType<SQLiteDatabase>().AsSelf().SingleInstance();

            builder.RegisterInstance(this).As<EngineGame>();

            Container = builder.Build();
        }
        protected override sealed void LoadContent()
        {
            // instantiate the container
            builder = new ContainerBuilder();

            // setup caches
            textureCache = new InMemoryResourceCache<Texture2D>(
                new ContentManagerProvider<Texture2D>(Content));
            builder.RegisterInstance(textureCache).As<IResourceCache<Texture2D>>();

            spriteBatch = new SpriteBatch(GraphicsDevice);

            var blank = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color);
            blank.SetData(new[] { Color.White });
            textureCache.AddResource("blank", blank);
        }