Changeset 179
- Timestamp:
- 2009-07-24 13:10:31 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
henri_t/Kill em' all/Peli.cs
r169 r179 19 19 { 20 20 #region Muuttujat 21 Weapon ase1; 21 22 22 23 const double liikeVoima = 4000; … … 39 40 DrawPerimeter = false; // ei haluta piirtää kentän reunoja 40 41 vihollisajastin = new Timer(); 42 vihollisajastin.Interval = 60; 43 vihollisajastin.Trigger += new Timer.TriggerHandler(vihollisajastin_Trigger); 44 AddTimer(vihollisajastin); 45 vihollisajastin.Start(); 41 46 42 47 // Asetetaan painovoima … … 48 53 } 49 54 55 void vihollisajastin_Trigger(Timer sender) 56 { 57 ObjectIgnorer ignorer = new ObjectIgnorer(); 58 59 for (int i = 0; i < 3; i++) 60 { 61 PlatformCharacter vihollinen = new PlatformCharacter(Shapes.CreateCircle(30), 100, 1); 62 nazibrain aivot = new nazibrain(); 63 vihollinen.Brain = aivot; 64 aivot.target = pelaaja1; 65 vihollinen.X = RandomGen.NextDouble(4900, 0); 66 vihollinen.Y = 300; 67 vihollinen.Body.CollisionIgnorer = ignorer; 68 69 Direction suunta = RandomGen.NextDirection(); 70 71 72 Texture2D[] tekstuurit = 73 { 74 Content.Load<Texture2D>( "nazi1" ), 75 Content.Load<Texture2D>( "nazi2" ), 76 Content.Load<Texture2D>( "nazi3" ), 77 78 }; 79 80 AnimatedTexture kavelyTekstuuri = new AnimatedTexture(tekstuurit); 81 kavelyTekstuuri.FPS = 0; 82 vihollinen.RightWalkingTexture = kavelyTekstuuri; 83 vihollinen.LeftWalkingTexture = Textures.Mirror(kavelyTekstuuri); 84 vihollinen.RightIdleTexture = new AnimatedTexture(Content.Load<Texture2D>("nazi1")); 85 vihollinen.LeftIdleTexture = new AnimatedTexture(Textures.Mirror(Content.Load<Texture2D>("nazi2"))); 86 vihollinen.AnimationPerPixel = 0.0005; 87 Level.Objects.Add(vihollinen); 88 LuoAse(Level, vihollinen); 89 vihollinen.HitpointsReachedZero += new EventHandler(poistaVihollinen); 90 } 91 } 92 50 93 void aloitaUusiPeli() 51 94 { … … 193 236 Controls.Listen(Keys.Up, ButtonPosition.Pressed, hyppaa, "Hyppää", pelaaja1, hyppyVoima); 194 237 Controls.Listen(Keys.Space, ButtonPosition.Down, Ammu, "Ammu", pelaaja1.Weapon); 195 Controls.Listen(Keys.Z, ButtonPosition.Pressed, hyppaa, "", pelaaja1, hyppyVoima);238 Controls.Listen(Keys.Z, ButtonPosition.Pressed, vaihdaase, "vaihdaase", pelaaja1, hyppyVoima); 196 239 lisaaGamePadNappaimet(PlayerIndex.One, pelaaja1); 197 240 } … … 216 259 } 217 260 261 bool vaihdaase(ControlEvent e) 262 { 263 PlatformCharacter hahmo = e.Parameter0 as PlatformCharacter; 264 265 LuoAse2(Level, hahmo); 266 267 return false; 268 269 } 270 218 271 bool hyppaa(ControlEvent e) 219 272 { … … 229 282 bool Ammu(ControlEvent e) 230 283 { 231 Weapon ase = e.Parameter0 as Weapon; 232 Projectile ammus = ase.Use(); 284 //Weapon ase = e.Parameter0 as Weapon; 285 //Projectile ammus = ase.Use(); 286 Projectile ammus = ase1.Use(); 233 287 234 288 if (ammus != null) … … 261 315 kentta.Objects.Add(hahmo.Weapon); 262 316 hahmo.EquipWeapon(); 317 ase1 = hahmo.Weapon; 263 318 } 264 319 void LuoAse2 (Level kentta, PlatformCharacter hahmo) 265 320 { // Luoteja aseeseen 321 Weapon vanhaase = pelaaja1.Weapon; 266 322 Projectile luoti = new PlasmaParticle(); 267 323 luoti.Size = new Vector2D(5, 1); … … 274 330 kentta.Objects.Add(hahmo.Weapon); 275 331 hahmo.EquipWeapon(); 332 ase1 = hahmo.Weapon; 333 vanhaase.Lifetime.IsExpired = true; 334 276 335 } 277 336
Note: See TracChangeset
for help on using the changeset viewer.