예제 #1
0
 private void handleInput()
 {
     if (debugButton != 0)
     {
         Debug.Log("Button not zero");
     }
     //Debug.Log("Player is null: " + (player == null));
     if ((Input.GetKeyDown(KeyCode.X) || !debugMode && player.Device.Action3) && state <= CharacterState.blocking)
     {
         state = CharacterState.punching;
         actionController.Punch();
         unlockTimer = punchTime;
         actionLock  = true;
         debugButton = 0;
     }
     else if ((Input.GetKeyDown(KeyCode.S) || !debugMode && player.Device.Action2) && state <= CharacterState.blocking)
     {
         /*state = CharacterState.kicking;
          * actionController.Kick();
          * debugButton = 0;*/
         state      = CharacterState.dodge;
         dodgeTimer = dodgeTime;
         actionLock = true;
     }
     else if ((Input.GetKeyDown(KeyCode.D) || !debugMode && player.Device.Action1) && state <= CharacterState.blocking)
     {
         state = CharacterState.blocking;
         actionController.Block();
         debugButton = 0;
     }
     else if ((Input.GetKeyDown(KeyCode.C) || !debugMode && player.Device.Action4) && state <= CharacterState.blocking)
     {
         state = CharacterState.heavyPunching;
         actionController.HeavyPunch();
         unlockTimer = bigHit;
         actionLock  = true;
         debugButton = 0;
     }
     //*/
     else if (state <= CharacterState.moving)
     {
         if (Mathf.Abs(player.Device.LeftStickX.Value) > 0.15f &&
             (Mathf.Abs(Vector3.Distance(transform.position, otherPlayer.transform.position)) > 2f ||
              leftPlayer && player.Device.LeftStickX.Value < 0 ||
              !leftPlayer && player.Device.LeftStickX.Value > 0))
         {
             state     = CharacterState.moving;
             direction = new Vector2(player.Device.LeftStickX.Value, 0f);
         }
         else
         {
             direction = Vector2.zero;
             state     = CharacterState.idle;
         }
     }
     if (state != CharacterState.moving)
     {
         direction = Vector2.zero;
     }
     if (player.Device.Action1.WasReleased && state <= CharacterState.blocking)
     {
         state = CharacterState.idle;
     }
 }