Ejemplo n.º 1
0
 public void SetProject(ProjectValueObject project, DisplayObjectContainer renderTarget)
 {
     _project = project;
     foreach (var emitterValueObject in project.Emitters)
     {
         StarlingHandler handler = (StarlingHandler)emitterValueObject.Emitter.ParticleHandler;
         handler.Container = renderTarget;
     }
 }
Ejemplo n.º 2
0
        public ProjectValueObject CreateProjectInstance()
        {
            if (!_projectLoaded)
            {
                throw new InvalidOperationException("No project is loaded, call LoadSim() first!");
            }
            float version = _descJson["version"].Value <float>();
            var   project = new ProjectValueObject(version);

            foreach (RawEmitterData rawData in _rawEmitterDatas)
            {
                Emitter emitter = _stardusSerializer.Deserialize(rawData.EmitterString);
                emitter.Name = rawData.EmitterId;
                EmitterValueObject emitterVo = new EmitterValueObject(emitter);
                project.Emitters.Add(emitterVo);
                if (rawData.Snapshot != null)
                {
                    var snapshots = ParticleSnapshots.Parser.ParseFrom(rawData.Snapshot);
                    emitterVo.EmitterSnapshot = snapshots.Particles;
                    emitterVo.AddParticlesFromSnapshot();
                }
                var textures    = _atlas.GetTextures(SDEConstants.GetSubtexturePrefix(emitterVo.Id));
                var subTextures = textures.Cast <SubTexture>().ToList();
                ((StarlingHandler)(emitterVo.Emitter.ParticleHandler)).Textures = subTextures;
            }

            foreach (var emitterVo in project.Emitters)
            {
                foreach (var action in emitterVo.Emitter.Actions)
                {
                    Spawn spawn = action as Spawn;
                    if (spawn?.SpawnerEmitterId != null)
                    {
                        foreach (var emitterValueObject in project.Emitters)
                        {
                            if (spawn.SpawnerEmitterId == emitterValueObject.Id)
                            {
                                spawn.SpawnerEmitter = emitterValueObject.Emitter;
                            }
                        }
                    }
                }
            }
            return(project);
        }
Ejemplo n.º 3
0
 public SimPlayer(ProjectValueObject project, DisplayObjectContainer renderTarget)
 {
     SetProject(project, renderTarget);
 }