示例#1
0
            private static GameObject GetEffect(string effectName, string spellId = "", bool isMoveable = false)
            {
                GameObject result;

                if (isMoveable)
                {
                    result = Instances.GetMoveableSpell(spellId, effectName);
                    if (result == null)
                    {
                        Log.Error($"Moveable spell {spellId}.{effectName} not found!");
                    }
                    else
                    {
                        Log.Warning($"Moveable spell {spellId}.{effectName} FOUND!");
                        return(result);
                    }
                }

                string prefabName = Effects.GetIndividualEffectName(EffectParameters.GetEffectNameOnly(effectName));

                Log.Debug($"GetEffect() - prefabName = \"{prefabName}\"");
                if (Prefabs.Has(prefabName))
                {
                    Log.Debug($"Cloning...");
                    result = Prefabs.Clone(effectName);
                }
                else
                {
                    Log.Debug($"CompositeEffect.CreateKnownEffect(\"{effectName}\")");
                    result = CompositeEffect.CreateKnownEffect(effectName);
                }

                PrepareEffect(result);
                return(result);
            }
 public static void Update()
 {
     Target.Update();
     Spells.Update();
     Instances.Update();
     CompositeEffect.Update();
     PersistentEffects.Update();
 }
示例#3
0
 public static void SetTargetingEffect(string effectJson)
 {
     targetingSphereCompositeEffect = CompositeEffect.CreateFrom(effectJson);
     if (targetingSphereCompositeEffect != null)
     {
         Talespire.Log.Debug($"Targeting Sphere found!");
     }
     else
     {
         Talespire.Log.Error($"Targeting Sphere NOT found!");
     }
 }
示例#4
0
 public static void SetTargetingFire(string fireCompositeEffectJson)
 {
     targetingFireCompositeEffect = CompositeEffect.CreateFrom(fireCompositeEffectJson);
     if (targetingFireCompositeEffect != null)
     {
         Log.Debug($"Targeting Fire found!");
     }
     else
     {
         Log.Error($"Targeting Fire NOT found!");
     }
 }
        public static CompositeEffect CreateFrom(string json, string instanceId = null)
        {
            //Talespire.Log.Indent("CompositeEffect.CreateFrom");
            try
            {
                CompositeEffect compositeEffect = JsonConvert.DeserializeObject <CompositeEffect>(json);
                compositeEffect.RebuildProperties();

                return(compositeEffect);
            }
            finally
            {
                //Talespire.Log.Unindent();
            }
        }
示例#6
0
            private static void AttachEffects(CreatureBoardAsset creatureAsset, IOldPersistentEffect persistentEffect)
            {
                Log.Indent();
                if (persistentEffect != null)
                {
                    if (persistentEffect is SuperPersistentEffect superPersistentEffect)
                    {
                        for (int i = 0; i < superPersistentEffect.EffectProperties.Count; i++)
                        {
                            string           prefix           = i.ToString().PadLeft(2, '0');
                            EffectProperties effectProperties = superPersistentEffect.EffectProperties[i];
                            Log.Warning($"Adding effect {prefix} - \"{effectProperties.EffectName}\"");
                            GameObject spell = Spells.AttachEffect(creatureAsset, effectProperties.EffectName, creatureAsset.CreatureId.ToString(), 0, 0, 0, STR_AttachedNode, prefix);

                            TransferPropertiesToPersistentEffect(CompositeEffect.GetFromGameObject(spell), superPersistentEffect);

                            if (superPersistentEffect.ScriptData != null && superPersistentEffect.ScriptData.Count > 0)
                            {
                                Log.Debug($"");
                                foreach (string scriptName in superPersistentEffect.ScriptData.Keys)
                                {
                                    Log.Warning($"Adding Script: {scriptName} to \"{creatureAsset.GetOnlyCreatureName()}\" with data: \"{superPersistentEffect.ScriptData[scriptName]}\"");
                                    TaleSpireBehavior script = spell.AddComponent(KnownScripts.GetType(scriptName)) as TaleSpireBehavior;
                                    if (script != null)
                                    {
                                        script.OwnerCreated(creatureAsset.CreatureId.ToString());
                                        script.Initialize(superPersistentEffect.ScriptData[scriptName]);
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        Spells.AttachEffect(creatureAsset, persistentEffect.EffectName, creatureAsset.CreatureId.ToString(), 0, 0, 0, STR_AttachedNode);
                    }
                }
                else
                {
                    Log.Error($"Unable to attach any effects. {nameof(persistentEffect)} is null!");
                    //Log.Warning($"Adding \"{defaultNewEffect}\"...");
                    //Spells.AttachEffect(creatureAsset, defaultNewEffect, creatureAsset.CreatureId.ToString(), 0, 0, 0, STR_AttachedNode);
                }

                Log.Unindent();
            }
示例#7
0
 protected void CreateTargetSelector(CompositeEffect compositeEffect)
 {
     try
     {
         targetingPrefab = compositeEffect?.CreateOrFindUnsafe();
         compositeEffect?.RefreshIfNecessary(targetingPrefab);
         if (targetingPrefab == null)
         {
             Talespire.Log.Error($"targetingPrefab is NULL!!!");
         }
         else
         {
             targetingPrefab.transform.SetParent(Transform);
             targetingPrefab.transform.localPosition = new Vector3(0, offsetY, 0);
         }
     }
     catch (Exception ex)
     {
         Talespire.Log.Exception(ex);
     }
 }
示例#8
0
            private static void TransferPropertiesToPersistentEffect(CompositeEffect compositeEffect, SuperPersistentEffect superPersistentEffect)
            {
                if (compositeEffect == null)
                {
                    return;
                }

                superPersistentEffect.VisibilityMatchesBase = compositeEffect.VisibilityMatchesBase;

                if (compositeEffect.Scripts != null)
                {
                    Log.Warning($"Found a composite effect with scripts!");
                    foreach (string script in compositeEffect.Scripts)
                    {
                        if (!superPersistentEffect.ScriptData.ContainsKey(script))
                        {
                            Log.Warning($"Adding Script \"{script}\" with empty Data!!!");
                            superPersistentEffect.ScriptData[script] = "";
                        }
                    }
                }
            }
            static void ShowHealth(string creatureId, int healthAmount, string effectName)
            {
                CreatureBoardAsset creatureAsset = GetCreatureBoardAsset(creatureId);

                if (creatureAsset == null)
                {
                    Log.Error($"AddHitPoints - creatureId {creatureId} not found.");
                    return;
                }

                GameObject heal = CompositeEffect.CreateKnownEffect(effectName);

                heal.transform.position = creatureAsset.transform.position;
                float scale = creatureAsset.CreatureScale / 2.0f;

                heal.transform.localScale = new Vector3(scale, scale, scale);
                Property.Modify(heal, "ParticlesHeal", "<ParticleSystem>.startSize", 0.4f * creatureAsset.CreatureScale);
                Property.Modify(heal, "ParticlesHealPlus", "<ParticleSystem>.startSize", 0.3f * creatureAsset.CreatureScale);

                float lifetimeSeconds     = Math.Max(5f, Math.Min(healthAmount, 16f));
                float particleFadeOutTime = Math.Max(lifetimeSeconds / 2f, 3f);

                Instances.AddTemporal(heal, lifetimeSeconds, particleFadeOutTime);
            }