// process player input void Update() { Vector2 movement = new Vector2(Input.GetAxisRaw("Horizontal" + playerNum), Input.GetAxisRaw("Vertical" + playerNum)); fighter.Movement(movement); if (Input.GetButtonDown("Punch" + playerNum)) { // punch fighter.Attack(0); } if (Input.GetButtonDown("Projectile" + playerNum)) { // fireball fighter.Attack(1); } if (Input.GetButton("Block" + playerNum)) { // block fighter.Block(true); } else { fighter.Block(false); } if (Input.GetButtonDown("Jump" + playerNum)) { fighter.Jump(); } if (Input.GetButtonDown("Taunt" + playerNum)) { fighter.Taunt(); } }
/* * Set fighter to blocking or unblocking depending on button up or down. */ void TryBlock() { if (RBInput.GetAxisForPlayer(InputStrings.BLOCK, PlayerIndex, playerDevice) == 1 || RBInput.GetButtonForPlayer(InputStrings.BLOCK, PlayerIndex, playerDevice)) { fighter.Block(); } else if (RBInput.GetAxisForPlayer(InputStrings.BLOCK, PlayerIndex, playerDevice) == 0 || RBInput.GetButtonUpForPlayer(InputStrings.BLOCK, PlayerIndex, playerDevice)) { if (fighter.IsBlocking) { fighter.UnBlock(); } } }
/* * Set fighter to blocking or unblocking depending on button up or down. */ void TryBlock() { if (RBInput.GetAxisForPlayer(InputStrings.BLOCK, PlayerIndex) == 1 || RBInput.GetButtonForPlayer(InputStrings.BLOCK, PlayerIndex)) { fighter.Block(); } else if (RBInput.GetAxisForPlayer(InputStrings.BLOCK, PlayerIndex) < 1 || RBInput.GetButtonUpForPlayer(InputStrings.BLOCK, PlayerIndex)) { if (fighter.isBlocking) { fighter.UnBlock(false); } } }