Changeset 5625 for 2014/30/AarniAR/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid.cs
- Timestamp:
- 2014-07-24 11:25:52 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/AarniAR/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid/AdventureOfStarKid.cs
r5617 r5625 7 7 using Jypeli.Widgets; 8 8 9 class 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 9 22 public class AdventureOfStarKid : PhysicsGame 10 23 { … … 14 27 private Image[] jumpinganimation = LoadImages("jumpinganimation"); 15 28 private Image[] lifelost = LoadImages("LifeLost"); 29 private Image[] damage = LoadImages("Damage"); 16 30 const double nopeus = 200; 17 31 const double hyppyNopeus = 750; … … 22 36 23 37 PlatformCharacter pelaaja1; 38 bool invincible = false; 24 39 25 40 Image pelaajanKuva = LoadImage("Standinganimation"); … … 69 84 void Lisaastumper(Vector paikka, double leveys, double korkeus) 70 85 { 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 77 97 } 78 98 … … 85 105 AddCollisionHandler(pelaaja1, "stumper", TormaaTahteen); 86 106 Add(pelaaja1); 87 pelaaja1.AnimWalk = new Animation(running );107 pelaaja1.AnimWalk = new Animation(running, running); 88 108 pelaaja1.AnimIdle = new Animation(shootinganimation); 89 109 pelaaja1.AnimJump = new Animation(jumpinganimation); 90 110 pelaaja1.AnimFall = new Animation(jumpinganimation); 111 91 112 pelaajan1Ase = new PlasmaCannon(1.0, 1.0); 92 113 pelaajan1Ase.InfiniteAmmo = true; 114 pelaajan1Ase.ProjectileCollision += AmmusOsuu; 93 115 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 } 94 126 } 95 127 … … 126 158 void TormaaTahteen(PhysicsObject hahmo, PhysicsObject stumper) 127 159 { 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 } 132 166 //stumper.Destroy(); 133 167 } 168 134 169 void Ammu(PlasmaCannon Ase) 135 170 { … … 138 173 pelaaja1.Animation.Start(); 139 174 } 175 140 176 void LuoPistelaskuri() 141 177 { … … 144 180 health.MinValue = 0; 145 181 health.LowerLimit += PelaajaHaviaa; 146 /*182 147 183 health.Changed += delegate 148 184 { 149 Animation anim = new Animation( lifelost);150 anim.FPS = 2.0;185 Animation anim = new Animation(damage); 186 anim.FPS = 6.0; 151 187 pelaaja1.PlayAnimation(anim); 188 invincible = true; 189 Timer.SingleShot(1, delegate { invincible = false; }); 152 190 }; 153 */191 154 192 ProgressBar healthMeter = new ProgressBar(150, 20); 155 193 healthMeter.X = Screen.Left + 150;
Note: See TracChangeset
for help on using the changeset viewer.