Ejemplo n.º 1
0
        public override void OnDetach(Character target)
        {
            base.OnDetach(target);
            targetMovementComponent.WallCollisionHandler -= OnWallCollision;
            targetAnimation.Animation.UnpauseAnimation();
            Timing.KillCoroutines(ch);
            JointHierarchyAdjustment jha = targetGo.GetComponentInChildren <JointHierarchyAdjustment>();

            if (jha != null)
            {
                jha.UndoAdjustment();
            }
            SetEnableDynamicBones(false);
        }
Ejemplo n.º 2
0
        protected override void OnUpdate(float dt)
        {
            justChanged = false;
            if (IsFinish())
            {
                return;
            }

            elapsed += dt;

            if (elapsed >= timeUntilReturnToIdle && !isReturnToIdleStarted)
            {
                isReturnToIdleStarted = true;
                if (targetEntity.GetComponent <HealthComponent>().IsAlive())
                {
                    targetAnimation.Animation.PlayAnimation(
                        animProfile.LieToIdle(), 1, PlayMethod.Crossfade, .1f
                        );
                    targetAnimation.Animation.PlayAnimation(
                        AnimationName.IDLE, 1, PlayMethod.Queue, 0
                        );
                }
                //DLog.Log("Return to idle");
            }

            if (elapsed >= timeUntilFall)
            {
                if (!isOnGroundAnimationPlayed)
                {
                    justChanged = true;
                    state       = MainModifierState.Air;
                    //DLog.Log("RagdollModifier: state: " + state);
                    isOnGroundAnimationPlayed = true;
                    JointHierarchyAdjustment jha = targetGo.GetComponentInChildren <JointHierarchyAdjustment>();
                    if (jha != null)
                    {
                        jha.UndoAdjustment();
                    }
                    targetAnimation.Animation.UnpauseAnimation();
                    targetAnimation.Animation.PlayAnimation(animProfile.FallLoop());
                    SetEnableDynamicBones(false);

                    MovementComponent targetMc = targetEntity.GetComponent <MovementComponent>();
                    targetMc.UpdateGround();
                    float s       = targetMc.Position.y;
                    float t       = info.RagdollModifierConfig.timeToFall;
                    float v0      = info.RagdollModifierConfig.initSpeedOfFall;
                    float gravity = 2 * (s - v0 * t) / (t * t);
                    fallRequest = new FallRequest(gravity);
                    targetMc.AbortAllRequests();
                    targetMc.AddMovementRequest(fallRequest);
                    //DLog.Log("Fall");
                }
            }

            if (elapsed >= timeUntilGround && !isGrounded)
            {
                justChanged = true;
                state       = MainModifierState.Ground;
                //DLog.Log("RagdollModifier: state: " + state);
                isGrounded = true;
                targetAnimation.Animation.PlayAnimation(animProfile.FallToLie());
                targetAnimation.Animation.JumpToFrame(info.RagdollModifierConfig.onGroundAnimationStartFrame);
                targetAnimation.Animation.QueueAnimation(animProfile.LieLoop());
                //DLog.Log("Lie");
            }

            if (fallRequest != null)
            {
                if (fallRequest.IsCompleted())
                {
                    if (!isEventTriggered)
                    {
                        isEventTriggered = true;
                        TriggerEvents();
                    }
                }
            }

            if (vfxLogic != null)
            {
                vfxLogic.Update(dt);
            }

            if (elapsed >= duration)
            {
                lifetime.End();
            }
        }