Ignore:
Timestamp:
2017-11-18 14:59:00 (17 months ago)
Author:
rikavila
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/PaavoH/Shootdown/Shootdown/Shootdown/Shootdown.cs

    r9474 r9481  
    2020    PlatformCharacter Player1; 
    2121    PlatformCharacter Player2; 
    22     AssaultRifle Player1Gun; 
    23     AssaultRifle Player2Gun; 
    2422 
    2523    SoundEffect maaliAani = LoadSoundEffect("maali"); 
     
    5250        kentta.SetTileMethod('1', AddPlayer1); 
    5351        kentta.SetTileMethod('2', AddPlayer2); 
     52        kentta.SetTileMethod('A', AddAmmoBox); 
    5453        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    5554        Level.CreateBorders(false); 
     
    6564    } 
    6665 
    67  
     66    void AddAmmoBox(Vector paikka, double leveys, double korkeus) 
     67    { 
     68        PhysicsObject AmmoBox = PhysicsObject.CreateStaticObject(leveys, korkeus); 
     69        AmmoBox.Position = paikka; 
     70        AmmoBox.Color = Color.Gold; 
     71        AmmoBox.Tag = "AmmoBox"; 
     72        Add(AmmoBox); 
     73    } 
    6874 
    6975    void AddPlayer1(Vector paikka, double width, double height) 
     
    7379        Player1.Mass = 4.0; 
    7480        Player1.Image = pelaajanKuva; 
     81        AddCollisionHandler(Player1, "AmmoBox", MoreAmmo); 
    7582        Add(Player1); 
    7683 
    7784        Player1.Weapon = new AssaultRifle(30, 10); 
    78         Player1.Weapon.Ammo.Value = 1000; 
     85        Player1.Weapon.Ammo.Value = 50; 
    7986        Player1.Weapon.Image = ShotgunImage; 
    8087        Player1.Weapon.ProjectileCollision = BulletTouch; 
     
    8996        Player2.Mass = 4.0; 
    9097        Player2.Image = pelaajanKuva; 
     98        AddCollisionHandler(Player2, "AmmoBox", MoreAmmo); 
    9199        Add(Player2); 
    92100 
     
    95103        Player2.Weapon = new AssaultRifle(30, 10); 
    96104 
    97         Player2.Weapon.Ammo.Value = 1000; 
     105        Player2.Weapon.Ammo.Value = 50; 
    98106        Player2.Weapon.Image = ShotgunImage; 
    99107        Player2.Weapon.ProjectileCollision = BulletTouch; 
     
    193201        //MessageDisplay.Add(p); 
    194202    } 
     203 
     204    void MoreAmmo(PhysicsObject Player, PhysicsObject AmmoBox) 
     205    { 
     206 
     207        (Player as PlatformCharacter).Weapon.Ammo.Value = 50; 
     208        AmmoBox.Destroy(); 
     209    } 
    195210} 
    196211 
Note: See TracChangeset for help on using the changeset viewer.