Example #1
0
 void TykkiOsui(PhysicsObject ammus, PhysicsObject kohde)
 {
     if (kohde == tankki)
     {
         return;
     }
     if (kohde.Tag.ToString() == "tyyppi")
     {
         tirskahdus.AddEffect(ammus.Position, 2);
         kohde.LinearDamping = 1;
         kohde.Animation     = new Animation(ukkoPutoaaKuvat);
     }
     else if (kohde.Tag.ToString() == "kopteri")
     {
         tykinOsuma.AddEffect(ammus.Position, 2);
         kohde.IgnoresGravity = false;
         kohde.Animation      = new Animation(kopteriPutaaKuvat);
         kohde.Animation.FPS  = 12;
         kohde.Animation.Start();
     }
     else if (kohde.Tag.ToString() == "laskeutunut")
     {
         tirskahdus.AddEffect(ammus.Position, 2);
         kohde.Destroy();
         miesLaskuri.Value++;
     }
     else if (kohde == maa || kohde.Tag.ToString() == "reuna")
     {
         ammus.Destroy();
     }
 }
Example #2
0
 /// <summary>
 /// Lisää efektin sen olion kohdalle, johon törmätään.
 /// </summary>
 /// <param name="expSystem">Efektijärjestelmä</param>
 /// <param name="numParticles">Kuinka monta partikkelia laitetaan</param>
 /// <returns></returns>
 public static CollisionHandler <PhysicsObject, PhysicsObject> AddEffectOnTarget(ExplosionSystem expSystem, int numParticles)
 {
     return(delegate(PhysicsObject collidingObject, PhysicsObject targetObject)
     {
         expSystem.AddEffect(targetObject.Position, numParticles);
     });
 }
Example #3
0
    void LaskuvarjonTormays(PhysicsObject tyyppi, PhysicsObject kohde)
    {
        if (kohde != tankki && kohde != maa && kohde.Tag.ToString() != "reuna" && kohde.Tag.ToString() != "tankki")
        {
            return;
        }

        tyyppiLista.Remove(tyyppi);
        tyyppi.Destroy();

        if (kohde == tankki)
        {
            tirskahdus.AddEffect(tyyppi.Position, 2);
            miesLaskuri.Value++;
        }
        else if (kohde == maa)
        {
            if (tyyppi.LinearDamping < 1)
            {
                tyyppiLista.Add(LuoLaskeutunut(tyyppi.X, tyyppi.Y));
                return;
            }
            else
            {
                tirskahdus.AddEffect(tyyppi.Position, 2);
                miesLaskuri.Value++;
                return;
            }
        }
    }
Example #4
0
    void TormaaTahteen2(PhysicsObject hahmo, PhysicsObject tahti2)
    {
        rajahdys.AddEffect(hahmo.X, hahmo.Y, 50);

        maaliAani.Play();
        MessageDisplay.Add("Otit Osuman   D:");
        laskuri.Value      -= 1;
        elamaLaskuri.Value -= 3;
        tahti2.Destroy();
    }
Example #5
0
    void AmmuTykilla(Tank t)
    {
        t.Cannon.Power.Value = voimaMittari.Value;
        PhysicsObject ammus = t.Cannon.Shoot();

        if (ammus != null)
        {
            ammus.Mass = 100;
            tykkiSuuliekki.AddEffect(ammus.Position, 25);
        }

        voimaMittari.Value = 0;
    }
Example #6
0
 void LaskeutuneenLuotiOsui(PhysicsObject ammus, PhysicsObject kohde)
 {
     if (kohde.Tag.ToString() == "laskeutunut")
     {
         return;
     }
     if (kohde == tankki)
     {
         hpMittari.Value -= 10.0;
         ammus.Destroy();
         tankkiinOsui.AddEffect(ammus.Position, 30);
     }
     else
     {
         ammus.Destroy();
     }
 }
Example #7
0
 void KopterinTormays(PhysicsObject kopteri, PhysicsObject kohde)
 {
     if (kohde.Tag.ToString() == "reuna")
     {
         if (kopteri.Velocity.Y < 0)
         {
             kopteri.Destroy();
             kopteriLaskuri.Value++;
         }
     }
     else if (kohde == maa)
     {
         kopteriRajahdys.AddEffect(kopteri.Position, 50);
         kopteri.Destroy();
         kopteriLaskuri.Value++;
     }
 }
Example #8
0
    private void StarXplosion(int currentStar, int ofStars, GameObject onTopOfTarget)
    {
        if (currentStar > 0 && currentStar <= 3)
        {
            ExplosionSystem starplosion = new ExplosionSystem(LoadImage("juststar"), 50);
            starplosion.MinVelocity = starplosion.MinVelocity / 2;
            starplosion.MaxVelocity = starplosion.MaxVelocity / 2;
            Add(starplosion, 3);
            var explosionPosition = new Vector(
                onTopOfTarget.AbsolutePosition.X - onTopOfTarget.Width / 2 + currentStar * onTopOfTarget.Width / 4,
                onTopOfTarget.AbsolutePosition.Y - onTopOfTarget.Height / 3);
            onTopOfTarget.Image = LoadImage(String.Format("level_{0}star", currentStar));
            starplosion.AddEffect(explosionPosition, 5 + 5 * currentStar);

            if (currentStar < ofStars)
            {
                Timer.SingleShot(starplosion.MaxLifetime,
                                 () => StarXplosion(currentStar + 1, ofStars, onTopOfTarget));
            }
        }
    }
Example #9
0
 void HpLoppu()
 {
     tankki.Destroy();
     tankkiRajahdys.AddEffect(tankki.Position, 150);
     Timer.SingleShot(10, AloitaAlusta);
 }