Ignore:
Timestamp:
2016-06-15 14:57:44 (3 years ago)
Author:
karkaite
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2016/24/AnttuK/SUO/SUO/SUO/SUO.cs

    r7298 r7340  
    1010{ 
    1111    Image plImg = LoadImage("Untitled"); 
     12    Image alien = LoadImage("alien"); 
    1213    PhysicsObject player; 
    1314    IntMeter counter; 
     
    1617    public override void Begin() 
    1718    { 
    18         CreateCounter(); 
    1919        SetKeys(); 
    2020        SetLevel(); 
     
    3434        Add(counterDisp); 
    3535    } 
    36     void Restart(PhysicsObject obj1, PhysicsObject obj2) 
     36    void Restart(Boolean lose) 
    3737    { 
    3838        ClearAll(); 
    39         MessageDisplay.Add("You Lose! Try Again?"); 
    40         CreateCounter(); 
     39        if (lose) 
     40        { 
     41            MessageDisplay.Add("You Lose! Try Again?"); 
     42        } 
    4143        SetKeys(); 
    4244        SetLevel(); 
    4345    } 
    44     void Win(PhysicsObject obj1, PhysicsObject obj2) 
     46    void Win() 
    4547    { 
    4648        if (counter.Value == 0) 
     
    6163        Keyboard.Listen(Key.Up, ButtonState.Down, MovePlayer, null, new Vector(0, 50)); 
    6264        Keyboard.Listen(Key.Down, ButtonState.Down, MovePlayer, null, new Vector(0, -50)); 
    63         Keyboard.Listen(Key.R, ButtonState.Down, Restart, null, player,player); 
     65        Keyboard.Listen(Key.R, ButtonState.Down, Restart, null, false); 
    6466    } 
    6567    void SetLevel() 
    6668    { 
    67          
     69        CreateCounter(); 
    6870        TileMap tiles = TileMap.FromLevelAsset("level1"); 
    6971        tiles.SetTileMethod('#', CreateRect, Color.Gray); 
     
    9597        player.Tag = "player"; 
    9698        player.CollisionIgnoreGroup = 1; 
    97         AddCollisionHandler(player, "flag", Win); 
     99        AddCollisionHandler<PhysicsObject, PhysicsObject>(player, "flag", delegate { Win(); } ); 
    98100        AddCollisionHandler(player, "star", CountAndDestroy); 
    99101        Add(player); 
     
    113115        PhysicsObject enem = new PhysicsObject(width*0.75, height*0.75); 
    114116        enem.Position = pos; 
    115         enem.Shape = Shape.Diamond; 
    116         enem.Color = Color.Ruby; 
     117        enem.Image = alien; 
    117118        enem.Restitution = 1.0; 
    118119        enem.Tag = "enemy"; 
    119120        enem.Brain = smartEnem; 
    120  
    121         AddCollisionHandler(enem, "player", Restart); 
     121        // FIXME idiotic collisionhandler 
     122        AddCollisionHandler<PhysicsObject, PhysicsObject>(enem, "player", delegate { Restart(true); } ); 
    122123        Add(enem); 
    123124    } 
Note: See TracChangeset for help on using the changeset viewer.