Beispiel #1
0
            public static void ClearAttached(string spellId, string creatureId)
            {
                CreatureBoardAsset creatureBoardAsset = Minis.GetCreatureBoardAsset(creatureId);

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

                GameObject creatureBase       = creatureBoardAsset.GetBase();
                string     attachedEffectName = GetAttachedEffectName(spellId);

                GameObject childEffect = creatureBase.FindChild(attachedEffectName);

                if (childEffect == null)
                {
                    Log.Error($"Child effect {attachedEffectName} not found.");
                    return;
                }

                while (childEffect != null)
                {
                    childEffect.transform.SetParent(null);
                    Instances.AddTemporal(childEffect, 2, 2);
                    childEffect = creatureBase.FindChild(attachedEffectName);
                }
            }
            public static void ShowDamage(string creatureId, int damageAmount, string bloodColor, float rotationOffset = 0)
            {
                CreatureBoardAsset creatureAsset = GetCreatureBoardAsset(creatureId);

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

                if (damageAmount > 30)
                {
                    ShowDamage(creatureId, damageAmount - 30, bloodColor, random.NextInt(60) - 30);
                    damageAmount = 30;
                }

                float scale = 0.65f * creatureAsset.CreatureScale;                  // 0.5, 1, 2, 3, 4

                string prefabName;
                float  scaleMultiplier;

                if (damageAmount < 15)
                {
                    prefabName      = GetRandomSmallBloodPrefab();
                    scaleMultiplier = 1;
                }
                else
                {
                    prefabName      = GetRandomLargeBloodPrefab();
                    scaleMultiplier = 1 + damageAmount / 70f;
                }

                Log.Debug($"prefabName = \"{prefabName}\"");
                GameObject bloodPrefab = Prefabs.Get(prefabName);

                if (bloodPrefab == null)
                {
                    Log.Error($"Prefab \"{prefabName}\" not found!");
                    bloodPrefab = Prefabs.Get("Blood4");
                }

                // TODO: Change the blood color... bloodColor

                scale *= scaleMultiplier;

                float groundHeight = creatureAsset.GetGroundHeight();

                //Log.Debug($"groundHeight = {groundHeight}");

                GameObject bloodEffect = UnityEngine.Object.Instantiate(bloodPrefab, creatureAsset.HookHitTarget.position, creatureAsset.HookHitTarget.rotation);

                Property.ModifyFloat(bloodEffect, null, "<BFX_BloodSettings>.GroundHeight", groundHeight);
                ChangeBloodEffectColor(bloodEffect, bloodColor);
                bloodEffect.transform.Rotate(Vector3.up, 180 + rotationOffset);
                bloodEffect.transform.localScale = new Vector3(scale, scale, scale);

                Instances.AddTemporal(bloodEffect, 16);
            }
Beispiel #3
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);
            }
Beispiel #4
0
            static GameObject GetSpell(string effectName, string spellId, float lifeTime, float enlargeTimeSeconds, float shrinkOnDeleteTime, float rotationDegrees, bool isMoveable)
            {
                GameObject spell = GetEffect(effectName, spellId, isMoveable);

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

                float actualRotation = rotationDegrees;

                if (actualRotation == -1)
                {
                    actualRotation = RandomRange(0, 360);
                }
                spell.transform.Rotate(Vector3.up, actualRotation);

                spell.name = GetSpellName(spellId, effectName, isMoveable);
                // TODO: Figure out how to implement Moveable spells.
                if (lifeTime > 0)
                {
                    float particleShutoffTimeSeconds = Math.Min(2, lifeTime / 5);
                    if (shrinkOnDeleteTime > particleShutoffTimeSeconds)
                    {
                        particleShutoffTimeSeconds = shrinkOnDeleteTime;
                    }
                    Instances.AddTemporal(spell, lifeTime, particleShutoffTimeSeconds, enlargeTimeSeconds, shrinkOnDeleteTime);
                }
                else
                {
                    Instances.AddSpell(spellId, spell, enlargeTimeSeconds, shrinkOnDeleteTime);
                }

                return(spell);
            }
            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);
            }