Changeset 6208 for 2015/26


Ignore:
Timestamp:
2015-06-23 20:49:18 (4 years ago)
Author:
empaheik
Message:

Ruumiit ja punaiset palkit polttavat ikävästi.

Location:
2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 2015/26/ohjaajat/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun/HillbillyRun.cs

    r6207 r6208  
    1818 *  -2 - Talot taustalla. 
    1919 *   
    20  *  
     20 * CollisionIgnoreGroupit 
     21 *  3 - Ryömivät ja liekit. //TODO: lisätä noidatkin tänne 
     22 *  2 - Kärry. 
    2123 *  
    2224*/ 
     
    2628class HillBilly : PlatformCharacter 
    2729{ 
    28     public HillBilly(double leveys, double korkeus) 
     30    private IntMeter lifeCounter = new IntMeter(2, 0, 2); 
     31    public IntMeter Life  
     32    { 
     33        set { lifeCounter = value; } 
     34        get { return lifeCounter; }  
     35    } 
     36 
     37    public HillBilly(double leveys, double korkeus, HillbillyRun game) 
    2938        : base(leveys, korkeus) 
    3039    { 
    31  
     40         
    3241    } 
    3342} 
     
    3948{ 
    4049    private List<HillBilly> players = new List<HillBilly>(); 
     50    private List<HillBilly> startingPlayers = new List<HillBilly>(); 
     51 
    4152    //private List<double> playerPositionsX = new List<double>(); 
    4253    //private List<double> playerPositionsY = new List<double>(); 
     
    7990    } 
    8091 
     92    #region Intro 
    8193    void IntroSequence() 
    8294    { 
     
    134146        Add(win); 
    135147    } 
     148    #endregion 
    136149 
    137150    void StartGame() 
     
    195208 
    196209        level.SetTileMethod(Color.Gold, CreatePlayer); 
    197         level.SetTileMethod(Color.Rose, CreateDummy, Color.Rose);   //TODO: CreateFlame 
    198210        level.SetTileMethod(Color.Harlequin, CreateCart); 
    199211        level.SetTileMethod(Color.White, CreateBlockObject);  
     
    201213        level.SetTileMethod(Color.Gray, CreateCrawly);   
    202214        level.SetTileMethod(Color.Red, CreateDummy, Color.Red);    //TODO: CreateWitch 
     215        level.SetTileMethod(Color.Rose, CreateFlame);    
     216        //level.SetTileMethod(Color.Azure, CreateDummy, Color.Azure);   //TODO: CreateSmoke 
     217        //level.SetTileMethod(Color.Orange, CreateDummy, Color.Orange); //TODO: CreateTombstone 
    203218        level.Execute(TILE_SIZE, TILE_SIZE); 
    204219        level.Optimize(Color.Black, Color.Brown); 
     
    215230    } 
    216231 
     232    void CreateFlame(Vector position, double width, double height) 
     233    { 
     234        PhysicsObject flame = PhysicsObject.CreateStaticObject(width, height); 
     235        //flame.Image = flameImage; 
     236        flame.Color = Color.Red; 
     237        flame.Position = position; 
     238        flame.CollisionIgnoreGroup = 3; 
     239        flame.Tag = "burn"; 
     240        Add(flame); 
     241    } 
     242 
    217243    void CreateBlockObject(Vector position, double width, double height) 
    218244    { 
     
    238264        crawly.Animation = crawl; 
    239265        crawly.Animation.Start(); 
     266        crawly.Tag = "burn"; 
    240267        crawly.CollisionIgnoreGroup = 3; 
    241268        Add(crawly); 
     
    304331    void CreatePlayer(Vector position, double width, double height) 
    305332    { 
    306         HillBilly player = new HillBilly(width, height * 2); 
     333        HillBilly player = new HillBilly(width, height * 2, this); 
    307334        player.Shape = Shape.Rectangle; 
    308335        player.Position = position + new Vector(0, height * 0.5); 
    309336        player.Color = Color.White; 
    310337        players.Add(player); 
     338        startingPlayers.Add(player); 
    311339        Add(player); 
     340        AddCollisionHandler(player, "burn", delegate(PhysicsObject p, PhysicsObject t)  
     341        { 
     342            HillBilly billy = p as HillBilly; 
     343            billy.Life.Value--; 
     344        } 
     345        ); 
     346 
     347        player.Life.LowerLimit += delegate { players.Remove(player); player.Destroy(); }; 
    312348    } 
    313349 
     
    351387    void SetControls() 
    352388    { 
    353         Keyboard.Listen(Key.A, ButtonState.Down, delegate { players[0].Walk(-300); }, "Player 1 moves left"); 
    354         Keyboard.Listen(Key.D, ButtonState.Down, delegate { players[0].Walk(300); }, "Player 1 moves right"); 
    355         Keyboard.Listen(Key.W, ButtonState.Down, delegate { players[0].Jump(1000); }, "Player 1 jumps"); 
    356  
    357         Keyboard.Listen(Key.Left, ButtonState.Down, delegate { players[1].Walk(-300); }, "Player 2 moves left"); 
    358         Keyboard.Listen(Key.Right, ButtonState.Down, delegate { players[1].Walk(300); }, "Player 2 moves right"); 
    359         Keyboard.Listen(Key.Up, ButtonState.Down, delegate { players[1].Jump(1000); }, "Player 2 jumps"); 
     389        Keyboard.Listen(Key.A, ButtonState.Down, delegate { startingPlayers[0].Walk(-300); }, "Player 1 moves left"); 
     390        Keyboard.Listen(Key.D, ButtonState.Down, delegate { startingPlayers[0].Walk(300); }, "Player 1 moves right"); 
     391        Keyboard.Listen(Key.W, ButtonState.Down, delegate { startingPlayers[0].Jump(1000); }, "Player 1 jumps"); 
     392 
     393        Keyboard.Listen(Key.Left, ButtonState.Down, delegate { startingPlayers[1].Walk(-300); }, "Player 2 moves left"); 
     394        Keyboard.Listen(Key.Right, ButtonState.Down, delegate { startingPlayers[1].Walk(300); }, "Player 2 moves right"); 
     395        Keyboard.Listen(Key.Up, ButtonState.Down, delegate { startingPlayers[1].Jump(1000); }, "Player 2 jumps"); 
    360396 
    361397        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Show help"); 
Note: See TracChangeset for help on using the changeset viewer.