示例#1
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();
        }
示例#2
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();
        }