public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager Content) { base.Initialize(Content); scene.World.BeginContact += OnContact; scene.World.EndContact += AfterContact; AsType.CreateFramesFromXML("break_frames"); switch (material) { case BodyMaterial.WOOD: AsType.CurrentFrame = "wood"; Body.Mass = 0.5f; Body.Friction = 3; Body.Restitution = 0.1f; health = 1.5f; break; case BodyMaterial.GLASS: AsType.CurrentFrame = "glass"; Body.Mass = 0.8f; Body.Friction = 2; Body.Restitution = 0.1f; health = 0.9f; break; case BodyMaterial.CONCRETE: AsType.CurrentFrame = "cement"; Body.Mass = 1.5f; Body.Friction = 6; Body.Restitution = 0.01f; health = 4.0f; break; } maxHealth = health; Width = Body.Width; // *AsType.ScaleX; Height = Body.Height; // *AsType.ScaleY; UniformScale = 1.0f; if (Math.Abs(Height / Width - 1) < 0.3f && Height < 80) { AsType.CurrentFrame = AsType.CurrentFrame + "_block"; } else if (Math.Abs(Height / Width - 1) < 0.3f) { AsType.CurrentFrame = AsType.CurrentFrame + "_square"; } else if (Height / Width > 5) { AsType.CurrentFrame = AsType.CurrentFrame + "_long"; } AsType.UpdateOrigin(); for (float f = Height * ScaleY / 2.0f; f > -Height * ScaleY / 2.0f; f -= 80)//Height * ScaleY / 5.0f) { for (float j = Height * ScaleY / 2.0f; j > -Height * ScaleY / 2.0f; j -= 80) { // for (int i = 0; i < 4; i++) { //if (BaseGame.Random.Next(1, 5) == 2) { Vector2 fuzz = new Vector2(RandomFloatInRange(-Width / 2.0f, Width / 2.0f), RandomFloatInRange(-Width / 2.0f, Width / 2.0f)); // Vector2 firstPos = Position + f * rotDir + fuzz; Splinter s = new Splinter(material); s.ScaleMultiplier = (Width * Height) / 10000.0f; s.Initialize(BaseGame.Get.Content); //s.Position = firstPos; //scene.AddNode(s); preMadeSplinters.Add(s); } } } } }
public override void Initialize(Microsoft.Xna.Framework.Content.ContentManager Content) { base.Initialize(Content); scene.World.BeginContact += OnContact; scene.World.EndContact += AfterContact; AsType.CreateFramesFromXML("break_frames"); switch (material) { case BodyMaterial.WOOD: AsType.CurrentFrame = "wood"; Body.Mass = 0.5f; Body.Friction = 3; Body.Restitution = 0.1f; health = 1.5f; break; case BodyMaterial.GLASS: AsType.CurrentFrame = "glass"; Body.Mass = 0.8f; Body.Friction = 2; Body.Restitution = 0.1f; health = 0.9f; break; case BodyMaterial.CONCRETE: AsType.CurrentFrame = "cement"; Body.Mass = 1.5f; Body.Friction = 6; Body.Restitution = 0.01f; health = 4.0f; break; } maxHealth = health; Width = Body.Width;// *AsType.ScaleX; Height = Body.Height;// *AsType.ScaleY; UniformScale = 1.0f; if (Math.Abs(Height / Width - 1) < 0.3f && Height < 80) { AsType.CurrentFrame = AsType.CurrentFrame + "_block"; } else if (Math.Abs(Height / Width - 1) < 0.3f) { AsType.CurrentFrame = AsType.CurrentFrame + "_square"; } else if (Height / Width > 5) { AsType.CurrentFrame = AsType.CurrentFrame + "_long"; } AsType.UpdateOrigin(); for (float f = Height * ScaleY / 2.0f; f > -Height * ScaleY / 2.0f; f -= 80)//Height * ScaleY / 5.0f) { for (float j = Height * ScaleY / 2.0f; j > -Height * ScaleY / 2.0f; j -= 80) { // for (int i = 0; i < 4; i++) { //if (BaseGame.Random.Next(1, 5) == 2) { Vector2 fuzz = new Vector2(RandomFloatInRange(-Width / 2.0f, Width / 2.0f), RandomFloatInRange(-Width / 2.0f, Width / 2.0f)); // Vector2 firstPos = Position + f * rotDir + fuzz; Splinter s = new Splinter(material); s.ScaleMultiplier = (Width * Height) / 10000.0f; s.Initialize(BaseGame.Get.Content); //s.Position = firstPos; //scene.AddNode(s); preMadeSplinters.Add(s); } } } } }