Beispiel #1
0
        /// <summary>
        /// Creates the sparks from the explosion.
        /// </summary>
        /// <param name="explosion">The explosion that is the source of sparks.</param>
        /// <returns>
        /// A collection of sparks for the specified explosion.
        /// </returns>
        /// <exception cref="System.ArgumentNullException"> if <paramref name="explosion"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="System.InvalidOperationException"> if <paramref name="explosion"/>
        /// does not match <typeparamref name="TExplosion"/>.</exception>
        public virtual IEnumerable <Firework> CreateSparks(ExplosionBase explosion)
        {
            if (explosion == null)
            {
                throw new ArgumentNullException(nameof(explosion));
            }

            int desiredNumberOfSparks;

            if (!explosion.SparkCounts.TryGetValue(this.GeneratedSparkType, out desiredNumberOfSparks))
            {
                return(Enumerable.Empty <Firework>());
            }

            TExplosion typedExplosion = SparkGeneratorBase <TExplosion> .GetTypedExplosion(explosion);

            IList <Firework> sparks = new List <Firework>(desiredNumberOfSparks);

            for (int i = 0; i < desiredNumberOfSparks; i++)
            {
                sparks.Add(this.CreateSparkTyped(typedExplosion));
            }

            return(sparks);
        }
Beispiel #2
0
        /// <summary>
        /// Creates the spark from the explosion.
        /// </summary>
        /// <param name="explosion">The explosion that is the source of sparks.</param>
        /// <returns>A spark for the specified explosion.</returns>
        /// <exception cref="System.ArgumentNullException"> if <paramref name="explosion"/>
        /// is <c>null</c>.</exception>
        /// <exception cref="System.InvalidOperationException"> if <paramref name="explosion"/>
        /// does not match <typeparamref name="TExplosion"/>.</exception>
        public virtual Firework CreateSpark(ExplosionBase explosion)
        {
            if (explosion == null)
            {
                throw new ArgumentNullException(nameof(explosion));
            }

            TExplosion typedExplosion = SparkGeneratorBase <TExplosion> .GetTypedExplosion(explosion);

            return(this.CreateSparkTyped(typedExplosion));
        }