Esempio n. 1
0
 public override void update()
 {
     if (activated)
     {
         for (int i = 0; i < pPerUpdate; i++)
         {
             double coneRadians = (coneRadius * Math.PI) / 180.0;
             double angle       = (random.NextDouble() * coneRadians * 2) + direction - coneRadians;
             float  v           = pVelocity;
             if (pMinVelocity != -1)
             {
                 v = (float)random.NextDouble() * (pVelocity - pMinVelocity) + pMinVelocity;
             }
             int lifeTime = pLifeTime;
             if (pMinLifeTime != -1)
             {
                 lifeTime = (int)(random.NextDouble() * (pLifeTime - pMinLifeTime) + pMinLifeTime);
             }
             Vector2  velocity = MapTools.AngleToVector((float)angle) * v;
             Particle particle = new Particle(particleType, pos, pSize, velocity, lifeTime, pLoop, pFrameskip);
             particle.illuminationStrength = pIlluminationStrength;
             particle.gravityFactor        = pGravityFactor;
             particle.bounceFactor         = pBounceFactor;
             particle.dampenFactor         = pDampenFactor;
             Game1.world.particles.Add(particle);
         }
     }
 }
Esempio n. 2
0
        public override void Update()
        {
            angle += angleSpeed * 0.001f;

            raycast.dir  = MapTools.AngleToVector(angle - MathHelper.Pi * 0.5f);
            raycast.pos  = pos + raycast.dir * 10;
            hitOfRaycast = raycast.getHit();
            if (hitOfRaycast.obj is Player)
            {
                Game1.getPlayer().die();
            }
            //           Game1.world.particles.Add(new Particle(hitOfRaycast.pos.X - raycast.dir.X * 5, hitOfRaycast.pos.Y - raycast.dir.Y * 5, 5, 5, new Vector2(((float)new Random().NextDouble() - 0.5f) * 20.0f, ((float)new Random().NextDouble() - 0.5f) * 20.0f)));
            particleEmitter.pos.X     = hitOfRaycast.pos.X;
            particleEmitter.pos.Y     = hitOfRaycast.pos.Y;
            particleEmitter.Direction = angle - Math.PI * (0.5f - Math.Sign(angleSpeed) * 0.2f) + Math.PI;
            particleEmitter.update();
            base.Update();
        }
Esempio n. 3
0
        public override void Update()
        {
            speed *= 1.0125f;
            Vector2 playerPos = Game1.getPlayer().getCenter();

            speed.Normalize();
            Vector2 pointRotatedUp   = getCenter() + Vector2.Transform(speed, Matrix.CreateRotationZ(0.1f));
            Vector2 pointRotatedDown = getCenter() + Vector2.Transform(speed, Matrix.CreateRotationZ(-0.1f));

            if ((playerPos - pointRotatedUp).Length() < (playerPos - pointRotatedDown).Length())
            {
                if (angleSpeed < 0)
                {
                    angleSpeed = 0;
                }
                angleSpeed += 0.001f;
            }
            if ((playerPos - pointRotatedUp).Length() > (playerPos - pointRotatedDown).Length())
            {
                if (angleSpeed > 0)
                {
                    angleSpeed = 0;
                }
                angleSpeed -= 0.001f;
            }
            angle += angleSpeed;
            speed  = MapTools.AngleToVector(angle);
            speed *= travelSpeed;

            if (collidesWithMap().collided)
            {
                destroy = true;

                Light light = new PointLight
                {
                    Position  = new Vector2(getCenter().X, getCenter().Y) - speed,
                    Scale     = new Vector2(500), // Range of the light source (how far the light will travel)
                    Radius    = 1f,
                    Intensity = 1f,

                    Color        = new Color(1f, 0.5f, 0, 1),
                    CastsShadows = false,
                    ShadowType   = ShadowType.Illuminated // Will not lit hulls themselves
                };

                ExplosionHandler.addExplosion(light);
            }
            if (CollidesWithPlayer())
            {
                Game1.getPlayer().die();

                Light light = new PointLight
                {
                    Position  = new Vector2(getCenter().X, getCenter().Y) - speed,
                    Scale     = new Vector2(1500), // Range of the light source (how far the light will travel)
                    Radius    = 1f,
                    Intensity = 1f,

                    Color      = new Color(5f, 0.5f, 0, 1),
                    ShadowType = ShadowType.Solid // Will not lit hulls themselves
                };

                ExplosionHandler.addExplosion(light);
            }
            smokeEmitter.pos       = oldPos;
            smokeEmitter.Direction = angle + Math.PI;
            smokeEmitter.update();

            if (destroy == true)
            {
                particleEmitter.pos = oldPos;
                particleEmitter.start();
                particleEmitter.update();
            }
            oldPos = pos;
            base.Update();
        }
Esempio n. 4
0
        public override void Update()
        {
            if (frames % 120 == 119)
            {
                Game1.world.addItem(new CanonBall(Game1.cManager, pos.X, pos.Y, size.X, size.Y, MapTools.AngleToVector(angle - (float)Math.PI * 0.5f)));
                frames = 0;
            }


            frames++;
            base.Update();
        }