Beispiel #1
0
            public static GameObject AttachEffect(CreatureBoardAsset creatureBoardAsset, string effectName, string spellId, float enlargeTime, float lifeTime, float shrinkTime, string parentNodeName = null, string prefix = null)
            {
                GameObject spell = GetEffect(effectName);

                if (spell == null)
                {
                    Log.Error($"Spell effect \"{effectName}\" not found. Unable to Attach the effect.");
                    return(null);
                }

                //Log.Indent("Spells.AttachEffect");

                spell.name = GetAttachedEffectName(spellId, prefix);

                GameObject creatureBase    = creatureBoardAsset.GetAssetLoader();
                Transform  parentTransform = creatureBase.transform;

                if (parentNodeName != null)
                {
                    GameObject parentNode = creatureBase.FindChild(parentNodeName, true);
                    if (parentNode != null)
                    {
                        parentTransform = parentNode.transform;
                    }
                }

                // TODO: IS the same technique required for localScale?
                Vector3 savePosition = spell.transform.localPosition;

                spell.transform.SetParent(parentTransform);
                spell.transform.position      = parentTransform.position;
                spell.transform.localPosition = savePosition;

                if (parentNodeName != null)
                {
                    spell.transform.localEulerAngles = Vector3.zero;
                }

                EffectParameters.ApplyAfterPositioning(spell);

                if (lifeTime > 0)
                {
                    Instances.AddTemporal(spell, lifeTime, 2f * shrinkTime / 3f, enlargeTime, shrinkTime);
                }
                else if (enlargeTime > 0)
                {
                    Instances.EnlargeSoon(spell, enlargeTime);
                }

                //Log.Unindent("Spells.AttachEffect");
                return(spell);
            }