Exemplo n.º 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);
            }
Exemplo n.º 2
0
            private static void PlayEffect(string effectName, string spellId, string creatureId, float lifeTime, float enlargeTimeSeconds, float secondsDelayStart, float shrinkTime, SpellLocation location, float rotationDegrees, bool isMoveable)
            {
                if (secondsDelayStart > 0)
                {
                    Log.Debug($"QueueEffect \"{effectName}\" for {secondsDelayStart} seconds...");
                    QueueEffect(new WaitingToCast(location, secondsDelayStart, effectName, spellId, creatureId, enlargeTimeSeconds, lifeTime, null, shrinkTime, rotationDegrees, isMoveable));
                    return;
                }

                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

                if (creatureBoardAsset == null)
                {
                    Log.Error($"CreatureBoardAsset matching id {creatureId} not found!");
                    return;
                }

                GameObject spell = GetSpell(effectName, spellId, lifeTime, enlargeTimeSeconds, shrinkTime, rotationDegrees, isMoveable);

                if (spell == null)
                {
                    Log.Error($"Spell name \"{effectName}\" not found!");
                    return;
                }

                GameObject creatureBase = creatureBoardAsset.GetBase();

                if (location == SpellLocation.CreatureCastSpell)
                {
                    Log.Vector("creatureBoardAsset.HookSpellCast.position", creatureBoardAsset.HookSpellCast.position);
                    spell.transform.position = creatureBoardAsset.HookSpellCast.position;
                }
                else                  // Default to base position...
                {
                    spell.transform.position = creatureBase.transform.position;
                }

                float creatureRotationDegrees = creatureBoardAsset.GetRotationDegrees();

                spell.transform.Rotate(Vector3.up, creatureRotationDegrees);
                //spell.transform.localEulerAngles = new Vector3(spell.transform.localEulerAngles.x, rotationDegrees, spell.transform.localEulerAngles.z);
                //Log.Vector("spell.transform.localEulerAngles", spell.transform.localEulerAngles);
                //spell.transform.Rotate(creatureBoardAsset.GetRotation());
                //Log.Vector("spell.transform.localEulerAngles2", spell.transform.localEulerAngles);

                if (isMoveable)
                {
                    Log.Warning($"EffectParameters.ApplyAfterPositioning(spell) on moveable effect {effectName}");
                }
                EffectParameters.ApplyAfterPositioning(spell, isMoveable);
            }
Exemplo n.º 3
0
            public static GameObject PlayEffectAtPosition(string effectName, string spellId, Vector3 position, float lifeTime = 0, float enlargeTimeSeconds = 0, float secondsDelayStart = 0, float shrinkTime = 0, float rotationDegrees = 0, bool isMoveable = false, Action <GameObject> conditioning = null)
            {
                if (secondsDelayStart > 0)
                {
                    QueueEffect(new WaitingToCast(SpellLocation.AtPosition, secondsDelayStart, effectName, spellId, null, enlargeTimeSeconds, lifeTime, position, shrinkTime, rotationDegrees, isMoveable, conditioning));
                    return(null);
                }

                Log.Warning($"PlayEffectAtPosition(\"{effectName}\"...)");
                GameObject spell = GetSpell(effectName, spellId, lifeTime, enlargeTimeSeconds, shrinkTime, rotationDegrees, isMoveable);

                if (spell != null)
                {
                    spell.transform.position = position;
                    EffectParameters.ApplyAfterPositioning(spell, isMoveable);
                }

                conditioning?.Invoke(spell);

                return(spell);
            }