public override void OnEnter() { target = blackboard.GetValue <Transform> ("Target"); _dashDuration = Random.Range(dashDurationMin, dashDurationMax); _timer = 0f; var dir = AIUtils.GetTargetDirectionRelative(target.position, Owner.transform.position); if (TowardTarget) { _dashDirection = dir; } else { _dashDirection = -dir; } if (FaceDirection == 1) { faceDirectionComponent.SetFaceDirection(dir); } if (FaceDirection == -1) { faceDirectionComponent.SetFaceDirection(-dir); } platformController.ClearVelocity(); platformController.ActiveGravity = false; }
private void Awake() { stateMachine = new StateMachineBuilder() .State(STATE_Idle) .Enter(state => { animator.Play(hand.equipped ? getEquippedAnimation(stateMachine.CurrentStateStr) : "idle"); }) .Condition(() => statCollection.GetStatValue(GlobalSymbol.INPUTVAR_MOVE_HORIZONTAL) != 0, state => stateMachine.ChangeState(STATE_Run)) .Condition(() => playerInput.GetButtonDown(GlobalSymbol.INPUTACTION_Jump), state => stateMachine.ChangeState(STATE_Jump)) .Condition(() => !movement.isGrounded, state => stateMachine.ChangeState(STATE_Fall)) .Update((state, dt) => { }) .End() .State(STATE_Run) .Enter(state => { animator.Play(hand.equipped ? getEquippedAnimation(stateMachine.CurrentStateStr) : "run"); }) .Condition(() => statCollection.GetStatValue(GlobalSymbol.INPUTVAR_MOVE_HORIZONTAL) == 0, state => stateMachine.ChangeState(STATE_Idle)) .Condition(() => playerInput.GetButtonDown(GlobalSymbol.INPUTACTION_Jump), state => stateMachine.ChangeState(STATE_Jump)) .Update((state, dt) => { movement.Move(new Vector2(statCollection.GetStatValue(GlobalSymbol.INPUTVAR_MOVE_HORIZONTAL), 0)); faceDirectionComponent.SetFaceDirection(statCollection.GetStatValue(GlobalSymbol.INPUTVAR_MOVE_HORIZONTAL)); }) .End() .State(STATE_Jump) .Enter(state => { animator.Play(hand.equipped ? getEquippedAnimation(stateMachine.CurrentStateStr) : "jump"); movement.Jump(statCollection.GetStatValue(GlobalSymbol.JUMP_HEIGHT)); }) .Exit(state => { }) .Condition(() => movement.isGrounded, state => stateMachine.ChangeState(STATE_Idle)) .Update((state, dt) => { movement.Move(new Vector2(statCollection.GetStatValue(GlobalSymbol.INPUTVAR_MOVE_HORIZONTAL), 0)); }) .End() .State(STATE_Fall) .Enter(state => { animator.Play(hand.equipped ? getEquippedAnimation(stateMachine.CurrentStateStr) : "jump"); }) .Condition(() => movement.isGrounded, state => stateMachine.ChangeState(STATE_Idle)) .Update((state, dt) => { movement.Move(new Vector2(statCollection.GetStatValue(GlobalSymbol.INPUTVAR_MOVE_HORIZONTAL), 0)); faceDirectionComponent.SetFaceDirection(statCollection.GetStatValue(GlobalSymbol.INPUTVAR_MOVE_HORIZONTAL)); }) .End() .Build() as RSG.AbstractState; // movement.onMoved += onMovementMove; hand.onEquipped += onHandGearEquipped; hand.onUnequipped += onHandGearUnequipped; stateMachine.PushState(STATE_Idle); }
public override void OnEnter() { target = blackboard.GetValue <Transform> ("Target"); if (!dynamicMove) { var relDir = Util.GetPlayerDirectionRelative(target.position, platformController.transform.position); moveTargetX = target.position.x - relDir * statCollection.GetStatValue(KEY_RANGE_X); } if (!dynamicFaceTo) { faceDirectionComponent.SetFaceDirection(faceToTarget ? Util.GetPlayerDirectionRelative(target.position, platformController.transform.position) : -Util.GetPlayerDirectionRelative(target.position, platformController.transform.position)); } }