Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.29 KB | None | 0 0
  1. using System;
  2. using UnityEngine;
  3. using HutongGames.PlayMaker;
  4.  
  5. [ActionCategory("ExitLimbo")]
  6. public class JuggleGrabListener : PlayerStateAction
  7. {
  8.     public FsmEvent grabEvent;
  9.     public FsmEvent noGrabEvent;
  10.  
  11.     public FsmFloat fromTime;
  12.     public FsmFloat toTime;
  13.  
  14.     protected BaseInputController inputCtrl;
  15.  
  16.     public override void Reset()
  17.     {
  18.         this.fromTime = 0f;
  19.         this.toTime = 1f;
  20.  
  21.     }
  22.  
  23.     public override void OnEnter()
  24.     {
  25.         this.inputCtrl = this.playerCtrl.GetComponent<BaseInputController>();
  26.         this.checkInput();
  27.     }
  28.  
  29.     private void OnAnimationComplete()
  30.     {
  31.  
  32.     }
  33.  
  34.     public override void OnUpdate()
  35.     {
  36.         this.checkInput();
  37.     }
  38.  
  39.     private void checkInput()
  40.     {
  41.         var punchHeld = this.inputCtrl.getInput(InputManager.Input.Punch) > 0;
  42.         var kickHeld = this.inputCtrl.getInput(InputManager.Input.Kick) > 0;
  43.  
  44.         var relativeTime = this.animationCtrl.normalizedTime;
  45.         var tooSoon = relativeTime < this.fromTime.Value;
  46.         var tooLate = relativeTime > this.toTime.Value;
  47.  
  48.         if (punchHeld && kickHeld) {
  49.             this.Fsm.Event(this.grabEvent);
  50.         } else if (!punchHeld||!kickHeld||tooSoon) {
  51.             this.Fsm.Event(this.noGrabEvent);
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement