SHARE
TWEET

Untitled

a guest Sep 16th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [CreateAssetMenu(fileName = "PlayerInputHandler", menuName = "ScriptableObjects/PlayerInputHandler", order = 1)]
  2. public class PlayerInputHandler : InputHandler
  3. {
  4.     [SerializeField]
  5.     int value;
  6.  
  7.     ActionContainer buttonA;
  8.     ActionContainer buttonD;
  9.     ActionContainer buttonS;
  10.     ActionContainer buttonW;
  11.     ActionContainer buttonJ = new ShootAction();
  12.     ActionContainer buttonSpace;
  13.  
  14.     public override void HandleInput()
  15.     {
  16.         HandlePlayerInput();
  17.     }
  18.  
  19.     public void HandlePlayerInput()
  20.     {
  21.         Action actionToReturn = null;
  22.  
  23.         //button press
  24.         if (Input.GetKeyDown(KeyCode.J) && buttonJ != null)
  25.         {
  26.             actionToReturn = buttonJ.getPressAction();
  27.         }
  28.         else if (Input.GetKeyDown(KeyCode.Space) && buttonSpace != null)
  29.         {
  30.             actionToReturn = buttonSpace.getPressAction();
  31.         }
  32.  
  33.         //button release
  34.         if (Input.GetKeyUp(KeyCode.J) && buttonJ != null)
  35.         {
  36.             actionToReturn = buttonJ.getReleaseAction();
  37.         }
  38.         else if (Input.GetKeyUp(KeyCode.Space) && buttonSpace != null)
  39.         {
  40.             actionToReturn = buttonSpace.getReleaseAction();
  41.         }
  42.  
  43.         GameController.Player.ExecuteAction(actionToReturn);
  44.     }
  45. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top