protected override void OnDelayedAttachAsMain(Character target) { target.InterruptChannelingSkill(); targetAnimationComponent.Animation.PauseAnimation(); if (targetMovementComponent.ConfigData.isFallable) { float gravity = targetMovementComponent.Gravity; for (int kIndex = 0; kIndex < targetMovementComponent.MovementRequests.Count; kIndex++) { Request r = targetMovementComponent.MovementRequests[kIndex]; RequestType requestType = r.ShowRequestType(); if (requestType == RequestType.StationaryJump || requestType == RequestType.MovingJump) { gravity = ((StationaryJumpRequest)r).GroundingGravity; } } FallRequest fallRequest = new FallRequest( gravity, targetMovementComponent.Velocity.magnitude ); targetMovementComponent.AddMovementRequest(fallRequest); } }
private void PerformDash(DashAction da, Character caster) { switch (da.ShowRequirement()) { case JumpAction.Requirement.Air: if (caster.IsOnGround()) { isThisJumpDisabled = true; } break; case JumpAction.Requirement.Ground: if (!caster.IsOnGround()) { isThisJumpDisabled = true; } break; } if (isThisJumpDisabled) { return; } float distance = Math.Abs(da.ShowDistance()); Vector2 direction = da.ShowDirectionAsNormalizedVector(); if (caster.FacingDirection() == Direction.Left) { direction = new Vector2(direction.x * -1, direction.y); } if (da.ShowDistance() < 0) { direction *= -1; } caster.SetMovingDirection(direction); if (da.ignoreObstacles || da.collision) { dashRequest = new FixedUpdateDashRequest(distance, duration, da.ShowBlendTime(), da.IsUniform()); movementComponent.AddMovementRequest(dashRequest); } else { dashRequest = caster.Dash( distance, duration, da.ShowBlendTime(), true, true, ignoreMinSpeedOnAir, da.IsUniform() ); } }
protected override void OnDelayedAttachAsMain(Character target) { movementBehavior = info.Wmc.ShowMovementBehavior(); Vector2 direction = Vector2.right; Vector3 casterPosition = casterMovementComponent.Position; Vector3 offset = Vector3.zero; if (movementBehavior == MovementBehavior.BlackHoleTowardCaster) { offset = info.Wmc.offset.FlipFollowDirection(casterMovementComponent.FacingDirection); } Vector3 offsetPosition = casterPosition + offset; Vector3 targetPosition = targetMovementComponent.Position; Vector2 directionFromTargetToCaster = offsetPosition - targetPosition; switch (movementBehavior) { case MovementBehavior.TowardCaster: case MovementBehavior.BlackHoleTowardCaster: direction = directionFromTargetToCaster.ToLeftOrRightDirection(); break; case MovementBehavior.AwayFromCaster: direction = directionFromTargetToCaster.ToLeftOrRightDirection() * -1; break; case MovementBehavior.FollowCasterFacing: direction = casterMovementComponent.FacingDirection.ToNormalizedVector2(); break; case MovementBehavior.OppositeCasterFacing: direction = casterMovementComponent.FacingDirection.Opposite().ToNormalizedVector2(); break; default: throw new Exception("Missing logic to calculate movement direction of " + movementBehavior); } if (movementBehavior == MovementBehavior.BlackHoleTowardCaster) { directionMoveRequest = new DirectionMoveRequest(direction, info.Wmc.speed, duration, info.Wmc.acceleration, offsetPosition); } else { directionMoveRequest = new DirectionMoveRequest(direction, info.Wmc.speed, duration, info.Wmc.acceleration); } targetMovementComponent.AddMovementRequest(directionMoveRequest); }
protected override void OnDelayedAttachAsMain(Character target) { Log("OnAttach", target); Character casterCharacter = casterEntity.GetComponent <SkillComponent>().Character; if (attachType == ModifierAttachType.Main) { Direction movementDirection = CalculateMovementDirection( casterMovementComponent, targetMovementComponent, collidedProjectilePosition, info.MovementBehavior ); Direction facingDirection = CalculateFacingDirection( casterMovementComponent, targetMovementComponent, collidedProjectilePosition, info.FacingBehavior, movementDirection ); targetMovementComponent.MovingDirection = movementDirection.ToNormalizedVector2(); targetMovementComponent.FacingDirection = facingDirection; float gravity = targetMovementComponent.Gravity; for (int kIndex = 0; kIndex < targetMovementComponent.MovementRequests.Count; kIndex++) { Request r = targetMovementComponent.MovementRequests[kIndex]; RequestType requestType = r.ShowRequestType(); if (requestType == RequestType.StationaryJump || requestType == RequestType.MovingJump) { gravity = ((StationaryJumpRequest)r).GroundingGravity; } } FallRequest fallRequest = new FallRequest(gravity, targetMovementComponent.Velocity.magnitude); if (info.Distance != 0) { DashRequest dashRequest = new DashRequest(info.Distance, info.MovementDuration, 0); dashRequest.AddCorunningRequest(fallRequest); targetMovementComponent.AddMovementRequest(dashRequest); } if (targetMovementComponent.ConfigData.isFallable) { targetMovementComponent.AddMovementRequest(fallRequest); } if (ShouldInterruptTargetSkill()) { target.InterruptChannelingSkill(); } string animationName = AnimationName.Stagger.SOFT; if (info.Behaviors.Contains(Behavior.InterruptTargetSkill)) { animationName = AnimationName.Stagger.HARD; } if (!string.IsNullOrEmpty(info.OverrideAnimation)) { animationName = info.OverrideAnimation; string[] split = info.OverrideAnimation.Split(','); if (split.Length > 0) { animationName = split[BattleUtils.RandomRangeInt(0, split.Length)].Trim(); } } if (ShouldPlayAnimation()) { targetAnimationComponent.Animation.PlayAnimation(animationName, 1, PlayMethod.Play, 0); targetAnimationComponent.Animation.JumpToFrame(info.AnimFrame); } } }
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(); } }