/* * Set the fighter to bandaging state and start bandaging. */ void TryBandage() { if (RBInput.GetButtonForPlayer(InputStrings.BANDAGE, PlayerIndex, playerDevice)) { fighter.Bandage(); } else { fighter.InterruptBandage(); } }
/* * 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); } } }
/* * 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(); } } }
/* * Apply movement in the Player's desired directions according to the various speed * and movement variables. */ void Move() { // Get input values float horizontal = 0.0f, vertical = 0.0f; horizontal = RBInput.GetAxisRawForPlayer(InputStrings.HORIZONTAL, PlayerIndex, playerDevice); vertical = RBInput.GetAxisRawForPlayer(InputStrings.VERTICAL, PlayerIndex, playerDevice); // Determine move direction from target values float targetSpeed = 0.0f; Vector3 targetDirection = new Vector3(horizontal, 0.0f, vertical); if (targetDirection != Vector3.zero) { moveDirection = Vector3.RotateTowards(moveDirection, targetDirection, Mathf.Infinity, 1000); moveDirection = moveDirection.normalized; if (RBInput.GetButtonForPlayer(InputStrings.SPRINT, PlayerIndex, playerDevice)) { targetSpeed = sprintspeed; } else { targetSpeed = movespeed; } } // Get movement vector Vector3 movement = (moveDirection * targetSpeed) + new Vector3(0.0f, verticalSpeed, 0.0f); movement *= Time.deltaTime; // Apply movement vector CharacterController biped = GetComponent <CharacterController> (); collisionFlags = biped.Move(movement); // Rotate to face the direction of movement immediately if (moveDirection != Vector3.zero) { transform.rotation = Quaternion.LookRotation(moveDirection); } }
/* * Apply movement in the Player's desired directions according to the various speed * and movement variables. */ void TryMove() { // Get input values float horizontal = 0.0f, vertical = 0.0f; horizontal = RBInput.GetAxisRawForPlayer(InputStrings.HORIZONTAL, PlayerIndex, playerDevice); vertical = RBInput.GetAxisRawForPlayer(InputStrings.VERTICAL, PlayerIndex, playerDevice); Vector3 direction = new Vector3(horizontal, 0.0f, vertical); if (direction != Vector3.zero) { if (RBInput.GetButtonForPlayer(InputStrings.SPRINT, PlayerIndex, playerDevice)) { fighter.Sprint(direction); } else { fighter.Run(direction); } } }