当前位置: 首页>>代码示例>>C#>>正文


C# ActionState.WithDefaultBehaviours方法代码示例

本文整理汇总了C#中ActionState.WithDefaultBehaviours方法的典型用法代码示例。如果您正苦于以下问题:C# ActionState.WithDefaultBehaviours方法的具体用法?C# ActionState.WithDefaultBehaviours怎么用?C# ActionState.WithDefaultBehaviours使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ActionState的用法示例。


在下文中一共展示了ActionState.WithDefaultBehaviours方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildCharge

 private StateWrapper BuildCharge()
 {
     StateWrapper stateWrapper = new StateWrapper();
       FSMState state = new ActionState(this.chargeStateName);
       state.WithDefaultBehaviours(this.gameObject);
       if (this.animationBehaviour != null) {
     state.AddStartBehaviour(this.animationBehaviour);
       }
       state.AddStartBehaviour(new SetAnimationSpeedBehaviour(this.gameObject, 0f));
       state.AddStartBehaviour(new SetVariableBehaviour(this.gameObject, this.chargeVariable, this.initialChargeMultiplier));
       foreach (FSMBehaviour behaviour in this.customStartBehaviours) {
     state.AddStartBehaviour(behaviour);
       }
       state.AddUpdateBehaviour(new ChargeBehaviour(this.gameObject, this.chargeVariable, this.maxChargeMultiplier, this.maxChargeSeconds));
       state.AddExitBehaviour(new SetAnimationSpeedBehaviour(this.gameObject, 1f));
       stateWrapper.state = state;
       FSMTransition transition = null;
       foreach (string startingState in this.startingStates) {
     transition = new FSMTransition(startingState, this.chargeStateName);
     transition.AddConditions(
       new VarConditionsBuilder()
       .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
       .WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP))
       .Build()
     );
     stateWrapper.transitions.Add(transition);
       }
       return stateWrapper;
 }
开发者ID:BrunoRomes,项目名称:UnityTests,代码行数:29,代码来源:ChargedMeleeAttackBuilder.cs

示例2: BuildPursuit

 private StateWrapper BuildPursuit()
 {
     StateWrapper stateWrapper = new StateWrapper();
       FSMState state = new ActionState(this.stateName);
       state.WithDefaultBehaviours(this.gameObject);
       if (this.animationBehaviour != null) {
     state.AddStartBehaviour(this.animationBehaviour);
       }
       state.AddStartBehaviour(new VariableCalculatorBehaviour(this.gameObject, CharVars.SPEED_MULTIPLIER.ToS()).Add(this.speedIncrease));
       if (this.counterVariable != null) {
     state.AddStartBehaviour(new VariableCalculatorBehaviour(this.gameObject, this.counterVariable.ToS()).Add(1));
       }
       state.AddStartBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.IGNORE_DRAG.ToS(), true));
       foreach (FSMBehaviour behaviour in this.customStartBehaviours) {
     state.AddStartBehaviour(behaviour);
       }
       foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) {
     state.AddUpdateBehaviour(behaviour);
       }
       MoveTowardsBehaviour moveTowardsBehaviour = BehavioursBuilder.BuildMoveTowards(this.gameObject, true, true);
       if (this.target != null) {
     moveTowardsBehaviour = moveTowardsBehaviour.WithTarget(this.target);
       }
       if (this.targetVariable != null) {
     moveTowardsBehaviour = moveTowardsBehaviour.WithTargetVariable(this.targetVariable);
       }
       state.AddUpdateBehaviour(moveTowardsBehaviour);
       state.AddUpdateBehaviour(BehavioursBuilder.BuildKeepInsideBounds(this.gameObject, true, true));
       foreach (ComboWrapper combo in this.combos.Values) {
     SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant);
     foreach (ICondition condition in combo.conditions) {
       behaviour = behaviour.WithCondition(condition);
     }
     state.AddUpdateBehaviour(behaviour);
       }
       state.AddExitBehaviour(new VariableCalculatorBehaviour(this.gameObject, CharVars.SPEED_MULTIPLIER.ToS()).Subtract(this.speedIncrease));
       state.AddExitBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.IGNORE_DRAG.ToS(), false));
       foreach (FSMBehaviour behaviour in this.customExitBehaviours) {
     state.AddExitBehaviour(behaviour);
       }
       stateWrapper.state = state;
       //TRANSITIONS
       FSMTransition transition = null;
       foreach (string startingState in this.startingStates) {
     transition = new FSMTransition(startingState, this.stateName);
     VarConditionsBuilder builder = new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP))
     .WithVar(CharVars.TARGET, new ObjectCondition(this.targetVariable));
     if (this.counterVariable != null) {
       builder = builder.WithVar(this.counterVariable, new IntCondition(this.counterVariable.ToS(), Operators.LESS_THAN, this.maxPursuits));
     }
     transition.AddConditions(builder.Build());
     stateWrapper.transitions.Add(transition);
       }
       //RETURN
       foreach (string animationName in this.animationNames) {
     foreach (ComboWrapper combo in this.combos.Values) {
       transition = new FSMTransition(this.stateName, combo.toState);
       transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName));
       transition.AddConditions(
     new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant))
     .Build()
       );
       stateWrapper.transitions.Add(transition);
     }
       }
       transition = new FSMTransition(this.stateName, CharStates.FALL.ToS());
       transition.AddCondition(new TimeCondition(this.timeout));
       transition.AddConditions(
     new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false))
     .Build()
       );
       stateWrapper.transitions.Add(transition);
       transition = new FSMTransition(this.stateName, CharStates.FLY.ToS());
       transition.AddCondition(new TimeCondition(this.timeout));
       transition.AddConditions(
     new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true))
     .Build()
       );
       stateWrapper.transitions.Add(transition);
       return stateWrapper;
 }
开发者ID:BrunoRomes,项目名称:UnityTests,代码行数:89,代码来源:PursuitBuilder.cs

示例3: BuildTeleport

 private StateWrapper BuildTeleport()
 {
     StateWrapper stateWrapper = new StateWrapper();
       FSMState state = new ActionState(this.stateName);
       state.WithDefaultBehaviours(this.gameObject);
       if (this.animationBehaviour != null) {
     state.AddStartBehaviour(this.animationBehaviour);
       }
       if (this.counterVariable != null) {
     state.AddStartBehaviour(new VariableCalculatorBehaviour(this.gameObject, this.counterVariable.ToS()).Add(1));
       }
       if (this.flip && this.waitStateName == null) {
     state.AddStartBehaviour(BehavioursBuilder.BuildFlip(this.gameObject, false).Invert());
       }
       if (this.soundStart != null) {
     state.AddStartBehaviour(new PlaySoundBehaviour(this.gameObject, this.soundStart).Force());
       }
       if (this.effectStart != null) {
     state.AddStartBehaviour(new InstantiateBehaviour(this.gameObject, this.effectStart));
       }
       foreach (FSMBehaviour behaviour in this.customStartBehaviours) {
     state.AddStartBehaviour(behaviour);
       }
       if (this.soundUpdate != null) {
     state.AddUpdateBehaviour(new PlaySoundBehaviour(this.gameObject, this.soundUpdate));
     state.AddExitBehaviour(new StopSoundBehaviour(this.gameObject, this.soundUpdate));
       }
       if (this.effectUpdate != null) {
     state.AddUpdateBehaviour(new InstantiateBehaviour(this.gameObject, this.effectUpdate));
       }
       foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) {
     state.AddUpdateBehaviour(behaviour);
       }
       state.AddUpdateBehaviour(BehavioursBuilder.BuildKeepInsideBounds(this.gameObject, true, true));
       if (this.waitStateName == null) {
     foreach (ComboWrapper combo in this.combos.Values) {
       SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant);
       foreach (ICondition condition in combo.conditions) {
     behaviour = behaviour.WithCondition(condition);
       }
       state.AddUpdateBehaviour(behaviour);
     }
       }
       TeleportToBehaviour teleportToBehaviour = new TeleportToBehaviour(this.gameObject, this.obstacles).TeleportAhead(this.distance);
       if (this.target != null) {
     teleportToBehaviour = teleportToBehaviour.WithTarget(this.target);
       }
       if (this.targetVariable != null) {
     teleportToBehaviour = teleportToBehaviour.WithTargetVariable(this.targetVariable);
       }
       state.AddExitBehaviour(teleportToBehaviour);
       foreach (FSMBehaviour behaviour in this.customExitBehaviours) {
     state.AddExitBehaviour(behaviour);
       }
       if (this.soundExit != null) {
     state.AddExitBehaviour(new PlaySoundBehaviour(this.gameObject, this.soundExit).Force());
       }
       if (this.effectExit != null) {
     state.AddExitBehaviour(new InstantiateBehaviour(this.gameObject, this.effectExit));
       }
       stateWrapper.state = state;
       //TRANSITIONS
       FSMTransition transition = null;
       foreach (string startingState in this.startingStates) {
     transition = new FSMTransition(startingState, this.stateName);
     VarConditionsBuilder builder = new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP))
     .WithVar(CharVars.TARGET, new ObjectCondition(this.targetVariable));
     if (this.counterVariable != null) {
       builder = builder.WithVar(this.counterVariable, new IntCondition(this.counterVariable.ToS(), Operators.LESS_THAN, this.maxTeleports));
     }
     transition.AddConditions(builder.Build());
     stateWrapper.transitions.Add(transition);
       }
       //RETURN
       if (this.waitStateName == null) {
     foreach (string animationName in this.animationNames) {
       foreach (ComboWrapper combo in this.combos.Values) {
     transition = new FSMTransition(this.stateName, combo.toState);
     transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName));
     transition.AddConditions(
       new VarConditionsBuilder()
       .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
       .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant))
       .Build()
     );
     stateWrapper.transitions.Add(transition);
       }
     }
     transition = new FSMTransition(this.stateName, CharStates.FALL.ToS());
     transition.AddCondition(new TimeCondition(this.timeout));
     transition.AddConditions(
       new VarConditionsBuilder()
       .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
       .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false))
       .Build()
     );
     stateWrapper.transitions.Add(transition);
     transition = new FSMTransition(this.stateName, CharStates.FLY.ToS());
//.........这里部分代码省略.........
开发者ID:BrunoRomes,项目名称:UnityTests,代码行数:101,代码来源:TeleportBuilder.cs

示例4: BuildWait

 private StateWrapper BuildWait()
 {
     StateWrapper stateWrapper = new StateWrapper();
       FSMState state = new ActionState(this.waitStateName);
       state.WithDefaultBehaviours(this.gameObject);
       if (this.waitAnimationBehaviour != null) {
     state.AddStartBehaviour(this.waitAnimationBehaviour);
       }
       state.AddStartBehaviour(new StopMovementBehaviour(this.gameObject).WithXAxis().WithYAxis());
       state.AddStartBehaviour(new IgnoreGravityBehaviour(this.gameObject));
       state.AddStartBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.IGNORE_DRAG.ToS(), false));
       if (this.flip) {
     state.AddStartBehaviour(BehavioursBuilder.BuildFlip(this.gameObject, false).Invert());
       }
       foreach (FSMBehaviour behaviour in this.customStartBehaviours) {
     state.AddStartBehaviour(behaviour);
       }
       foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) {
     state.AddUpdateBehaviour(behaviour);
       }
       state.AddUpdateBehaviour(BehavioursBuilder.BuildKeepInsideBounds(this.gameObject, true, true));
       foreach (ComboWrapper combo in this.combos.Values) {
     SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant);
     foreach (ICondition condition in combo.conditions) {
       behaviour = behaviour.WithCondition(condition);
     }
     state.AddUpdateBehaviour(behaviour);
       }
       state.AddExitBehaviour(new RestoreGravityBehaviour(this.gameObject, CharVars.ORIGINAL_GRAVITY_SCALE.ToS()));
       foreach (FSMBehaviour behaviour in this.customExitBehaviours) {
     state.AddExitBehaviour(behaviour);
       }
       stateWrapper.state = state;
       //TRANSITIONS
       FSMTransition transition = null;
       foreach (string animationName in this.animationNames) {
     transition = new FSMTransition(this.stateName, this.waitStateName);
     transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName));
     stateWrapper.transitions.Add(transition);
       }
       //RETURN
       foreach (ComboWrapper combo in this.combos.Values) {
     transition = new FSMTransition(this.waitStateName, combo.toState);
     transition.AddConditions(
       new VarConditionsBuilder()
       .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
       .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant))
       .Build()
     );
     stateWrapper.transitions.Add(transition);
       }
       transition = new FSMTransition(this.waitStateName, CharStates.FALL.ToS());
       transition.AddCondition(new TimeCondition(this.timeout));
       transition.AddConditions(
     new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false))
     .Build()
       );
       stateWrapper.transitions.Add(transition);
       transition = new FSMTransition(this.waitStateName, CharStates.FLY.ToS());
       transition.AddCondition(new TimeCondition(this.timeout));
       transition.AddConditions(
     new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true))
     .Build()
       );
       stateWrapper.transitions.Add(transition);
       return stateWrapper;
 }
开发者ID:BrunoRomes,项目名称:UnityTests,代码行数:71,代码来源:TeleportBuilder.cs

示例5: BuildAttack

 private StateWrapper BuildAttack()
 {
     StateWrapper stateWrapper = new StateWrapper();
       FSMState state = new ActionState(this.stateName);
       state.WithDefaultBehaviours(this.gameObject);
       if (this.animationBehaviour != null) {
     state.AddStartBehaviour(this.animationBehaviour);
       }
       state.AddStartBehaviour(new SetVariableBehaviour(this.gameObject, CharVars.ATTACK_EFFECT.ToS(), (int) AttackEffects.NONE));
       if (this.stepForce != 0) {
     state.AddStartBehaviour(
       new ApplyForceBehaviour(this.gameObject)
       .WithDirection(new Vector2(1f, 0f))
       .WithForce(this.stepForce)
       .WithRelativeXDirection(CharVars.FACING_DIRECTION.ToS(), false)
     );
       }
       foreach (ComboWrapper combo in this.combos.Values) {
     SetVariableBehaviour behaviour = new SetVariableBehaviour(this.gameObject, CharVars.COMBO_VARIANT.ToS(), combo.variant);
     foreach (ICondition condition in combo.conditions) {
       behaviour = behaviour.WithCondition(condition);
     }
     state.AddUpdateBehaviour(behaviour);
       }
       foreach (FSMBehaviour behaviour in this.customStartBehaviours) {
     state.AddStartBehaviour(behaviour);
       }
       foreach (FSMBehaviour behaviour in this.customUpdateBehaviours) {
     state.AddUpdateBehaviour(behaviour);
       }
       foreach (FSMBehaviour behaviour in this.customExitBehaviours) {
     state.AddExitBehaviour(behaviour);
       }
       stateWrapper.state = state;
       FSMTransition transition = null;
       foreach (string startingState in this.startingStates) {
     transition = new FSMTransition(startingState, this.stateName);
     VarConditionsBuilder conditions = new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat();
     if (this.fromCharge) {
       conditions.WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.RELEASE, InputModes.NONE));
     } else {
       conditions.WithVar(CharVars.FromInputMode(this.input), new InputCondition(CharVars.FromInputMode(this.input).ToS(), Operators.EQUAL, InputModes.PRESS, InputModes.DOUBLE_TAP));
     }
     foreach (CharVar charVar in this.customTransitions.Keys) {
       conditions.WithVar(charVar, this.customTransitions[charVar]);
     }
     transition.AddConditions(conditions.Build());
     stateWrapper.transitions.Add(transition);
       }
       // // RETURN
       foreach (string animationName in this.animationNames) {
     foreach (ComboWrapper combo in this.combos.Values) {
       transition = new FSMTransition(this.stateName, combo.toState);
       transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName));
       transition.AddConditions(
     new VarConditionsBuilder()
     .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
     .WithVar(CharVars.COMBO_VARIANT, new IntCondition(CharVars.COMBO_VARIANT.ToS(), Operators.EQUAL, combo.variant))
     .Build()
       );
       stateWrapper.transitions.Add(transition);
     }
     transition = new FSMTransition(this.stateName, CharStates.IDLE.ToS());
     transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName));
     transition.AddConditions(
       new VarConditionsBuilder()
       .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
       .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, false))
       .Build()
     );
     stateWrapper.transitions.Add(transition);
     transition = new FSMTransition(this.stateName, CharStates.FLY.ToS());
     transition.AddCondition(new AnimationEndCondition(this.gameObject.GetComponent<Animator>(), animationName));
     transition.AddConditions(
       new VarConditionsBuilder()
       .IgnoringInputs().IgnoringAttributes().IgnoringDirections().IgnoringPositions().IgnoringFlags().IgnoringCombat()
       .WithVar(CharVars.IS_FLYING, new BoolCondition(CharVars.IS_FLYING.ToS(), Operators.EQUAL, true))
       .Build()
     );
     stateWrapper.transitions.Add(transition);
       }
       return stateWrapper;
 }
开发者ID:BrunoRomes,项目名称:UnityTests,代码行数:84,代码来源:BasicMeleeAttackBuilder.cs


注:本文中的ActionState.WithDefaultBehaviours方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。