Ejemplo n.º 1
0
		public static ParticleSystem ImpactEffect()
		{
			var impactEffect = new ParticleSystem();
			var impactEmitterData = new ParticleEmitterData();
			impactEmitterData.ParticleMaterial = GetFallbackMaterial();
			impactEffect.AttachEmitter(new ParticleEmitter(impactEmitterData, Vector3D.Zero));
			return impactEffect;
		}
Ejemplo n.º 2
0
		public static ParticleSystem CreepTransformationEffect()
		{
			var transformationEffect = new ParticleSystem();
			var transformationEmitterData = new ParticleEmitterData();
			transformationEmitterData.ParticleMaterial = GetFallbackMaterial();
			transformationEffect.AttachEmitter(new ParticleEmitter(transformationEmitterData,
				Vector3D.Zero));
			return transformationEffect;
		}
Ejemplo n.º 3
0
 public bool UpdateIfStillActive(ParticleEmitterData data)
 {
     if (!UpdateParticle(data))
     {
         return(false);                //ncrunch: no coverage
     }
     Position += CurrentMovement * Time.Delta;
     return(true);
 }
Ejemplo n.º 4
0
		public static ParticleSystem CreepDeathEffect()
		{
			var deathEffect = new ParticleSystem();
			var emitterData = new ParticleEmitterData();
			emitterData.ParticleMaterial = GetFallbackMaterial();
			emitterData.Size = new RangeGraph<Size>(new Size(1.0f), new Size(1.0f));
			emitterData.LifeTime = 1.0f;
			emitterData.MaximumNumberOfParticles = 1;
			deathEffect.AttachEmitter(new ParticleEmitter(emitterData, Vector3D.Zero));
			return deathEffect;
		}
Ejemplo n.º 5
0
        //ncrunch: no coverage start
        public bool UpdateEscapingParticleIfStillActive(ParticleEmitterData data, Vector3D position)
        {
            if (!UpdateParticle(data))
            {
                return(false);
            }
            var magnitude = CurrentMovement.Length;
            var vector    = Vector3D.Normalize(Position - position);

            Position += magnitude * vector * Time.Delta;
            return(true);
        }
Ejemplo n.º 6
0
 private bool UpdateParticle(ParticleEmitterData data)
 {
     ElapsedTime += Time.Delta;
     if (ElapsedTime > data.LifeTime && data.LifeTime > 0.0f)
     {
         return(IsActive = false);                //ncrunch: no coverage
     }
     CurrentMovement += Acceleration * Time.Delta;
     Rotation        += data.RotationSpeed.GetInterpolatedValue(ElapsedTime / data.LifeTime).
                        GetRandomValue() * Time.Delta;
     return(true);
 }
Ejemplo n.º 7
0
        public bool UpdateRoundingParticleIfStillActive(ParticleEmitterData data, Vector3D position)
        {
            if (!UpdateParticle(data))
            {
                return(false);
            }
            var formerZ = Position.Z;
            var axis    = position.GetVector2D();
            var vector  = Position.GetVector2D().RotateAround(axis, CurrentMovement.Length * 10);

            Position = new Vector3D(vector, formerZ);
            return(true);
        }
Ejemplo n.º 8
0
		public static ParticleSystem ProjectileEffect()
		{
			var projectileEffect = new ParticleSystem();
			var projectileEmitterData = new ParticleEmitterData();
			projectileEmitterData.ParticleMaterial = GetFallbackMaterial();
			projectileEmitterData.SpawnInterval = 0.01f;
			projectileEmitterData.LifeTime = 0;
			projectileEmitterData.MaximumNumberOfParticles = 1;
			projectileEmitterData.Color = new RangeGraph<Color>(Color.Red, Color.Red);
			projectileEmitterData.Size = new RangeGraph<Size>(new Size(0.2f), new Size(0.2f));
			projectileEffect.AttachEmitter(new ParticleEmitter(projectileEmitterData, Vector3D.Zero));
			return projectileEffect;
		}
Ejemplo n.º 9
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),
			};
		}
Ejemplo n.º 10
0
		public static ParticleEmitter CreateHitEffect(Vector2D position)
		{
			var material = new Material(ShaderFlags.Position2DColoredTextured, "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);
		}
Ejemplo n.º 11
0
		public ParticleEmitter(ParticleEmitterData emitterData, Vector3D spawnPosition)
		{
			if (emitterData.ParticleMaterial == null)
				throw new UnableToCreateWithoutMaterial(); //ncrunch: no coverage
			EmitterData = ParticleEmitterData.CopyFrom(emitterData);
			ElapsedSinceLastSpawn = emitterData.SpawnInterval;
			Position = spawnPosition;
			Rotation = Quaternion.Identity;
			lastFramePosition = spawnPosition;
			lastFrameRotation = Quaternion.Identity;
			CreateImageAnimationMaterials();
			StartRendererBasedOnShaderFormat();
		}
Ejemplo n.º 12
0
		public static ParticleSystem AttackEffect()
		{
			var attackEffect = new ParticleSystem();
			var attackEmitterData = new ParticleEmitterData();
			attackEmitterData.ParticleMaterial = GetFallbackMaterial();
			attackEmitterData.StartVelocity = new RangeGraph<Vector3D>(-Vector3D.UnitY);
			attackEmitterData.SpawnInterval = 0;
			attackEmitterData.MaximumNumberOfParticles = 16;
			attackEmitterData.LifeTime = 0.5f;
			attackEmitterData.Size = new RangeGraph<Size>(new Size(0.2f), new Size(0.4f));
			attackEmitterData.Color = new RangeGraph<Color>(Color.Red, Color.TransparentBlack);
			attackEffect.AttachEmitter(new ParticleEmitter(attackEmitterData, Vector3D.Zero));
			return attackEffect;
		}
Ejemplo n.º 13
0
		public EnemyPlane(Vector2D initialPosition)
			: base(ContentLoader.Load<Material>("EnemyPlaneMaterial"), initialPosition)
		{
			Hitpoints = 5;
			verticalDecelerationFactor = 3.0f;
			verticalAccelerationFactor = 1.5f;
			RenderLayer = (int)DefRenderLayer.Player;
			elapsedSinceLastMissile = missileCadenceInverse - 0.2f;
			// ParticleSystemData can very well be loaded by a ContentLoader, unused for simplicity in M5
			//machineGunAndLauncher =
			//	new ParticleSystem(ContentLoader.Load<ParticleSystemData>("MachineGunAndLauncherEnemy"));
			machineGunAndLauncher = new ParticleSystem();

			var machineGunData = new ParticleEmitterData
			{
				ParticleMaterial = ContentLoader.Load<Material>("BulletMaterial"),
				Size = new RangeGraph<Size>(new Size(0.01f, 0.005f), new Size(0.01f, 0.005f)),
				LifeTime = 3.0f,
				StartPosition =
					new RangeGraph<Vector3D>(new Vector3D(0.0f, -0.01f, 0.0f),
						new Vector3D(0.0f, -0.01f, 0.0f)),
				StartRotation =
					new RangeGraph<ValueRange>(new ValueRange(180.0f, 180.0f), new ValueRange(180.0f, 180.0f)),
				StartVelocity = new RangeGraph<Vector3D>(new Vector3D(-0.8f, 0.0f, 0.0f), Vector3D.Zero),
				Acceleration =
					new RangeGraph<Vector3D>(new Vector3D(0.0f, 0.1f, 0.0f), new Vector3D(0.0f, 0.1f, 0.0f)),
				SpawnInterval = 0,
				MaximumNumberOfParticles = 64
			};
			var launcherData = new ParticleEmitterData
			{
				ParticleMaterial = ContentLoader.Load<Material>("RocketMaterial"),
				Size = new RangeGraph<Size>(new Size(0.03f, 0.007f), new Size(0.03f, 0.007f)),
				LifeTime = 3.0f,
				StartPosition = new RangeGraph<Vector3D>(new Vector3D(0.0f, 0.01f, 0.0f), new Vector3D(0.0f, 0.01f, 0.0f)),
				StartRotation =
					new RangeGraph<ValueRange>(new ValueRange(180.0f, 180.0f), new ValueRange(180.0f, 180.0f)),
				StartVelocity = new RangeGraph<Vector3D>(new Vector3D(-0.5f, 0.0f, 0.0f), Vector3D.Zero),
				Acceleration = new RangeGraph<Vector3D>(new Vector3D[] { new Vector3D(0.0f, -0.1f, 0.0f), new Vector3D(0.0f, 0.1f, 0.0f), new Vector3D(0.0f, -0.1f, 0.0f) }),
				SpawnInterval = 0,
				MaximumNumberOfParticles = 8
			};

			machineGunAndLauncher.AttachEmitter(new ParticleEmitter(machineGunData, Vector3D.Zero));
			machineGunAndLauncher.AttachEmitter(new ParticleEmitter(launcherData, Vector3D.Zero));

			machineGunAndLauncher.Position = new Vector3D(initialPosition);
			Add(new Velocity2D(new Vector2D(-0.3f, 0), MaximumSpeed));
			Start<EnemyHandler>();
		}
Ejemplo n.º 14
0
 public ParticleEmitter(ParticleEmitterData emitterData, Vector3D spawnPosition)
 {
     if (emitterData.ParticleMaterial == null)
     {
         throw new UnableToCreateWithoutMaterial();                 //ncrunch: no coverage
     }
     EmitterData           = ParticleEmitterData.CopyFrom(emitterData);
     ElapsedSinceLastSpawn = emitterData.SpawnInterval;
     Position          = spawnPosition;
     Rotation          = Quaternion.Identity;
     lastFramePosition = spawnPosition;
     lastFrameRotation = Quaternion.Identity;
     CreateImageAnimationMaterials();
     StartRendererBasedOnShaderFormat();
 }
Ejemplo n.º 15
0
        /// <summary>
        /// Special behavior of the player's plane for use in the side-scrolling shoot'em'up.
        /// Can be controlled in its vertical position, fire shots and make the environment move.
        /// (It is so mighty that, when it flies faster, in truth the world turns faster!)
        /// </summary>
        public PlayerPlane(Vector2D initialPosition)
            : base(ContentLoader.Load<Material>("PlayerPlaneMaterial"), initialPosition)
        {
            Hitpoints = 3;
            verticalDecelerationFactor = 3.0f;
            verticalAccelerationFactor = 1.5f;
            mgCadenceInverse = PlayerMgCadenceInverse;
            missileCadenceInverse = PlayerMissileCadenceInverse;
            RenderLayer = (int)DefRenderLayer.Player;
            // ParticleSystemData can very well be loaded by a ContentLoader, unused for simplicity in M5
            //machineGunAndLauncher =
            //	new ParticleSystem(ContentLoader.Load<ParticleSystemData>("MachineGunAndLauncher"));
            machineGunAndLauncher = new ParticleSystem();
            var machineGunData = new ParticleEmitterData
            {
                ParticleMaterial = ContentLoader.Load<Material>("BulletMaterial"),
                Size = new RangeGraph<Size>(new Size(0.01f, 0.005f), new Size(0.01f, 0.005f)),
                LifeTime = 3.0f,
                StartPosition =
                    new RangeGraph<Vector3D>(new Vector3D(0.0f, -0.01f, 0.0f),
                        new Vector3D(0.0f, -0.01f, 0.0f)),
                StartVelocity = new RangeGraph<Vector3D>(new Vector3D(0.8f, 0.0f, 0.0f), Vector3D.Zero),
                Acceleration =
                    new RangeGraph<Vector3D>(new Vector3D(0.0f, 0.1f, 0.0f), new Vector3D(0.0f, 0.1f, 0.0f)),
                SpawnInterval = 0,
                MaximumNumberOfParticles = 64
            };
            var launcherData = new ParticleEmitterData
            {
                ParticleMaterial = ContentLoader.Load<Material>("RocketMaterial"),
                Size = new RangeGraph<Size>(new Size(0.03f, 0.007f), new Size(0.03f, 0.007f)),
                LifeTime = 3.0f,
                StartPosition = new RangeGraph<Vector3D>(new Vector3D(0.0f, 0.01f, 0.0f), new Vector3D(0.0f, 0.01f, 0.0f)),
                StartVelocity = new RangeGraph<Vector3D>(new Vector3D(0.3f,0.0f,0.0f), Vector3D.Zero),
                Acceleration = new RangeGraph<Vector3D>(new Vector3D[]{new Vector3D(0.0f, -0.1f, 0.0f), new Vector3D(0.0f, 0.1f, 0.0f), new Vector3D(0.0f, -0.1f, 0.0f)}),
                SpawnInterval = 0,
                MaximumNumberOfParticles = 8
            };

            machineGunAndLauncher.AttachEmitter(new ParticleEmitter(machineGunData, Vector3D.Zero));
            machineGunAndLauncher.AttachEmitter(new ParticleEmitter(launcherData, Vector3D.Zero));

            machineGunAndLauncher.Position = new Vector3D(initialPosition);

            Add(new Velocity2D(Vector2D.Zero, MaximumSpeed));
            Start<PlayerMovement>();
            Start<MachineGunFire>();
        }
Ejemplo n.º 16
0
		public static ParticleEmitter CreateDeathEffect(Vector2D position)
		{
			var material = new Material(ShaderFlags.Position2DColoredTextured, "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);
		}
Ejemplo n.º 17
0
		public Level(Score score)
		{
			brickMaterial = new Material(ShaderFlags.Position2DColoredTextured, "Brick");
			var explosionMaterial = new Material(ShaderFlags.Position2DColoredTextured, "Explosion");
			explosionSound = ContentLoader.Load<Sound>("BrickExplosion");
			lostBallSound = ContentLoader.Load<Sound>("LostBall");
			explosionData = new ParticleEmitterData
			{
				Color = new RangeGraph<Color>(Color.White, Color.TransparentWhite),
				Size = new RangeGraph<Size>(ExplosionSize, ExplosionSize * 2),
				ParticleMaterial = explosionMaterial,
				MaximumNumberOfParticles = 1,
				LifeTime = 0.6f,
				SpawnInterval = -1
			};
			this.score = score;
			Initialize();
		}
Ejemplo n.º 18
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;
			newEmitterData.BillboardMode = otherData.BillboardMode;
			return newEmitterData;
		}
Ejemplo n.º 19
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;
            newEmitterData.BillboardMode           = otherData.BillboardMode;
            return(newEmitterData);
        }
Ejemplo n.º 20
0
		private static MemoryStream SaveTestEmitter()
		{
			var particleEmitterData = new ParticleEmitterData();
			var shader = Create<Shader>(new ShaderCreationData(ShaderFlags.Position2DColoredTextured));
			var image = Create<Image>(new ImageCreationData(new Size(8.0f, 8.0f)));
			particleEmitterData.ParticleMaterial = new Material(shader, image);
			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;
		}
Ejemplo n.º 21
0
		private static Stream CreateEmitter3D(ParticleEmitterPositionType positionType)
		{
			var pointEmitter = new ParticleEmitterData();
			pointEmitter.ParticleMaterial = new Material(ShaderFlags.ColoredTextured, "DeltaEngineLogo");
			pointEmitter.PositionType = positionType;
			var data = BinaryDataExtensions.SaveToMemoryStream(pointEmitter);
			data.Seek(0, SeekOrigin.Begin);
			return data;
		}
Ejemplo n.º 22
0
		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;
		}