コード例 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            DefaultFont = Content.Load <SpriteFont>("Default");

            spriteBatch = new SpriteBatch(GraphicsDevice);
            //PrefabFactory.RegisterPrefab("machine gun", () => GameObjectFactory.New()
            //    .WithTexture(TextureUtil.CreateTexture(16, 16, Color.Red))
            //    .With(new Weapon() { FireRate = 0.5f })
            //    .Create());

            //PrefabFactory.RegisterPrefab("player", () => GameObjectFactory.New()
            //    .AtPosition(new Vector2(0))
            //    .WithTexture(TextureUtil.CreateTexture(64, 128, Color.Black))
            //    .With(new VelocityController())
            //    .With(new ShipEngine())
            //    .With(new PlayerController())
            //    .With(new Drag())
            //    .With(new ScreenWrapper()).With(new ParticleEmitter())
            //    .WithChild("machine gun", new Vector2(0, -1))
            //    .Create());

            //PrefabFactory.RegisterPrefab("bullet", () => GameObjectFactory.New()
            //    .WithTexture(TextureUtil.CreateTexture(16, 16, Color.Yellow))
            //    .With(new VelocityController())
            //    .With(new BulletController())
            //    .With(new ScreenWrapper())
            //    .Create());

            PrefabFactory.RegisterPrefab("unitbox", () => GameObjectFactory.New()
                                         .WithTexture(TextureUtil.CreateTexture(64, 64, Color.Black))
                                         .With(new Collider()
            {
                Body = BodyFactory.CreateRectangle(PhysicsWorld.World, 1, 1, 1)
            })
                                         .Create());

            PrefabFactory.RegisterPrefab("cursor", () => GameObjectFactory.New()
                                         .WithTexture(TextureUtil.CreateTexture(64, 64, Color.Red))
                                         .With(new SimpleController()).With(new Collider()
            {
                Body     = BodyFactory.CreateRectangle(PhysicsWorld.World, 1, 1, 1),
                BodyType = BodyType.Dynamic
            })
                                         .Create());

            GameObjectManager.Start();
        }