Exemplo n.º 1
0
        private ExplosionParticle[,] GetExplosionParticles()
        {
            int sizeX         = (int)Target.Width / (int)ParticleSize;
            int sizeY         = (int)Target.Height / (int)ParticleSize;
            int shapesToSpawn = sizeX * sizeY;

            if (Target.Model is Shape)
            {
                Shape targetModel = Target.Model as Shape;
                Queue <ExplosionParticle> objects = Game.ExplosionParticlePool.Retrieve(Target.Model.GetType(), shapesToSpawn);
                ExplosionParticle[,] particles = new ExplosionParticle[sizeX, sizeY];
                for (int x = 0; x < sizeX; x++)
                {
                    for (int y = 0; y < sizeY; y++)
                    {
                        particles[x, y]                      = objects.Dequeue();
                        particles[x, y].Speed                = ParticleSpeed;
                        particles[x, y].SpinRate             = this.SpinRate;
                        particles[x, y].FadeOut              = this.FadeOut;
                        particles[x, y].Width                = ParticleSize;
                        particles[x, y].Height               = ParticleSize;
                        particles[x, y].Fill                 = targetModel.Fill;
                        particles[x, y].TargetDirection      = GameHelper.GetDirection(Game.Rand);
                        particles[x, y].LifeTimeMilliseconds = TimeSpanMilliseconds;
                    }
                }
                return(particles);
            }
            return(null);
        }
Exemplo n.º 2
0
        private void SetProjectile()
        {
            RotateTransform transform = FiringWeapon.Model.RenderTransform as RotateTransform;
            float           angle     = (float)transform.Angle;

            Rotate(angle, 0, Height);
            targetDirection  = GameHelper.GetDirection(angle);
            Model.Visibility = Visibility.Visible;
        }