Ignore:
Timestamp:
2014-07-24 11:25:52 (9 years ago)
Author:
aajualal
Message:

Bugs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2014/30/AarniAR/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid.cs

    r5617 r5625  
    77using Jypeli.Widgets; 
    88 
     9class Vihu : PlatformCharacter 
     10{ 
     11    private IntMeter elamaLaskuri = new IntMeter(10, 0, 10); 
     12    public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 
     13 
     14    public Vihu(double leveys, double korkeus) 
     15        : base(leveys, korkeus) 
     16    { 
     17        elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 
     18    } 
     19} 
     20 
     21 
    922public class AdventureOfStarKid : PhysicsGame 
    1023{ 
     
    1427    private Image[] jumpinganimation = LoadImages("jumpinganimation"); 
    1528    private Image[] lifelost = LoadImages("LifeLost"); 
     29    private Image[] damage = LoadImages("Damage"); 
    1630    const double nopeus = 200; 
    1731    const double hyppyNopeus = 750; 
     
    2236 
    2337    PlatformCharacter pelaaja1; 
     38    bool invincible = false; 
    2439 
    2540    Image pelaajanKuva = LoadImage("Standinganimation"); 
     
    6984    void Lisaastumper(Vector paikka, double leveys, double korkeus) 
    7085    { 
    71         PhysicsObject tahti = PhysicsObject.CreateStaticObject(leveys, korkeus); 
    72         tahti.IgnoresCollisionResponse = false; 
    73         tahti.Position = paikka; 
    74         tahti.Image = tahtiKuva; 
    75         tahti.Tag = "stumper"; 
    76         Add(tahti); 
     86        Vihu stumper = new Vihu(leveys-4, korkeus-4); 
     87        stumper.IgnoresCollisionResponse = false; 
     88        stumper.Position = paikka; 
     89        stumper.Image = tahtiKuva; 
     90        stumper.Tag = "stumper"; 
     91        Add(stumper); 
     92        PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 
     93        tasoAivot.Speed = 200; 
     94 
     95        stumper.Brain = tasoAivot; 
     96 
    7797    } 
    7898 
     
    85105        AddCollisionHandler(pelaaja1, "stumper", TormaaTahteen); 
    86106        Add(pelaaja1); 
    87         pelaaja1.AnimWalk = new Animation(running); 
     107        pelaaja1.AnimWalk = new Animation(running, running); 
    88108        pelaaja1.AnimIdle = new Animation(shootinganimation); 
    89109        pelaaja1.AnimJump = new Animation(jumpinganimation); 
    90110        pelaaja1.AnimFall = new Animation(jumpinganimation); 
     111         
    91112        pelaajan1Ase = new PlasmaCannon(1.0, 1.0); 
    92113        pelaajan1Ase.InfiniteAmmo = true; 
     114        pelaajan1Ase.ProjectileCollision += AmmusOsuu; 
    93115        pelaaja1.Weapon = pelaajan1Ase; 
     116    } 
     117 
     118    void AmmusOsuu(PhysicsObject ammus, PhysicsObject kohde) 
     119    { 
     120        ammus.Destroy(); 
     121 
     122        if (kohde.Tag == "stumper") 
     123        { 
     124            (kohde as Vihu).ElamaLaskuri.Value--; 
     125        } 
    94126    } 
    95127 
     
    126158    void TormaaTahteen(PhysicsObject hahmo, PhysicsObject stumper) 
    127159    { 
    128         maaliAani.Play(); 
    129         MessageDisplay.Add("Ouch!"); 
    130         health.Value -= 2; 
    131          
     160        if (!invincible) 
     161        { 
     162            maaliAani.Play(); 
     163            MessageDisplay.Add("Ouch!"); 
     164            health.Value -= 2; 
     165        } 
    132166        //stumper.Destroy(); 
    133167    } 
     168 
    134169    void Ammu(PlasmaCannon Ase) 
    135170    { 
     
    138173        pelaaja1.Animation.Start(); 
    139174    } 
     175 
    140176    void LuoPistelaskuri() 
    141177    { 
     
    144180        health.MinValue = 0; 
    145181        health.LowerLimit += PelaajaHaviaa; 
    146         /* 
     182         
    147183        health.Changed += delegate 
    148184        { 
    149             Animation anim = new Animation(lifelost); 
    150             anim.FPS = 2.0; 
     185            Animation anim = new Animation(damage); 
     186            anim.FPS = 6.0; 
    151187            pelaaja1.PlayAnimation(anim); 
     188            invincible = true; 
     189            Timer.SingleShot(1, delegate { invincible = false; }); 
    152190        }; 
    153          */ 
     191         
    154192        ProgressBar healthMeter = new ProgressBar(150, 20); 
    155193        healthMeter.X = Screen.Left + 150; 
Note: See TracChangeset for help on using the changeset viewer.