Ignore:
Timestamp:
2013-06-28 10:53:42 (10 years ago)
Author:
juiitamm
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2013/26/OtsoR/Projekti/Projekti/Projekti/Projekti.cs

    r4286 r4295  
    9292    IntMeter shipcolor2; 
    9393    IntMeter shipWeapon2; 
     94    IntMeter points; 
    9495    int shipcounter; 
    9596    int bigshipcounter; 
     
    382383    void enemydeath() 
    383384    { 
    384         //shipcounter--; 
     385        shipcounter--; 
     386        points.Value += 5; 
    385387    } 
    386388    void bigenemydeath() 
    387389    { 
    388         //bigshipcounter--; 
     390        bigshipcounter--; 
     391        points.Value += 40; 
    389392    } 
    390393    void boss1death() 
     
    599602                ammus.Size *= 0.4; 
    600603                ammus.CollisionIgnoreGroup = 4; 
    601                 AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 
     604                AddCollisionHandler(ammus, AmmusOsui); 
    602605            } 
    603606            if (ase is LaserGun) 
     
    610613            { 
    611614                ammus.Size *= 0.9; 
    612                 AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 
     615                AddCollisionHandler(ammus, AmmusOsui); 
    613616                ammus.IgnoresCollisionResponse = true; 
    614617                ammus.CollisionIgnoreGroup = 3; 
     
    634637        } 
    635638    } 
     639    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
     640    { 
     641        if (kohde.Tag == "powerup") 
     642        { 
     643            return; 
     644        } 
     645        ammus.Destroy(); 
     646    } 
     647 
    636648    void missilehit(PhysicsObject tormaaja, PhysicsObject kohde) 
    637649    { 
    638         tormaaja.Destroy(); 
     650        if (kohde.Tag == "powerup") 
     651        { 
     652            return; 
     653        } 
    639654        Explosion missilecrash = new Explosion(8); 
    640655        missilecrash.Position = tormaaja.Position; 
    641656        missilecrash.UseShockWave = false; 
    642657        Add(missilecrash); 
     658        tormaaja.Destroy(); 
    643659    } 
    644660    void firehoming(Weapon ase) 
     
    741757        Controlsship(); 
    742758 
     759        Timer spawnrune = new Timer(); 
     760        spawnrune.Interval = 15; 
     761        spawnrune.Timeout += Spawnrunes; 
     762        spawnrune.Start(); 
     763 
     764        points = new IntMeter(0); 
     765        Label pointsdisplay = new Label(); 
     766        pointsdisplay.Title = "Points"; 
     767        pointsdisplay.X = Screen.Right - 100; 
     768        pointsdisplay.Y = Screen.Top - 100; 
     769        pointsdisplay.TextColor = Color.White; 
     770        pointsdisplay.Color = Color.Black; 
     771        pointsdisplay.BindTo(points); 
     772        Add(pointsdisplay); 
     773 
    743774        Timer a = new Timer(); 
    744775        a.Interval = 8; 
     
    758789        Controlsship2(); 
    759790 
    760         Timer a = new Timer(); 
    761         a.Interval = 8; 
    762         a.Timeout += Spawnhostiles; 
    763         a.Start(); 
    764     } 
    765  
     791        Timer spawnrune = new Timer(); 
     792        spawnrune.Interval = 15; 
     793        spawnrune.Timeout += Spawnrunes; 
     794        spawnrune.Start(); 
     795 
     796        points = new IntMeter(0); 
     797        Label pointsdisplay = new Label(); 
     798        pointsdisplay.Title = "Points"; 
     799        pointsdisplay.X = Screen.Right - 100; 
     800        pointsdisplay.Y = Screen.Top - 100; 
     801        pointsdisplay.TextColor = Color.White; 
     802        pointsdisplay.Color = Color.Black; 
     803        pointsdisplay.BindTo(points); 
     804        Add(pointsdisplay); 
     805 
     806        Timer spawnenemy = new Timer(); 
     807        spawnenemy.Interval = 8; 
     808        spawnenemy.Timeout += Spawnhostiles; 
     809        spawnenemy.Start(); 
     810    } 
    766811    void Spawnrunes() 
    767812    { 
    768813        while (runecounter < 5) 
    769814        { 
    770             int runetype = RandomGen.NextInt(0, 2); 
     815            int runetype = RandomGen.NextInt(1, 3); 
    771816            double runey = 0.0; 
    772817            double runex = 0.0; 
    773             if (RandomGen.NextBool()) 
    774             { 
    775                 runey = Level.Bottom + 2 * Level.Top * RandomGen.NextInt(0, 2); 
    776                 runex = RandomGen.NextDouble(Level.Left, Level.Right); 
    777             } 
    778             else 
    779             { 
    780                 runey = RandomGen.NextDouble(Level.Bottom, Level.Top); 
    781                 runex = Level.Left + 2 * Level.Right * RandomGen.NextInt(0, 2); 
    782             } 
    783             Createhostile(runetype, runey, runex); 
     818            Vector paikka = Level.GetRandomFreePosition(5.0); 
     819            runey = paikka.Y; 
     820            runex = paikka.X; 
     821            Createrune(runetype, runey, runex); 
    784822            runecounter++; 
    785823        } 
     
    787825    void Createrune(int runetype, double y, double x) 
    788826    { 
    789         PhysicsObject Rune = new PhysicsObject(5, 5); 
     827        PhysicsObject Rune = new PhysicsObject(10, 10); 
    790828        Rune.X = x; 
    791829        Rune.Y = y; 
    792830        Rune.CollisionIgnoreGroup = 2 & 3 & 4; 
     831        Rune.IgnoresCollisionResponse = true; 
     832        Rune.MakeStatic(); 
     833        Rune.Tag = "powerup"; 
     834        Rune.AngularVelocity = 5; 
     835        Add(Rune); 
    793836        switch (runetype) 
    794837        { 
     
    796839                //Addcollision 
    797840                Rune.Image = rdamage; 
     841                Rune.Height = 15; 
     842                Rune.Width = 10; 
    798843                AddCollisionHandler(Rune, "player", delegate(PhysicsObject tormaaja, Player ship) { damagerune(tormaaja, ship); }); 
    799844                break; 
     
    801846                //Addcollision 
    802847                Rune.Image = rrepair; 
    803                 AddCollisionHandler(Rune, "player", delegate(PhysicsObject tormaaja, Player ship) { damagerune(tormaaja, ship); }); 
     848                AddCollisionHandler(Rune, "player", delegate(PhysicsObject tormaaja, Player ship) { repairrune(tormaaja, ship); }); 
     849                Rune.Height = 14; 
     850                Rune.Width = 14; 
    804851                break; 
    805852            case 3: 
     
    812859    { 
    813860        rune.Destroy(); 
     861        weapon.FireRate *= 2; 
     862        Timer.SingleShot(10, delegate{ weapon.FireRate *=0.5; }); 
     863        runecounter--; 
    814864    } 
    815865    void repairrune(PhysicsObject rune, Player ship) 
    816866    { 
     867        ship.Health.Value += 100; 
    817868        rune.Destroy(); 
     869        runecounter--; 
    818870    } 
    819871    //void rune3(PhysicsObject rune, Player ship) 
Note: See TracChangeset for help on using the changeset viewer.