コード例 #1
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>();
        }
コード例 #2
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>();
        }
コード例 #3
0
 public void AddEmitterToSystem(ParticleEmitter existingEmitter = null)
 {
     currentEffect.AttachEmitter(existingEmitter ??
                                 new ParticleEmitter(CreateDefaultEmitterData(), Vector3D.Zero));
     currentEmitterInEffect = currentEffect.AttachedEmitters.Count - 1;
     RefreshAllEffectProperties();
     RaisePropertyChanged("AvailableEmitterIndices");
 }
コード例 #4
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;
		}
コード例 #5
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;
		}
コード例 #6
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;
		}
コード例 #7
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;
		}
コード例 #8
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;
		}
コード例 #9
0
        private ParticleEmitter CreateAndAttachEmitter(Vector3D emitterPosition)
        {
            var textureData = new ImageCreationData(new Size(32));
            var material    = new Material(ContentLoader.Create <Shader>(
                                               new ShaderCreationData(ShaderFlags.ColoredTextured)),
                                           ContentLoader.Create <Image>(textureData));
            var emitterData = new ParticleEmitterData {
                ParticleMaterial = material
            };
            var emitter = new ParticleEmitter(emitterData, emitterPosition);

            particleSystem.AttachEmitter(emitter);
            return(emitter);
        }