Changeset 6295


Ignore:
Timestamp:
2015-06-24 22:51:14 (4 years ago)
Author:
empaheik
Message:

Nimet + elämät, etualan ruohot (optimointia vähentämällä, hmm), kenttä vaihtuu, kun bossin tappaa, restart.

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

Legend:

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

    r6293 r6295  
    5454        HillbillyRun game = this.Game as HillbillyRun; 
    5555        Owner.PlayAnimation(Animations[1]); 
    56         game.CreateMilkParticles(this.Owner); 
     56        game.CreateMilkParticles(this.Owner, 10, 200, 300, new Vector(0, -30), "milkparticle"); 
    5757         
    5858    } 
     
    7878    public Improvement Improvement { get; set; } 
    7979 
     80    public Label Name { get; set; } 
     81 
     82    private ProgressBar visibleLife; 
     83    public ProgressBar VisibleLife 
     84    { 
     85        get { return visibleLife; } 
     86        set { visibleLife = value; } 
     87    } 
     88 
    8089    public void GainImprovement(Improvement improvement) 
    8190    { 
     
    96105    } 
    97106 
    98     public HillBilly(double leveys, double korkeus) 
     107    public HillBilly(double leveys, double korkeus, String name) 
    99108        : base(leveys, korkeus) 
    100109    { 
    101110 
     111        this.visibleLife = new ProgressBar(50, 15); //(this.Width, this.Height/8); 
     112        this.Add(visibleLife); 
     113        this.visibleLife.Position += new Vector(0, this.Height / 2 + this.Height / 5); 
     114        this.visibleLife.BindTo(this.lifeCounter); 
     115        this.visibleLife.Color = Color.Black; 
     116 
     117        this.Name = new Label(name); 
     118        this.Add(Name); 
     119        this.Name.Position += new Vector(0, this.Height / 2 + this.Height / 3); 
    102120    } 
    103121} 
     
    117135    public const double TILE_SIZE = 70; 
    118136 
     137    public String[] names = new String[] { "Adolfiina", "Rasputiina", "Hermanniina", "Joosefiina"}; 
     138         
    119139    private double cameraTargetX; // Sijainti jossa kameran pitäisi olla. 
    120140    private Vector cameraTarget; 
     
    369389        //level.SetTileMethod(Color.Azure, CreateDummy, Color.Azure);   //TODO: CreateSmoke 
    370390        //level.SetTileMethod(Color.Orange, CreateDummy, Color.Orange); //TODO: CreateTombstone 
    371         level.Optimize(Color.Black, Color.Brown); 
     391        level.Optimize(Color.Brown);    //Color.Black   //Tekee jännittäviä asioita wheatille, jos optimoidaan (tietysti). Jotenn.  
    372392        level.Execute(TILE_SIZE, TILE_SIZE); 
    373393    } 
     
    574594                    mage.Destroy(); 
    575595                    castTimer.Stop(); 
    576                     //NextLevel();  
     596                    NextLevel();  
    577597                } 
    578598                Timer.SingleShot(0.5, delegate { immune = false; }); 
     
    639659    void CreatePlayer(Vector position, double width, double height) 
    640660    { 
    641         HillBilly player = new HillBilly(width, height * 2); 
     661        HillBilly player = new HillBilly(width, height * 2, names[players.Count()]); 
    642662        player.Shape = Shape.Rectangle; 
    643663        player.Position = position + new Vector(0, height * 0.5); 
     
    741761 
    742762        Keyboard.Listen(Key.F12, ButtonState.Pressed, NextLevel, null); 
     763        Keyboard.Listen(Key.R, ButtonState.Pressed, StartGame, null); 
    743764 
    744765        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Show help"); 
     
    746767    } 
    747768 
    748     public void CreateMilkParticles(HillBilly billy) 
     769    public void CreateMilkParticles(HillBilly billy, int size, int xBase, int yBase, Vector position, String tag) 
    749770    { 
    750771        for (int i = 0; i < 10; i++) 
    751772        { 
    752773            const double maxLife = 1.0; 
    753             PhysicsObject milkParticle = new PhysicsObject(10, 10, Shape.Circle); 
     774            PhysicsObject milkParticle = new PhysicsObject(size, size, Shape.Circle); 
    754775            milkParticle.Color = new Color(255, 255, 255, 128); 
    755             milkParticle.Position = billy.Position + new Vector(0, -30); 
     776            milkParticle.Position = billy.Position + position; 
    756777            milkParticle.IgnoresCollisionResponse = true; 
    757             milkParticle.Tag = "milkparticle"; 
     778            milkParticle.Tag = tag; 
    758779            milkParticle.LifetimeLeft = TimeSpan.FromSeconds(maxLife); 
    759780            Add(milkParticle); 
     
    772793            var rx = RandomGen.NextDouble(-50, 50); 
    773794            var ry = RandomGen.NextDouble(-50, 50); 
    774             milkParticle.Hit(new Vector(billy.FacingDirection.GetVector().X * (200 + rx), 300 + ry)); 
     795            milkParticle.Hit(new Vector(billy.FacingDirection.GetVector().X * (xBase + rx), yBase + ry)); 
    775796        } 
    776797    } 
     
    780801        if (player.Improvement == null) 
    781802        { 
    782             player.Jump(200);   //TODO: CRY ALL THE TEARS  :'( 
     803 
     804            CreateMilkParticles(player, 5, 100, 100, new Vector(0, player.Height/3), "tears"); 
     805            //for (int i = 0; i < 5; i++) 
     806            //{ 
     807            //    const double maxLife = 1.0; 
     808            //    PhysicsObject milkParticle = new PhysicsObject(5, 5, Shape.Circle); 
     809            //    milkParticle.Color = new Color(255, 255, 255, 128); 
     810            //    milkParticle.Position = player.Position + new Vector(0, player.Height / 3); 
     811            //    milkParticle.IgnoresCollisionResponse = true; 
     812            //    milkParticle.LifetimeLeft = TimeSpan.FromSeconds(maxLife); 
     813            //    Add(milkParticle); 
     814 
     815            //    // Väri muuttuu läpinäkyväksi. 
     816            //    var fadeTimer = new Timer { Interval = 0.07 }; 
     817            //    fadeTimer.Timeout += delegate 
     818            //    { 
     819            //        byte c = 255; 
     820            //        milkParticle.Color = new Color(c, c, c, (byte)(128 * milkParticle.LifetimeLeft.TotalSeconds / maxLife)); 
     821            //    }; 
     822            //    fadeTimer.Start(); 
     823            //    milkParticle.Destroyed += fadeTimer.Stop; 
     824 
     825            //    // Random lentonopeus. 
     826            //    var rx = RandomGen.NextDouble(-50, 50); 
     827            //    var ry = RandomGen.NextDouble(-50, 50); 
     828            //    milkParticle.Hit(new Vector(player.FacingDirection.GetVector().X * (100 + rx), 100 + ry)); 
     829            //} 
    783830            return; 
    784831        } 
Note: See TracChangeset for help on using the changeset viewer.