Exemple #1
0
        private void InitTerrain(ECSEngine engine)
        {
            _sm.RegisterSystem("Game", new TerrainMapRenderSystem());

            var terrainTex = engine.LoadContent <Texture2D>("Canyon");
            var defaultTex = engine.LoadContent <Texture2D>("grasstile");

            var terrain = EntityFactory.Instance.NewEntityWithTag("Terrain");
            var t       = new TerrainMapComponent(engine.GetGraphicsDevice(), terrainTex, defaultTex, 10);
            var tf      = new TransformComponent();

            TerrainMapRenderSystem.LoadHeightMap(ref t, terrainTex, defaultTex, engine.GetGraphicsDevice());

            t.SetTextureToChunk(0, engine.LoadContent <Texture2D>("LTCornerroad"));
            t.SetTextureToChunk(1, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(2, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(3, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(4, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(5, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(6, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(7, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(8, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(9, engine.LoadContent <Texture2D>("LBCornerroad"));
            t.SetTextureToChunk(10, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(19, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(20, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(29, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(30, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(39, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(40, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(49, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(50, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(59, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(60, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(69, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(70, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(79, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(80, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(89, engine.LoadContent <Texture2D>("horizontalroad"));
            t.SetTextureToChunk(90, engine.LoadContent <Texture2D>("RTCornerroad"));
            t.SetTextureToChunk(99, engine.LoadContent <Texture2D>("RBCornerroad"));
            t.SetTextureToChunk(98, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(97, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(96, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(95, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(94, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(93, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(92, engine.LoadContent <Texture2D>("verticalroad"));
            t.SetTextureToChunk(91, engine.LoadContent <Texture2D>("verticalroad"));

            tf.World    = Matrix.CreateTranslation(0, 0, 0);
            tf.Position = Vector3.Zero;
            ComponentManager.Instance.AddComponentToEntity(terrain, t);
            ComponentManager.Instance.AddComponentToEntity(terrain, tf);

            SceneManager.Instance.AddEntityToSceneOnLayer("Game", 2, terrain);
        }
Exemple #2
0
        private void InitParticles(ECSEngine engine)
        {
            SystemManager.Instance.RegisterSystem("Game", new ParticleRenderSystem(engine.GetGraphicsDevice()));
            SystemManager.Instance.RegisterSystem("Game", new ParticleUpdateSystem());
            Entity SmokehParticle        = EntityFactory.Instance.NewEntityWithTag("smokeh");
            SmokeParticleComponent pComp = new SmokeParticleComponent();

            ComponentManager.Instance.AddComponentToEntity(SmokehParticle, pComp);
            ParticleRenderSystem.LoadParticleEffect(engine.GetGraphicsDevice(), engine.LoadContent <Effect>("Effects/ParticleEffect"), engine.LoadContent <Texture2D>("smoke"), ref pComp);
            ParticleRenderSystem.setParticleOffsetPosition(ref pComp, new Vector3(0, 0, 10f));
            SceneManager.Instance.AddEntityToSceneOnLayer("Game", 2, SmokehParticle);
        }