- Timestamp:
- 2014-07-01 10:39:54 (9 years ago)
- Location:
- 2014/27/AleksanteriV/Protokolla236
- Files:
-
- 97 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/27/AleksanteriV/Protokolla236/Protokolla236/Protokolla236/Protokolla236.cs
r5197 r5198 9 9 // apuva lista: 10 10 11 public class MikonPhysicsObject : PhysicsObject 12 { 13 private bool broken = false; 14 private Protokolla236 game; 15 public void Break(int method, int pieceCountX = 2, int pieceCountY = 2) 16 { 17 if (this.broken) { return; } 18 this.Destroy(); 19 this.broken = true; 20 switch (method) 21 { 22 case 0://uniform break 23 var pieceWidth = this.Width / pieceCountX; 24 var pieceHeight = this.Height / pieceCountY; 25 if (pieceWidth < 1 || pieceHeight < 1) { return; } 26 //loop x and y through 27 //calc left corner 28 var startCorner = Vector.FromLengthAndAngle(this.Width / 2 - pieceWidth / 2, this.AbsoluteAngle + Angle.StraightAngle) + Vector.FromLengthAndAngle(this.Height / 2 - pieceHeight / 2, this.AbsoluteAngle - Angle.RightAngle); //vasen alakulma 29 30 for (int y = 0; y < pieceCountY; y++) 31 { 32 for (int x = 0; x < pieceCountX; x++) 33 { 34 MikonPhysicsObject childBox = new MikonPhysicsObject(this.game, pieceWidth, pieceHeight); 35 childBox.Color = this.Color; 36 childBox.AbsoluteAngle = this.AbsoluteAngle; 37 childBox.AngularVelocity = this.AngularVelocity; 38 39 childBox.Position = this.Position + startCorner 40 + Vector.FromLengthAndAngle(x * pieceWidth, this.AbsoluteAngle) //plus x 41 + Vector.FromLengthAndAngle(y * pieceHeight, this.AbsoluteAngle + Angle.RightAngle); //plus y 42 43 childBox.Velocity = this.Velocity; 44 45 //childBox.Position += offset; 46 47 Game.Add(childBox); 48 } 49 } 50 break; 51 } 52 } 53 public MikonPhysicsObject(Protokolla236 game, double w, double h) 54 : base(w, h) 55 { 56 // TODO: Complete member initialization 57 //game.AddCollisionHandler(game.level, this, delegate { this.Break(0, 2, 2); }); 58 this.game = game; 59 } 60 } 11 61 12 62 public class Portti : PhysicsObject … … 274 324 void LuoTaso(Vector paikka, double leveys, double korkeus, Animation kuva) 275 325 { 276 PhysicsObject taso = PhysicsObject.CreateStaticObject(leveys, korkeus); 326 MikonPhysicsObject taso = new MikonPhysicsObject(this, leveys, korkeus); 327 taso.MakeStatic(); 277 328 taso.Position = paikka; 278 329 taso.Tag = "taso"; … … 467 518 { 468 519 ammus.Destroy(); 469 if (kohde.Tag.ToString() == "vihu") 470 { 471 kohde.Destroy(); 472 520 switch(kohde.Tag.ToString()){ 521 case "vihu":case "sikio": 522 kohde.Destroy(); 523 break; 524 case "taso": 525 ((MikonPhysicsObject)kohde).Break(0,2,2); 526 break; 473 527 } 474 else if (kohde.Tag.ToString() == "sikio")475 {476 kohde.Destroy();477 }478 479 528 } 480 529
Note: See TracChangeset
for help on using the changeset viewer.