Changeset 4449 for 2013


Ignore:
Timestamp:
2013-07-04 20:05:08 (6 years ago)
Author:
jumakall
Message:
 
Location:
2013/27/TeemuM/Game/Game/Game
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2013/27/TeemuM/Game/Game/Game/Game.cs

    r4448 r4449  
    156156            else if (commands[0] == "die") 
    157157            { 
    158                 // UI.GameOver(); 
     158                player.canMove = false; 
     159                GameOver(); 
    159160            } 
    160161            else if (commands[0] == "exit") 
     
    308309        Add(LifeBar); 
    309310    } 
     311 
     312 
     313 
     314    private void GameOver() 
     315    { 
     316        GameObject layer = new GameObject(Game.Screen.Width, Game.Screen.Height); 
     317        layer.Color = Color.Transparent; 
     318        layer.Position = player.Position; 
     319        Add(layer, 1); 
     320        layer.FadeColorTo(Color.Lerp(Color.Transparent, Color.Black, 0.8), 1.0); 
     321 
     322        Label t = new Label("Game over"); 
     323        t.Position = player.Position; 
     324        t.TextColor = Color.White; 
     325        Add(t, 1); 
     326 
     327        Timer.SingleShot(1, delegate { IsPaused = true; }); 
     328    } 
    310329} 
  • 2013/27/TeemuM/Game/Game/Game/Player.cs

    r4446 r4449  
    99public class Player : PhysicsObject 
    1010{ 
     11    private static Image playerImage = Game.LoadImage("Player"); 
     12 
     13 
    1114    const double defaultSpeed = 1000; 
    1215    const int defaultPower = 10000; 
    13     private static Image playerImage = Game.LoadImage("Player"); 
     16    private double speed = defaultSpeed; 
     17    private double power = defaultPower; 
    1418 
    1519    private Weapon weapon; 
    16     private double speed = defaultSpeed; 
    1720    public IntMeter health; 
    18     private double power = defaultPower; 
    1921    public bool canMove = true; 
     22 
     23    //Handlers 
     24    public delegate void EmptyHandler(); 
     25 
     26    //Events 
     27    public event EmptyHandler Dying; 
    2028 
    2129    public Player(double width, double height, int health, bool addDefaultControls) : base(width, height) 
     
    2432        this.health.LowerLimit += delegate 
    2533        { 
    26             GameObject layer = new GameObject(Game.Screen.Width, Game.Screen.Height); 
    27             layer.Color = Color.Transparent; 
    28             layer.Position = this.Position; 
    29             Game.Add(layer, 1); 
    30             layer.FadeColorTo(Color.Lerp(Color.Transparent, Color.Black, 0.8), 1.0); 
    31  
    32             Label t = new Label("Game over"); 
    33             t.Position = this.Position; 
    34             Game.Add(t); 
    35  
    36             Timer.SingleShot(1, delegate { Game.IsPaused = true; }); 
     34             
    3735 
    3836            this.Destroy(); 
Note: See TracChangeset for help on using the changeset viewer.