public StunModifier(StunInfo info, Entity casterEntity, Entity targetEntity, Vector3 collidedProjectilePosition, Environment environment, CollectionOfInteractions modifierInteractionCollection) : this( info, info.Config.ShowLevel(), casterEntity, targetEntity, collidedProjectilePosition, environment, modifierInteractionCollection ) { this.info = info; bool found; extraStunDuration = targetEntity.GetComponent <StatsComponent>().CharacterStats .FindStats(StatsType.ExtraStunDuration, out found); duration = this.info.Config.ShowDurationInSeconds(); }
public StunModifier(StunInfo info, WeightLevel forceLevel, Entity casterEntity, Entity targetEntity, Vector3 collidedProjectilePosition, Environment environment, CollectionOfInteractions modifierInteractionCollection) : base( new StaggerInfo( info.Target(), info.ShowParentSkill(), info.Config.distance, info.Config.movementDuration, info.ShowSuccessRate(), info.DelayToApply(), forceLevel, info.ShowBehaviors(), info.Config.overrideAnimation, info.ShowVfxConfig(), info.Config.ShowMovementBehavior(), info.Config.ShowFacingBehavior(), StaggerModifierConfig.Requirement.Any, info.ShowLifetimeConfigs(), info.Config.loopAnimation, info.Config.crossfade, info.Config.animFrame ), casterEntity, targetEntity, collidedProjectilePosition, environment, modifierInteractionCollection ) { this.info = info; bool found; extraStunDuration = targetEntity.GetComponent <StatsComponent>().CharacterStats .FindStats(StatsType.ExtraStunDuration, out found); animComponent = targetEntity.GetComponent <AnimationComponent>(); }
public bool OnAttachAsSub(Character target) { attachType = ModifierAttachType.Sub; bool attachSuccess = false; try { Modifier highest = target.FindModifierOfHighestRank(); MType highestType = (MType)(int)highest.Type(); MType thisType = (MType)(int)Type(); List <Interaction> inters = modifierInteractionCollection.Find(highestType, thisType); if (inters.Count < 1) { return(attachSuccess); } Interaction inter = inters[0]; bool isStateQuerySuccess = false; MainModifierState mainState = MainModifierState.Ground; if (highest is BaseModifier) { bool justChanged; isStateQuerySuccess = ((BaseModifier)highest).TryQueryingState(out mainState, out justChanged); } if (!isStateQuerySuccess) { mainState = target.IsOnGround() ? MainModifierState.Ground : MainModifierState.Air; } List <ActionDetails> actions = inter.FindActions(mainState); if (actions.Count < 1) { return(attachSuccess); } for (int i = 0; i < actions.Count; i++) { ActionDetails ad = actions[i]; switch (ad.ShowActionType()) { case InteractionActionType.DoNothing: attachSuccess = false; break; case InteractionActionType.Vibrate: VibrateActionDetails vad = (VibrateActionDetails)ad; VibrateTarget( vad.xAmplitude, vad.duration, vad.frequency, vad.shouldDecay, vad.decayConstant, targetGameObject, () => subLifetime.End() ); attachSuccess = true; break; case InteractionActionType.PlayAnimation: PlayAnimationActionDetails paad = (PlayAnimationActionDetails)ad; if (targetAnimation.CurrentAnimationNames().Contains(paad.name)) { targetAnimation.Stop(); } targetAnimation.PlayAnimation(paad.name); targetAnimation.JumpToFrame(paad.startFrame); if (highest is StunModifier) { ((StunModifier)highest).OnAnimationPlayedBySubModifier(paad.name); } subLifetime.End(); attachSuccess = true; break; case InteractionActionType.Jump: JumpActionDetails jad = (JumpActionDetails)ad; movingJumpRequest = new MovingJumpRequest( jad.height, jad.timeToPeak, jad.timeToGround, jad.timeToFloat, jad.distance ); targetEntity.GetComponent <MovementComponent>().AddMovementRequest( movingJumpRequest ); attachSuccess = true; break; case InteractionActionType.Dash: MovementComponent casterMc = casterEntity.GetComponent <MovementComponent>(); Direction casterFacing = casterMc.FacingDirection; DashActionDetails dad = (DashActionDetails)ad; dashRequest = new DashRequest( casterFacing, dad.distance, dad.duration, 0, dad.constantSpeed ); targetEntity.GetComponent <MovementComponent>().AddMovementRequest( dashRequest ); attachSuccess = true; break; case InteractionActionType.OverrideMainModifier: attachType = ModifierAttachType.Main; target.RemoveModifier(highest); OnAttachAsMain(target); attachSuccess = true; break; case InteractionActionType.IncreaseLyingDuration: StunInfo si = (StunInfo)info; increaseLyingDuration = new IncreaseLyingDuration( subLifetime, si.ShowDuration(), targetEntity ); attachSuccess = true; break; default: throw new Exception( "Missing logic to handle SubModifier of ActionType " + ad.ShowActionType() ); } } return(attachSuccess); } catch (Exception e) { DLog.LogError(e); return(attachSuccess); } }