Changeset 5199 for 2014/27


Ignore:
Timestamp:
2014-07-01 10:43:04 (5 years ago)
Author:
mijoilmo
Message:

refaktoroin luokan omaan tiedostoon

Location:
2014/27/AleksanteriV/Protokolla236/Protokolla236/Protokolla236
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • 2014/27/AleksanteriV/Protokolla236/Protokolla236/Protokolla236/Protokolla236.cs

    r5198 r5199  
    88 
    99// apuva lista: 
    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 } 
    6110 
    6211public class Portti : PhysicsObject 
  • 2014/27/AleksanteriV/Protokolla236/Protokolla236/Protokolla236/Protokolla236.csproj

    r5197 r5199  
    111111  </ItemGroup> 
    112112  <ItemGroup> 
     113    <Compile Include="MikonPhysicsObject.cs" /> 
    113114    <Compile Include="Ohjelma.cs" /> 
    114115    <Compile Include="Protokolla236.cs" /> 
Note: See TracChangeset for help on using the changeset viewer.