Exemple #1
0
        /// <summary>
        /// Creates elements by a power up defintion.
        /// </summary>
        /// <param name="powerUpDef">The power up definition.</param>
        /// <param name="attributeHolder">The attribute holder.</param>
        /// <returns>The elements which represent the powerup.</returns>
        public static IEnumerable <PowerUpWrapper> CreateByPowerUpDefintion(PowerUpDefinition powerUpDef, AttributeSystem attributeHolder)
        {
            if (powerUpDef.Boost.ConstantValue != null)
            {
                yield return(new PowerUpWrapper(powerUpDef.Boost.ConstantValue, powerUpDef.TargetAttribute, attributeHolder));
            }

            if (powerUpDef.Boost.RelatedValues != null)
            {
                foreach (var relationship in powerUpDef.Boost.RelatedValues)
                {
                    yield return(new PowerUpWrapper(attributeHolder.CreateRelatedAttribute(relationship, attributeHolder), powerUpDef.TargetAttribute, attributeHolder));
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates elements by a <see cref="PowerUpDefinition"/>.
        /// </summary>
        /// <param name="powerUpDef">The power up definition.</param>
        /// <param name="attributeHolder">The attribute holder.</param>
        /// <returns>The elements which represent the power-up.</returns>
        public static IEnumerable <PowerUpWrapper> CreateByPowerUpDefinition(PowerUpDefinition powerUpDef, AttributeSystem attributeHolder)
        {
            if (powerUpDef.Boost?.ConstantValue != null)
            {
                yield return(new PowerUpWrapper(
                                 powerUpDef.Boost.ConstantValue,
                                 powerUpDef.TargetAttribute ?? throw Error.NotInitializedProperty(powerUpDef, nameof(PowerUpDefinition.TargetAttribute)),
                                 attributeHolder));
            }

            if (powerUpDef.Boost?.RelatedValues != null)
            {
                foreach (var relationship in powerUpDef.Boost.RelatedValues)
                {
                    yield return(new PowerUpWrapper(
                                     attributeHolder.CreateRelatedAttribute(relationship, attributeHolder),
                                     powerUpDef.TargetAttribute ?? throw Error.NotInitializedProperty(powerUpDef, nameof(PowerUpDefinition.TargetAttribute)),
                                     attributeHolder));
                }
            }
        }