예제 #1
0
        public static ParticleSystem createSystem(JsonObject initData)
        {
            ParticleSystem ps = new ParticleSystem();

            ps.continuous   = (bool)initData["continuous"];
            ps.lifetime     = (float)initData["lifetime"];
            ps.maxParticles = (int)initData["maxParticles"];
            String            textureName = (string)initData["material"];
            TextureDescriptor td          = new TextureDescriptor(textureName);

            ps.material = Renderer.resourceManager.getResource(td) as Texture;

            JsonObject features = initData["features"];

            foreach (String key in features.keys)
            {
                ParticleFeatureCreator creator = null;
                if (featureFactory.TryGetValue(key, out creator) == true)
                {
                    JsonObject      featureData = features[key];
                    ParticleFeature f           = creator.create(featureData);
                    ps.addFeature(f);
                }
                else
                {
                    //don't get here
                    throw new Exception(String.Format("Unable to find creator for {0}", key));
                }
            }

            addParticleSystem(ps);
            return(ps);
        }
예제 #2
0
 public static void addFeatureCreator(ParticleFeatureCreator fc)
 {
     featureFactory.Add(fc.name, fc);
 }