Ejemplo n.º 1
0
        IEnumerator SlowCoroutine(Creature targetCreature, float energy, float maxSlow, float minSlow, float duration)
        {
            EffectData imbueHitRagdollEffectData = Catalog.GetData <EffectData>("ImbueIceRagdoll", true);

            effectInstance = imbueHitRagdollEffectData.Spawn(targetCreature.ragdoll.rootPart.transform, true, Array.Empty <Type>());
            effectInstance.SetRenderer(targetCreature.GetRendererForVFX(), false);
            effectInstance.Play(0);
            effectInstance.SetIntensity(1f);

            float animSpeed = Mathf.Lerp(minSlow, maxSlow, energy / 100);

            if (animSpeed != 0)
            {
                targetCreature.animator.speed   *= (animSpeed / 100);
                targetCreature.locomotion.speed *= (animSpeed / 100);
            }
            else
            {
                targetCreature.ragdoll.SetState(Ragdoll.State.Frozen);
                targetCreature.ragdoll.AddNoStandUpModifier(this);

                targetCreature.brain.Stop();
            }


            /*
             * targetCreature.animator.speed *= (animSpeed / 100);
             * targetCreature.locomotion.speed *= (animSpeed / 100);
             */



            yield return(new WaitForSeconds(duration));

            /*
             * targetCreature.animator.speed = 1;
             * targetCreature.locomotion.speed = targetCreature.data.locomotionSpeed;
             *
             *
             *
             * if (!targetCreature.brain.instance.isActive)
             * {
             *  targetCreature.brain.instance.Start();
             * }*/


            if (animSpeed != 0)
            {
                targetCreature.animator.speed   = 1;
                targetCreature.locomotion.speed = targetCreature.data.locomotionSpeed;
            }
            else
            {
                if (!targetCreature.isKilled)
                {
                    targetCreature.ragdoll.SetState(Ragdoll.State.Destabilized);
                    targetCreature.ragdoll.RemoveNoStandUpModifier(this);

                    targetCreature.brain.Load(targetCreature.brain.instance.id);
                }
            }



            effectInstance.Despawn();

            /*
             * targetCreature.umaCharacter.umaDCS.SetColor("Skin", defaultSkinColor, default(Color), 0, true);
             */
        }