Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using UnityEngine;
- using HutongGames.PlayMaker;
- [ActionCategory("ExitLimbo")]
- public class JuggleGrabListener : PlayerStateAction
- {
- public FsmEvent grabEvent;
- public FsmEvent noGrabEvent;
- public FsmFloat fromTime;
- public FsmFloat toTime;
- protected BaseInputController inputCtrl;
- public override void Reset()
- {
- this.fromTime = 0f;
- this.toTime = 1f;
- }
- public override void OnEnter()
- {
- this.inputCtrl = this.playerCtrl.GetComponent<BaseInputController>();
- this.checkInput();
- }
- private void OnAnimationComplete()
- {
- }
- public override void OnUpdate()
- {
- this.checkInput();
- }
- private void checkInput()
- {
- var punchHeld = this.inputCtrl.getInput(InputManager.Input.Punch) > 0;
- var kickHeld = this.inputCtrl.getInput(InputManager.Input.Kick) > 0;
- var relativeTime = this.animationCtrl.normalizedTime;
- var tooSoon = relativeTime < this.fromTime.Value;
- var tooLate = relativeTime > this.toTime.Value;
- if (punchHeld && kickHeld) {
- this.Fsm.Event(this.grabEvent);
- } else if (!punchHeld||!kickHeld||tooSoon) {
- this.Fsm.Event(this.noGrabEvent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement