예제 #1
0
 /// <summary>
 /// Register a custom spell bundle from pre-made settings.
 /// </summary>
 /// <param name="offer">Offer settings.</param>
 public void RegisterCustomSpellBundleOffer(CustomSpellBundleOffer offer)
 {
     // Key must be unique
     if (customSpellBundleOffers.ContainsKey(offer.Key))
     {
         Debug.LogErrorFormat("RegisterCustomSpellBundleOffer: Duplicate bundle key '{0}'", offer.Key);
         return;
     }
     customSpellBundleOffers.Add(offer.Key, offer);
 }
예제 #2
0
        void RegisterCustomEffectDemo()
        {
            // This method is an example of how to create a fully custom spell bundle
            // and expose it to other systems like spells for sale and item enchanter
            // The process is mostly just setting up data, something that can be automated with helpers

            // First register custom effect with broker
            // This will make it available to crafting stations supported by effect
            // We're using variant 0 of this effect here (Inferno)
            MageLight templateEffect = new MageLight();

            templateEffect.CurrentVariant = 0;
            RegisterEffectTemplate(templateEffect);

            // Create effect settings for our custom spell
            // These are Chance, Duration, and Magnitude required by spell - usually seen in spellmaker
            // No need to define settings not used by effect
            // For our custom spell, we're using same Duration settings as Light spell: 1 + 4 per level
            // Note these settings will also control final cost of spell to buy and cast
            EffectSettings effectSettings = new EffectSettings()
            {
                DurationBase     = 1,
                DurationPlus     = 4,
                DurationPerLevel = 1,
            };

            // Create an EffectEntry
            // This links the effect key with settings
            // Each effect entry in bundle needs its own settings - most spells only have a single effect
            EffectEntry effectEntry = new EffectEntry()
            {
                Key      = templateEffect.Properties.Key,
                Settings = effectSettings,
            };

            // Create a custom spell bundle
            // This is a portable version of the spell for other systems
            // For example, every spell in the player's spellbook is a bundle
            // Bundle target and elements settings should follow effect requirements
            EffectBundleSettings mageLightInferoSpell = new EffectBundleSettings()
            {
                Version     = CurrentSpellVersion,
                BundleType  = BundleTypes.Spell,
                TargetType  = TargetTypes.CasterOnly,
                ElementType = ElementTypes.Magic,
                Name        = "Magelight Inferno",
                IconIndex   = 12,
                Effects     = new EffectEntry[] { effectEntry },
            };

            // Create a custom spell offer
            // This informs other systems if they can use this bundle
            CustomSpellBundleOffer mageLightInferoOffer = new CustomSpellBundleOffer()
            {
                Key   = "MageLightInferno-CustomOffer",                         // This key is for the offer itself and must be unique
                Usage = CustomSpellBundleOfferUsage.SpellsForSale |             // Available in spells for sale
                        CustomSpellBundleOfferUsage.CastWhenUsedEnchantment |   // Available for "cast on use" enchantments
                        CustomSpellBundleOfferUsage.CastWhenHeldEnchantment,    // Available for "cast on held" enchantments
                BundleSetttings = mageLightInferoSpell,                         // The spell bundle created earlier
                EnchantmentCost = 250,                                          // Cost to use spell at item enchanter if enabled
            };

            // Register the offer
            RegisterCustomSpellBundleOffer(mageLightInferoOffer);
        }