Changeset 5381
- Timestamp:
- 2014-07-03 14:59:43 (9 years ago)
- Location:
- 2014/27/PekkaR
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/27/PekkaR/D2x_2d/D2x_2d/D2x_2d/D2x_2d.cs
r5334 r5381 30 30 } 31 31 32 public void setShield(int t) 33 { 34 if (t > 0) shield.Value = t; 32 public 33 #if DEBUG 34 virtual 35 #endif 36 Explosion setShield(int t) 37 { 38 if (t > 0) 39 { 40 shield.Value = t; 41 return null; 42 } 35 43 else 36 44 { 37 45 shield.Value = 0; 46 Explosion r = new Explosion(50); 47 r.Position = Position; 48 r.Force = 500; 38 49 Destroy(); 50 return r; 39 51 } 40 52 } … … 54 66 } 55 67 68 #if DEBUG 69 public override Explosion setShield(int t) 70 { 71 return null; 72 } 73 #endif 74 56 75 public IntMeter getEnergyMeter() 57 76 { … … 59 78 } 60 79 80 public void AddEnergy(int inc) 81 { 82 energy.Value += inc; 83 } 84 85 public void Lataa() 86 { 87 if(energy.Value < 200) energy.Value = 200; 88 } 89 61 90 public Ammus Ammu() 62 91 { 63 #if DEBUG92 #if !DEBUG 64 93 if (energy.Value > 0) 65 94 { 66 95 #endif 67 Ammus a = new Ammus(1, "ToV", Angle.GetVector());68 69 70 71 #if DEBUG96 Ammus a = new Ammus(4, "ToV", Angle.GetVector(), 1); 97 a.Position = Position; 98 energy.Value--; 99 return a; 100 #if !DEBUG 72 101 } 73 102 else return null; … … 78 107 public class Vihollinen : Shieldable 79 108 { 80 private int deal ;81 82 public Vihollinen(int d, int w, int h ) : base(w, h)109 private int deal, koko; 110 111 public Vihollinen(int d, int w, int h, int k) : base(w, h) 83 112 { 84 113 deal = d; 114 koko = k; 85 115 Tag = "vihollinen"; 116 Color = Color.Green; 86 117 } 87 118 … … 89 120 { 90 121 Vector s = (kohde.Position - Position).Normalize(); 91 Ammus a = new Ammus(deal, "ToP", s );122 Ammus a = new Ammus(deal, "ToP", s, koko); 92 123 a.Position = Position; 93 124 return a; … … 99 130 private int deal; 100 131 101 public Ammus(int d, string t, Vector suunta) : base(3, 3) 132 public Ammus(int d, string t, Vector suunta, int koko) 133 : base(3 * koko, 3 * koko) 102 134 { 103 135 deal = d; … … 107 139 KineticFriction = 1; 108 140 MomentOfInertia = Double.PositiveInfinity; 109 Timer.SingleShot(2.0, Destroy); 110 Hit(suunta * 100); 141 Color = Color.Red; 142 Timer.SingleShot(5.0, Destroy); 143 Hit(suunta * 120); 111 144 } 112 145 … … 118 151 119 152 protected Pelaaja pelaaja; 153 protected PhysicsObject exit; 154 protected Vihollinen reaktori; 120 155 121 156 private bool playeradded = false; … … 132 167 private void LuoKuuntelijat() 133 168 { 134 Keyboard.Listen(Key.A, ButtonState.Down, delegate { pelaaja.Velocity = pelaaja.Angle.GetVector() * 50; }, null);169 Keyboard.Listen(Key.A, ButtonState.Down, delegate { pelaaja.Velocity = pelaaja.Angle.GetVector() * 70; }, null); 135 170 Keyboard.Listen(Key.A, ButtonState.Released, delegate { pelaaja.Velocity = Vector.Zero; }, null); 136 Keyboard.Listen(Key.Z, ButtonState.Down, delegate { pelaaja.Velocity = pelaaja.Angle.GetVector() * - 50; }, null);171 Keyboard.Listen(Key.Z, ButtonState.Down, delegate { pelaaja.Velocity = pelaaja.Angle.GetVector() * -70; }, null); 137 172 Keyboard.Listen(Key.Z, ButtonState.Released, delegate { pelaaja.Velocity = Vector.Zero; }, null); 138 Keyboard.Listen(Key.Left, ButtonState.Down, delegate { if (altpressed) pelaaja.Velocity = (pelaaja.Angle + Angle.RightAngle).GetVector() * 50; else pelaaja.Angle = pelaaja.Angle + (Angle.RightAngle / 50); }, null);173 Keyboard.Listen(Key.Left, ButtonState.Down, delegate { if (altpressed) pelaaja.Velocity = (pelaaja.Angle + Angle.RightAngle).GetVector() * 70; else pelaaja.Angle = pelaaja.Angle + (Angle.RightAngle / 40); }, null); 139 174 Keyboard.Listen(Key.Left, ButtonState.Released, delegate { pelaaja.Velocity = Vector.Zero; }, null); 140 Keyboard.Listen(Key.Right, ButtonState.Down, delegate { if (altpressed) pelaaja.Velocity = (pelaaja.Angle - Angle.RightAngle).GetVector() * 50; else pelaaja.Angle = pelaaja.Angle - (Angle.RightAngle / 50); }, null);175 Keyboard.Listen(Key.Right, ButtonState.Down, delegate { if (altpressed) pelaaja.Velocity = (pelaaja.Angle - Angle.RightAngle).GetVector() * 70; else pelaaja.Angle = pelaaja.Angle - (Angle.RightAngle / 40); }, null); 141 176 Keyboard.Listen(Key.Right, ButtonState.Released, delegate { pelaaja.Velocity = Vector.Zero; }, null); 142 177 Keyboard.Listen(Key.LeftAlt, ButtonState.Pressed, delegate { altpressed = true; }, null); … … 172 207 ruudut.SetTileMethod('P', LuoPelaaja); 173 208 ruudut.SetTileMethod('V', LuoVihollinen); 174 ruudut.SetTileMethod('|', LuoPystySeina); 175 ruudut.SetTileMethod('-', LuoVaakaSeina); 209 ruudut.SetTileMethod('-', LuoSeina); 210 ruudut.SetTileMethod('S', LuoShield); 211 ruudut.SetTileMethod('E', LuoEnergia); 212 ruudut.SetTileMethod('C', LuoLatauspaikka); 213 ruudut.SetTileMethod('X', LuoExit); 214 ruudut.SetTileMethod('R', LuoReaktori); 215 ruudut.SetTileMethod('@', LuoExitTak); 216 ruudut.Optimize('-'); 176 217 ruudut.Execute(40, 40); 177 218 } … … 184 225 private void LuoVihollinen(Vector paikka, double leveys, double korkeus) 185 226 { 186 Vihollinen vih = new Vihollinen(1, 10, 10 );227 Vihollinen vih = new Vihollinen(1, 10, 10, 1); 187 228 vih.Position = paikka; 188 229 vih.Tag = "vihollinen"; 189 230 vih.setShield(10); 190 231 Timer ajastin = new Timer(); 191 ajastin.Interval = 1.5;192 ajastin.Timeout += delegate { if (!(pelaaja.IsDestroyed || vih.IsDestroyed) && RandomGen.NextBool()) Add(vih.Ammu(pelaaja)); };232 ajastin.Interval = 0.8; 233 ajastin.Timeout += delegate { if (!(pelaaja.IsDestroyed || vih.IsDestroyed) && RandomGen.NextBool()) Add(vih.Ammu(pelaaja)); vih.Move(RandomGen.NextVector(20, 20)); }; 193 234 ajastin.Start(); 194 235 AddCollisionHandler<Vihollinen, Ammus>(vih, "ammusToV", Osuma); … … 196 237 } 197 238 198 private void LuoPystySeina(Vector paikka, double leveys, double korkeus) 199 { 200 PhysicsObject seina = PhysicsObject.CreateStaticObject(leveys, korkeus); 201 seina.Position = paikka; 202 seina.Tag = "seina"; 203 AddCollisionHandler<PhysicsObject, Ammus>(seina, KasitteleAmmus); 204 Add(seina); 205 } 206 207 private void LuoVaakaSeina(Vector paikka, double leveys, double korkeus) 239 private void LuoSeina(Vector paikka, double leveys, double korkeus) 208 240 { 209 241 PhysicsObject seina = PhysicsObject.CreateStaticObject(leveys, korkeus); … … 244 276 Add(pelaaja); 245 277 Camera.Follow(pelaaja); 278 Camera.Zoom(1.6); 246 279 playeradded = true; 247 280 248 281 } 249 282 250 private void Osuma(Shieldable pelaaja, Ammus kohde) 251 { 252 pelaaja.setShield(pelaaja.getShield() - kohde.getDeal()); 283 private void LuoShield(Vector paikka, double leveys, double korkeus) 284 { 285 PhysicsObject shield = new PhysicsObject(10, 10); 286 shield.Position = paikka; 287 shield.Shape = Shape.Circle; 288 shield.Color = Color.Blue; 289 AddCollisionHandler<PhysicsObject, Pelaaja>(shield, "pelaaja", delegate { pelaaja.setShield(pelaaja.getShield() + 20); shield.Destroy(); }); 290 Add(shield); 291 } 292 293 private void LuoEnergia(Vector paikka, double leveys, double korkeus) 294 { 295 PhysicsObject energia = new PhysicsObject(10, 10); 296 energia.Position = paikka; 297 energia.Shape = Shape.Circle; 298 energia.Color = Color.Yellow; 299 AddCollisionHandler<PhysicsObject, Pelaaja>(energia, "pelaaja", LisaaEnergiaa); 300 Add(energia); 301 } 302 303 private void LuoLatauspaikka(Vector paikka, double leveys, double korkeus) 304 { 305 PhysicsObject lp = PhysicsObject.CreateStaticObject(leveys, korkeus); 306 lp.Position = paikka; 307 lp.Shape = Shape.Rectangle; 308 lp.Color = Color.Yellow; 309 AddCollisionHandler<PhysicsObject, Pelaaja>(lp, "pelaaja", delegate { pelaaja.Lataa(); }); 310 Add(lp); 311 } 312 313 private void LuoReaktori(Vector paikka, double leveys, double korkeus) 314 { 315 reaktori = new Vihollinen(5, 30, 30, 2); 316 reaktori.Position = paikka; 317 reaktori.MakeStatic(); 318 reaktori.Color = Color.OrangeRed; 319 reaktori.setShield(50); 320 AddCollisionHandler<Shieldable, Ammus>(reaktori, "ammusToV", Osuma); 321 Timer ajastin = new Timer(); 322 ajastin.Interval = 0.6; 323 ajastin.Timeout += delegate { if (!(pelaaja.IsDestroyed || reaktori.IsDestroyed) && RandomGen.NextBool()) Add(reaktori.Ammu(pelaaja)); }; 324 ajastin.Start(); 325 Add(reaktori); 326 } 327 328 private void LuoExit(Vector paikka, double leveys, double korkeus) 329 { 330 exit = PhysicsObject.CreateStaticObject(leveys, korkeus); 331 exit.Position = paikka; 332 exit.Color = Color.Brown; 333 Add(exit); 334 } 335 336 private void LuoExitTak(Vector paikka, double leveys, double korkeus) 337 { 338 PhysicsObject et = PhysicsObject.CreateStaticObject(leveys, korkeus); 339 et.Position = paikka; 340 et.Color = new Color(255, 255, 255, 0); 341 AddCollisionHandler<PhysicsObject, Pelaaja>(et, "pelaaja", delegate { ClearAll(); playeradded = false; MessageDisplay.Add("You won the game"); Begin(); }); 342 Add(et); 343 } 344 345 private void Osuma(Shieldable p, Ammus kohde) 346 { 347 Explosion a = p.setShield(p.getShield() - kohde.getDeal()); 348 if (a != null) 349 { 350 Add(a); 351 if (p == reaktori) 352 { 353 exit.Destroy(); 354 IntMeter jaika = new IntMeter(0); 355 jaika.Value = 50; 356 Timer jak = new Timer(); 357 Timer.SingleShot(50, delegate { }); 358 jak.Interval = 1; 359 jak.Timeout += delegate { jaika.Value--; }; 360 } 361 } 253 362 kohde.Destroy(); 254 363 } 364 365 private void LisaaEnergiaa(PhysicsObject energ, Pelaaja kohde) 366 { 367 kohde.AddEnergy(300); 368 energ.Destroy(); 369 } 255 370 } -
2014/27/PekkaR/D2x_2d/D2x_2d/D2x_2d/obj/x86/Debug/ContentPipeline-{D8F805CA-FFFC-4C76-8CBF-A2C6D544F284}.xml
r5334 r5381 9 9 <Options>None</Options> 10 10 <Output>C:\MyTemp\PekkaR\D2x_2d\D2x_2d\D2x_2d\bin\x86\Debug\Content\1.xnb</Output> 11 <Time>2014-07-0 2T10:44:19.4955557+03:00</Time>11 <Time>2014-07-03T14:13:08.0639897+03:00</Time> 12 12 </Item> 13 13 <Item> … … 18 18 <Options>None</Options> 19 19 <Output>C:\MyTemp\PekkaR\D2x_2d\D2x_2d\D2x_2d\bin\x86\Debug\Content\2.xnb</Output> 20 <Time>2014-07-03T1 0:07:44.1509966+03:00</Time>20 <Time>2014-07-03T14:32:46.3308046+03:00</Time> 21 21 </Item> 22 22 <BuildSuccessful>true</BuildSuccessful> -
2014/27/PekkaR/D2x_2d/D2x_2d/D2x_2dContent/1.txt
r5274 r5381 1 |-----| 2 | V| 3 | | 4 |P | 5 |-----| 1 ------- 2 - V- 3 - - 4 -P - 5 ------- -
2014/27/PekkaR/D2x_2d/D2x_2d/D2x_2dContent/2.txt
r5334 r5381 7 7 - V- 8 8 -- - 9 -V - 10 -------- ----- 11 - V -V - 12 - ----- - 13 - -- 14 - V- 15 - - 16 - V - 17 ----------------- 9 -V - ---- 10 -------- ----- C- 11 - V -V -V---- 12 - ----- - 13 - ---- - 14 - E V- - ---- 15 - S - - -- 16 - V - - R- 17 -X--------------- ------- 18 @
Note: See TracChangeset
for help on using the changeset viewer.