public void PlayerUpdate() { if (controllerInput.GetStartButtonDown()) { gameManager.PauseGame(isPlayerOne); } if (action == Action.Neutral || action == Action.Attacking) //Attacks managed here { if (controllerInput.GetLeftActionButtonDown()) { attackManager.Punch(stance); } else if (controllerInput.GetBottomActionButtonDown() && !delayFrame) //Same button as resuming from pause menu so wait a frame { attackManager.Kick(stance); } else if (controllerInput.GetTopActionButtonDown()) { attackManager.RangedAttack(stance); } if (stance == Stance.Standing) { if (controllerInput.GetLeftBumperDown()) { attackManager.Taunt(); } else if (!controllerInput.GetRightBumper() && controllerInput.GetRightActionButtonDown()) { attackManager.SpecialAttack(); } else if (controllerInput.GetRightBumper() && controllerInput.GetRightActionButtonDown()) { attackManager.Ultimate(); } } attackManager.PerformComboAttackIfQueued(); } if (action != Action.Recovering && action != Action.Attacking && stance != Stance.KnockedDown) { Vector3 velocity = new Vector3(0f, rb.velocity.y); if (stance == Stance.Jumping) { velocity.x = rb.velocity.x; } else if (stance == Stance.Standing || stance == Stance.Crouching) //Blocking, moving, and crouching inputs { if (controllerInput.GetXAxisLeft()) //Movement { velocity.x -= moveSpeed; anim.SetFloat("direction", -1f); if (!anim.GetBool("walking")) { anim.Play("Walk", 0, float.NegativeInfinity); } } else if (controllerInput.GetXAxisRight()) { velocity.x += moveSpeed; anim.SetFloat("direction", 1f); if (!anim.GetBool("walking")) { anim.Play("Walk"); } } if (action == Action.Blocking) { if (!(controllerInput.GetLeftTrigger() || controllerInput.GetRightTrigger())) { anim.Play("Unblock"); } } else { if (controllerInput.GetLeftTrigger() || controllerInput.GetRightTrigger()) { anim.Play("Block"); action = Action.Recovering; } } if (action != Action.Attacking) { if (stance == Stance.Crouching) { if (!controllerInput.GetYAxisDown()) { anim.Play("Uncrouch"); } } else { if (controllerInput.GetYAxisDown()) { anim.Play("Crouch"); } } } } if (stance == Stance.Standing && action == Action.Neutral) { if (controllerInput.GetYAxisUp()) { invincible = false; stance = Stance.Jumping; velocity.y = 2f; //Add jumping animation } } if (!gameManager.AbleToMoveForward() && //Prevent player from moving past other player ((isPlayerOne && velocity.x > 0f) || (!isPlayerOne && velocity.x < 0f))) { velocity.x = 0f; } rb.velocity = velocity; if (velocity.x == 0f) { anim.SetBool("walking", false); } else { anim.SetBool("walking", true); } } else if (attackMoving) { rb.velocity = attackingVelocity; } else if (stance == Stance.KnockedDown && action != Action.Recovering) { if (controllerInput.GetYAxisUp()) { GetUp(); } } if (inHitFrame) { CheckForHit(); } }
public void CheckForButtonInput() { if (menuActive) { if (!lockedMenu) { if (repeatDelayCount > 0f) { repeatDelayCount -= Time.deltaTime; } int startX = currentX; int startY = currentY; if (controllerInput.GetXAxisLeft() && (repeatDelayCount <= 0f || lastButtonPressed != ButtonTypes.Left)) { do { currentX--; if (currentX < 0) { currentX = maxX; } } while (!ValidButton() && currentX != startX); lastButtonPressed = ButtonTypes.Left; if (currentX != startX) { DeselectButton(startX, startY); SelectButton(); } } else if (controllerInput.GetXAxisRight() && (repeatDelayCount <= 0f || lastButtonPressed != ButtonTypes.Right)) { do { currentX++; if (currentX > maxX) { currentX = 0; } } while (!ValidButton() && currentX != startX); lastButtonPressed = ButtonTypes.Right; if (currentX != startX) { DeselectButton(startX, startY); SelectButton(); } } else if (controllerInput.GetYAxisUp() && (repeatDelayCount <= 0f || lastButtonPressed != ButtonTypes.Up)) { do { currentY--; if (currentY < 0) { currentY = maxY; } } while (!ValidButton() && currentY != startY); lastButtonPressed = ButtonTypes.Up; if (currentY != startY) { DeselectButton(startX, startY); SelectButton(); } } else if (controllerInput.GetYAxisDown() && (repeatDelayCount <= 0f || lastButtonPressed != ButtonTypes.Down)) { do { currentY++; if (currentY > maxY) { currentY = 0; } } while (!ValidButton() && currentY != startY); lastButtonPressed = ButtonTypes.Down; if (currentY != startY) { DeselectButton(startX, startY); SelectButton(); } } else if (controllerInput.GetBottomActionButtonDown()) { PressButton(); } } if (controllerInput.GetRightActionButtonDown()) { menuScript.Cancel(isPlayerOne); } } }