示例#1
0
 public static ParticleEmitter CreateHitEffect(Vector2D position)
 {
     var material = new Material(Shader.Position2DColorUV, "Hit");
     var deathEffect = new ParticleEmitterData
     {
         ParticleMaterial = material,
         MaximumNumberOfParticles = 1,
         SpawnInterval = 0,
         Size = new RangeGraph<Size>(new Size(0.06f), new Size(0.09f)),
         LifeTime = 0.5f
     };
     return new ParticleEmitter(deathEffect, position);
 }
示例#2
0
 public Grid(BlocksContent content)
 {
     this.content = content;
     zoomBrickData = new ParticleEmitterData
     {
         LifeTime = 0.2f,
         Color = new RangeGraph<Color>(Color.White, Color.TransparentWhite),
         MaximumNumberOfParticles = 10,
         SpawnInterval = -1,
         StartVelocity = new RangeGraph<Vector3D>(Vector2D.Zero, Vector2D.Zero),
         StartPosition = new RangeGraph<Vector3D>(Vector2D.Zero, Vector2D.Zero),
     };
 }
示例#3
0
 public InteractionLogic()
 {
     // ParticleSystemData can very well be loaded by a ContentLoader, unused for simplicity in M5
     //explosionData = ContentLoader.Load<ParticleEmitterData>("ExplosionEffectEmitter0");
     explosionData = new ParticleEmitterData
     {
         ParticleMaterial = ContentLoader.Load<Material>("ExplosionAnimated2D"),
         Size = new RangeGraph<Size>(new Size(0.2f, 0.2f), new Size(0.2f,0.2f)),
         LifeTime = 0,
         SpawnInterval = 0.001f,
         MaximumNumberOfParticles = 1
     };
     IncreaseScore += i => { };
 }
示例#4
0
 public ParticleEmitter(ParticleEmitterData emitterData, Vector3D spawnPosition)
 {
     EmitterData = ParticleEmitterData.CopyFrom(emitterData);
     ElapsedSinceLastSpawn = emitterData.SpawnInterval;
     if (emitterData.ParticleMaterial == null)
     {
         base.Dispose();
         throw new UnableToCreateWithoutMaterial();
     }
     Position = spawnPosition;
     Rotation = Quaternion.Identity;
     lastFramePosition = spawnPosition;
     CreateImageAnimationMaterials();
     OnDraw<Particle2DRenderer>();
 }
示例#5
0
 public static ParticleEmitter CreateDeathEffect(Vector2D position)
 {
     var material = new Material(Shader.Position2DColorUV, "DeathSkull");
     var deathEffect = new ParticleEmitterData
     {
         ParticleMaterial = material,
         MaximumNumberOfParticles = 1,
         SpawnInterval = 0,
         Size = new RangeGraph<Size>(new Size(GameLogic.DeathSkullSize),
             new Size(GameLogic.DeathSkullSize-0.005f)),
         Acceleration = new RangeGraph<Vector3D>(new Vector2D(0, -0.04f), new Vector2D(0, -0.04f)),
         LifeTime = 2f,
         StartVelocity = new RangeGraph<Vector3D>(Vector2D.Zero, new Vector2D(0.01f, 0.01f))
     };
     return new ParticleEmitter(deathEffect, position);
 }
示例#6
0
 //ncrunch: no coverage start
 public Projectile(Vector2D startPosition, float angle)
     : base(Rectangle.FromCenter(startPosition, new Size(.02f)))
 {
     Rotation = angle;
     RenderLayer = (int)AsteroidsRenderLayer.Rockets;
     // ParticleSystemData can very well be loaded by a ContentLoader, unused for simplicity in M5
     //missileAndTrails =
     //	new ParticleSystem(ContentLoader.Load<ParticleSystemData>("MissileEffect"));
     missileAndTrails = new ParticleSystem();
     var rocketData = new ParticleEmitterData
     {
         ParticleMaterial = ContentLoader.Load<Material>("Missile2D"),
         Size = new RangeGraph<Size>(new Size(0.025f, 0.025f), new Size(0.025f, 0.025f)),
         LifeTime = 0,
         SpawnInterval = 0.001f,
         MaximumNumberOfParticles = 1
     };
     var trailData = new ParticleEmitterData
     {
         ParticleMaterial = ContentLoader.Load<Material>("Projectile2D"),
         Size = new RangeGraph<Size>(new Size(0.02f, 0.03f), new Size(0.02f, 0.04f)),
         StartPosition =
             new RangeGraph<Vector3D>(new Vector3D(0.0f, 0.02f, 0.0f), new Vector3D(0.0f, 0.02f, 0.0f)),
         LifeTime = 2.2f,
         SpawnInterval = 0.2f,
         MaximumNumberOfParticles = 8
     };
     missileAndTrails.AttachEmitter(new ParticleEmitter(trailData, Vector3D.Zero));
     missileAndTrails.AttachEmitter(new ParticleEmitter(rocketData, Vector3D.Zero));
     missileAndTrails.AttachedEmitters[0].EmitterData.DoParticlesTrackEmitter = true;
     missileAndTrails.AttachedEmitters[1].EmitterData.DoParticlesTrackEmitter = true;
     foreach (var emitter in missileAndTrails.AttachedEmitters)
         emitter.EmitterData.StartRotation =
             new RangeGraph<ValueRange>(new ValueRange(Rotation, Rotation),
                 new ValueRange(Rotation, Rotation));
     var data = new SimplePhysics.Data
     {
         Gravity = Vector2D.Zero,
         Velocity =
             new Vector2D(MathExtensions.Sin(angle) * ProjectileVelocity,
                 -MathExtensions.Cos(angle) * ProjectileVelocity)
     };
     Add(data);
     Start<MoveAndDisposeOnBorderCollision>();
 }
示例#7
0
 public static ParticleEmitterData CopyFrom(ParticleEmitterData otherData)
 {
     var newEmitterData = new ParticleEmitterData();
     newEmitterData.SpawnInterval = otherData.SpawnInterval;
     newEmitterData.LifeTime = otherData.LifeTime;
     newEmitterData.MaximumNumberOfParticles = otherData.MaximumNumberOfParticles;
     newEmitterData.StartVelocity = new RangeGraph<Vector3D>(otherData.StartVelocity.Values);
     newEmitterData.Acceleration = new RangeGraph<Vector3D>(otherData.Acceleration.Values);
     newEmitterData.Size = new RangeGraph<Size>(otherData.Size.Values);
     newEmitterData.StartRotation = new RangeGraph<ValueRange>(otherData.StartRotation.Values);
     newEmitterData.Color = otherData.Color = new RangeGraph<Color>(otherData.Color.Values);
     newEmitterData.ParticleMaterial = otherData.ParticleMaterial;
     newEmitterData.ParticlesPerSpawn = otherData.ParticlesPerSpawn;
     newEmitterData.RotationSpeed = new RangeGraph<ValueRange>(otherData.RotationSpeed.Values);
     newEmitterData.PositionType = otherData.PositionType;
     newEmitterData.StartPosition = new RangeGraph<Vector3D>(otherData.StartPosition.Values);
     newEmitterData.ParticlesPerSpawn = otherData.ParticlesPerSpawn;
     newEmitterData.DoParticlesTrackEmitter = otherData.DoParticlesTrackEmitter;
     return newEmitterData;
 }
 private bool TrySavingEmitterData(ParticleEmitterData emitterData, string name,
     bool overwrite)
 {
     if (!MaySaveRegardingExistingAndOverwrite(name, ContentType.ParticleEmitter, overwrite))
     { //ncrunch: no coverage start
         WarnExistantContentNoOverwrite(name, ContentType.ParticleEmitter);
         return false;
     } //ncrunch: no coverage end
     var bytes = BinaryDataExtensions.ToByteArrayWithTypeInformation(emitterData);
     var fileNameAndBytes = new Dictionary<string, byte[]>();
     fileNameAndBytes.Add(name + ".deltaparticle", bytes);
     ContentMetaData metaData = metaDataCreator.CreateMetaDataFromParticle(name, bytes);
     service.UploadContent(metaData, fileNameAndBytes);
     return true;
 }
示例#9
0
 private static MemoryStream SaveTestParticle()
 {
     var particleEmitterData = new ParticleEmitterData();
     var shader = Load<Shader>(Shader.Position2DColor);
     particleEmitterData.ParticleMaterial = new Material(shader, null, new Size(8, 8));
     particleEmitterData.Size = new RangeGraph<Size>(new Size(0.1f, 0.1f));
     particleEmitterData.MaximumNumberOfParticles = 256;
     particleEmitterData.LifeTime = 5.0f;
     particleEmitterData.SpawnInterval = 0.1f;
     particleEmitterData.Color = new RangeGraph<Color>(Color.Red, Color.Green);
     var data = BinaryDataExtensions.SaveToMemoryStream(particleEmitterData);
     data.Seek(0, SeekOrigin.Begin);
     return data;
 }
示例#10
0
 private static Stream CreateEmitter3D(ParticleEmitterPositionType positionType)
 {
     var pointEmitter = new ParticleEmitterData();
     pointEmitter.ParticleMaterial = new Material(Shader.Position3DColorUV, "DeltaEngineLogo");
     pointEmitter.PositionType = positionType;
     var data = BinaryDataExtensions.SaveToMemoryStream(pointEmitter);
     data.Seek(0, SeekOrigin.Begin);
     return data;
 }