private void colide(Star star1) { Star star2; if (((star2 = star1.ColisionsRef) != null) && star2.Enabled) { star1.ColisionsRef = null; if (star2.ColisionsRef != null) { colide(star2); } double massPS1 = star1.AbsMass / (star1.AbsMass + star2.AbsMass); double massPS2 = star2.AbsMass / (star1.AbsMass + star2.AbsMass); if (star2 == data.SelectetStar) { data.SelectetStar = star1; } if (star2 == data.FocusStar) { data.FocusStar = star1; } if (star2 == data.RefStar) { data.RefStar = star1; } star1.Marked |= star2.Marked; star1.UpdateMass(star1.Mass + star2.Mass); star1.PosX = (star1.PosX * massPS1 + star2.PosX * massPS2); star1.PosY = (star1.PosY * massPS1 + star2.PosY * massPS2); star1.SpeedX = (star1.SpeedX * massPS1 + star2.SpeedX * massPS2); star1.SpeedY = (star1.SpeedY * massPS1 + star2.SpeedY * massPS2); star2.Enabled = false; if (star1.Name == "") { star1.Name = star2.Name; } else if (star2.Name != "") { star1.Name += star2.Name; } } }
private void buttonApply_Click(object sender, EventArgs e) { updateComboBox(); editStar.Name = textBoxName.Text; editStar.Density = (Convert.ToSingle(textBoxDensity.Text)); editStar.UpdateMass(Convert.ToSingle(textBoxMass.Text)); readTextBox(); editStar.PosX += posX; editStar.PosY += posY; editStar.SpeedX += speedX; editStar.SpeedY += speedY; posX = 0; posY = 0; speedX = 0; speedY = 0; game.ViewChanged = true; UpdateGui(); }