Ignore:
Timestamp:
2015-06-24 18:31:58 (8 years ago)
Author:
sieerinn
Message:

Maidon loiskuttelua säädetty. Ekan velhon animaatiot lisätty.

File:
1 edited

Legend:

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

    r6280 r6283  
    2424*/ 
    2525 
    26 #region Improvement  
    27 public abstract class Improvement :PlatformCharacter 
     26#region Improvement 
     27public abstract class Improvement : PlatformCharacter 
    2828{ 
    29     private List<Animation> animations; 
    30     public List<Animation> Animations 
    31     { 
    32         get { return animations; } 
    33         set { animations = value; } 
    34     } 
     29    public List<Animation> Animations { get; set; } 
    3530 
    3631    protected Improvement(double width, double height) 
     
    4338    { 
    4439        get { return owner; } 
    45         set {  owner = value; } 
     40        set { owner = value; } 
    4641    } 
    4742    private HillBilly owner; 
     
    5146 
    5247//Luokka maajussien erikoisuuksille. 
    53 public class MilkImprovement: Improvement 
     48public class MilkImprovement : Improvement 
    5449{ 
    5550 
     
    6257 
    6358    public MilkImprovement(double width, double height) 
    64         :base(width, height) 
     59        : base(width, height) 
    6560    { 
    6661 
     
    7974    } 
    8075 
    81     private Improvement improvement; 
    82     public Improvement Improvement 
    83     { 
    84         set { improvement = value;} 
    85         get { return improvement; } 
    86     } 
     76    public Improvement Improvement { get; set; } 
    8777 
    8878    public void GainImprovement(Improvement improvement) 
     
    9888    public void UseImprovement(Improvement improvement) 
    9989    { 
    100         this.PlayAnimation(improvement.Animations[1]); 
    101         improvement.DoTheThing(); 
     90        if (Animation != improvement.Animations[1]) 
     91        { 
     92            this.PlayAnimation(improvement.Animations[1], improvement.DoTheThing); 
     93        } 
    10294    } 
    10395 
     
    479471            crawly.Tag = ""; 
    480472            flame.Destroy(); 
     473            RemoveCollisionHandlers(crawly); 
    481474        }); 
    482475    } 
     
    623616    } 
    624617 
    625     public void CreateMilkParticles(HillBilly billy)        //TODO: Tiny particles. 
    626     { 
    627         PhysicsObject milkParticle = new PhysicsObject(20, 20); 
    628         milkParticle.Position = billy.Position; 
    629         milkParticle.Tag = "milkparticle"; 
    630         Add(milkParticle); 
     618    public void CreateMilkParticles(HillBilly billy) 
     619    { 
     620        for (int i = 0; i < 10; i++) 
     621        { 
     622            const double maxLife = 1.0; 
     623            PhysicsObject milkParticle = new PhysicsObject(10, 10, Shape.Circle); 
     624            milkParticle.Color = new Color(255, 255, 255, 128); 
     625            milkParticle.Position = billy.Position + new Vector(0, -30); 
     626            milkParticle.IgnoresCollisionResponse = true; 
     627            milkParticle.Tag = "milkparticle"; 
     628            milkParticle.LifetimeLeft = TimeSpan.FromSeconds(maxLife); 
     629            Add(milkParticle); 
     630 
     631            // Väri muuttuu läpinäkyväksi. 
     632            var fadeTimer = new Timer { Interval = 0.05 }; 
     633            fadeTimer.Timeout += delegate 
     634            { 
     635                byte c = 255; 
     636                milkParticle.Color = new Color(c, c, c, (byte)(128 * milkParticle.LifetimeLeft.TotalSeconds / maxLife)); 
     637            }; 
     638            fadeTimer.Start(); 
     639            milkParticle.Destroyed += fadeTimer.Stop; 
     640 
     641            // Random lentonopeus. 
     642            var rx = RandomGen.NextDouble(-50, 50); 
     643            var ry = RandomGen.NextDouble(-50, 50); 
     644            milkParticle.Hit(new Vector(billy.FacingDirection.GetVector().X * (200 + rx), 300 + ry)); 
     645        } 
    631646    } 
    632647 
    633648    private void UseImprovement(HillBilly player) 
    634649    { 
    635         if(player.Improvement == null) 
    636         { 
    637             player.Jump(200);   //TODO: CRY ALL THE TEARS 
     650        if (player.Improvement == null) 
     651        { 
     652            player.Jump(200);   //TODO: CRY ALL THE TEARS  :'( 
    638653            return; 
    639654        } 
Note: See TracChangeset for help on using the changeset viewer.