/// <summary> // Creates a new firework of this type. The optional parent firework is used to base /// and velocity on. /// </summary> internal Firework Create(Firework parent) { var firework = new Firework { Type = Type, Age = random.NextFloat(MinAge, MaxAge), Mass = 1, Damping = Damping, Acceleration = new Vector3(0, -9.81f, 0), Velocity = random.RandomVector3(MinVelocity, MaxVelocity) }; if (parent != null) { // The position and velocity are based on the parent. firework.Position = parent.Position; firework.Velocity += parent.Velocity; } else { int x = random.Next(3) - 1; firework.Position = new Vector3(5.0f * x, 0, 0); } firework.ClearAccumulator(); return(firework); }
void Create(int type, int count, Firework parent) { FireworkRule rule = rules[type - 1]; for (int i = 0; i < count; i++) { fireworks.Add(rule.Create(parent)); } }