예제 #1
0
        /// <summary>
        /// Takes a snapshot of the Emitters state.
        /// </summary>
        /// <param name="snap"></param>
        protected override void TakeSnapshot(ref Snapshot snap)
        {
            base.TakeSnapshot(ref snap);

            CircleSnapshot circleSnap = (CircleSnapshot)snap;

            circleSnap.Radius = _radius;
            circleSnap.Ring   = _ring;
        }
예제 #2
0
        /// <summary>
        /// Processes a Particle to give it its initial position and orientation.
        /// </summary>
        /// <param name="snap">Snapshot taken when the Particle was discharged.</param>
        /// <param name="position">The Particles offset from the position of the Emitter.</param>
        /// <param name="orientation">The particles orientation (unit vector).</param>
        protected override void GetParticlePositionAndOrientation(Snapshot snap, ref Vector2 position, ref Vector2 orientation)
        {
            CircleSnapshot circleSnap = (CircleSnapshot)snap;

            float angle = (float)Rnd.NextDouble() * MathHelper.TwoPi;

            orientation.X = (float)Math.Sin(angle);
            orientation.Y = (float)Math.Cos(angle);

            float distance = circleSnap.Radius;

            if (!circleSnap.Ring)
            {
                distance *= (float)Rnd.NextDouble();
            }

            position.X = (float)Math.Sin(angle) * distance;
            position.Y = (float)Math.Cos(angle) * distance;
        }