mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-08-23 19:04:32 -05:00
Merge branch 'controller' into main
This commit is contained in:
@@ -10,6 +10,8 @@ public class dDash : NetworkBehaviour{
|
||||
public const float maxDashTime = 1.0f;
|
||||
public float dashDistance = 10;
|
||||
public float dashStoppingSpeed = 0.1f;
|
||||
public SpecialItem dashItem;
|
||||
private bool isOnCoolDown = false;
|
||||
float currentDashTime = maxDashTime;
|
||||
float dashSpeed = 12;
|
||||
|
||||
@@ -23,9 +25,10 @@ public class dDash : NetworkBehaviour{
|
||||
void FixedUpdate(){
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
if(characterController.enabled == true){
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
if (Input.GetKeyDown(KeyCode.E) && isOnCoolDown == false)
|
||||
{
|
||||
currentDashTime = 0;
|
||||
currentDashTime = 0;
|
||||
StartCoroutine(startCoolDown());
|
||||
}
|
||||
if(currentDashTime < maxDashTime)
|
||||
{
|
||||
@@ -40,4 +43,13 @@ public class dDash : NetworkBehaviour{
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(){
|
||||
Debug.Log("start corotine");
|
||||
isOnCoolDown = true;
|
||||
//driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(dashItem.cooldownM);
|
||||
isOnCoolDown = false;
|
||||
Debug.Log("end corotine");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,8 @@ public class dGrapplingHook : NetworkBehaviour
|
||||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.E)) //If grapple button is hit
|
||||
//if E or left face gamepad button is pressed is slightly pressed
|
||||
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
|
||||
{
|
||||
if (!isGrappled) //If we are not grappling
|
||||
{
|
||||
@@ -60,7 +61,8 @@ public class dGrapplingHook : NetworkBehaviour
|
||||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift)) //Extend hook
|
||||
//if left shift or left bumper held down
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.JoystickButton4)) //Extend hook
|
||||
{
|
||||
ropeLength += climbRate * Time.deltaTime;
|
||||
if (ropeLength > maxGrappleDistance)
|
||||
@@ -69,7 +71,7 @@ public class dGrapplingHook : NetworkBehaviour
|
||||
}
|
||||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
if (Input.GetKey(KeyCode.RightShift)) // Retract Hook
|
||||
if (Input.GetKey(KeyCode.RightShift) || Input.GetKey(KeyCode.JoystickButton5)) // Retract Hook
|
||||
{
|
||||
ropeLength -= climbRate * Time.deltaTime;
|
||||
if (ropeLength < 5)
|
||||
|
||||
@@ -28,7 +28,10 @@ public class dKickController : NetworkBehaviour
|
||||
}
|
||||
|
||||
void Kick(){
|
||||
if (Input.GetKeyDown(KeyCode.F) && isKicking == false && characterController.isGrounded == false)
|
||||
//Note: when we merge this into PlayerMovement, we may want to change isgrounded to our
|
||||
//custom is grounded
|
||||
//If F is pressed or gamepad right trigger is pulled
|
||||
if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false && characterController.isGrounded == false)
|
||||
{
|
||||
Debug.Log("dive");
|
||||
// if kicking in air, kick until grounded (maybe add some foward momentum if needeD)
|
||||
@@ -37,13 +40,14 @@ public class dKickController : NetworkBehaviour
|
||||
leg.SetActive(true);
|
||||
}
|
||||
//otherwise do ground kick for .3 seconds
|
||||
else if (Input.GetKeyDown(KeyCode.F) && isKicking == false){
|
||||
else if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){
|
||||
Debug.Log("kick");
|
||||
StartCoroutine(Kicking(.3f));
|
||||
}
|
||||
|
||||
//once dive kick touches ground, set back to normal state
|
||||
if(characterController.isGrounded == true && isDiveKicking == true){
|
||||
if (characterController.isGrounded == true && isDiveKicking == true)
|
||||
{
|
||||
isDiveKicking = false;
|
||||
isKicking = false;
|
||||
leg.SetActive(false);
|
||||
|
||||
@@ -258,7 +258,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
//Jump Function
|
||||
private void Jump()
|
||||
{
|
||||
//If space is pressed apply an upwards force to the player
|
||||
//If space/south gamepad button is pressed apply an upwards force to the player
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
|
||||
{
|
||||
if(wallRun.IsWallRunning()){
|
||||
@@ -280,7 +280,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
curJumpNum = 0;
|
||||
}
|
||||
|
||||
//If space isn't being pressed then jump is false
|
||||
//If space/south face gamepad button isn't being pressed then jump is false
|
||||
if (Input.GetAxis("Jump") == 0) jumpPressed = false;
|
||||
}
|
||||
|
||||
@@ -311,16 +311,30 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
//Camera and Player Rotation
|
||||
private void Rotation()
|
||||
{
|
||||
Vector3 lastCamPos = new Vector3(0,0,0);
|
||||
Vector3 rotOffset = transform.localEulerAngles;
|
||||
if(moveController.enabled){
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
//if input is received from Mouse X
|
||||
if (Input.GetAxis("Mouse X") != 0)
|
||||
{
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
}
|
||||
//if input is received from right analog stick (horizontal)
|
||||
else if (Input.GetAxis("HorizontalCam") != 0)
|
||||
{
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam"));
|
||||
}
|
||||
|
||||
|
||||
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
//if input is if input is received from Mouse Y
|
||||
if (Input.GetAxis("Mouse Y") != 0)
|
||||
{
|
||||
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
}
|
||||
//if input is received from right analog stick (vertical)
|
||||
else if (Input.GetAxis("VerticalTurn") != 0)
|
||||
{
|
||||
camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,7 +454,8 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
|
||||
//Slide Function
|
||||
private void Slide(){
|
||||
if (Input.GetKey(KeyCode.Q)){
|
||||
//if the q button or the east face button on gamepad is held down
|
||||
if (Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)) {
|
||||
qDown = true;
|
||||
if (isSliding == false){
|
||||
originalTraction = pStats.Traction;
|
||||
|
||||
@@ -30,7 +30,8 @@ public class KickController : NetworkBehaviour
|
||||
void Kick(){
|
||||
//Note: when we merge this into PlayerMovement, we may want to change isgrounded to our
|
||||
//custom is grounded
|
||||
if (Input.GetKeyDown(KeyCode.F) && isKicking == false && characterController.isGrounded == false)
|
||||
//If F is pressed or gamepad right trigger is pulled
|
||||
if ((Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false && characterController.isGrounded == false)
|
||||
{
|
||||
Debug.Log("dive");
|
||||
// if kicking in air, kick until grounded (maybe add some foward momentum if needeD)
|
||||
@@ -39,7 +40,7 @@ public class KickController : NetworkBehaviour
|
||||
leg.SetActive(true);
|
||||
}
|
||||
//otherwise do ground kick for .3 seconds
|
||||
else if (Input.GetKeyDown(KeyCode.F) && isKicking == false){
|
||||
else if (( Input.GetKeyDown(KeyCode.F) || Input.GetAxis("Kick") != 0) && isKicking == false){
|
||||
Debug.Log("kick");
|
||||
StartCoroutine(Kicking(.3f));
|
||||
}
|
||||
|
||||
38
Assets/Scripts/PlayerScripts/MovementAbilities/Nitro.cs
Normal file
38
Assets/Scripts/PlayerScripts/MovementAbilities/Nitro.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Nitro : MonoBehaviour
|
||||
{
|
||||
private PlayerStats playerStats;
|
||||
private CoolDown driver;
|
||||
private bool isOnCoolDown = false;
|
||||
public SpecialItem nitroItem;
|
||||
//this will need to be set from scritable object or something;
|
||||
private float coolDown;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start(){
|
||||
playerStats = GetComponent<PlayerStats>();
|
||||
coolDown = 5.0f;
|
||||
//retrieves
|
||||
driver = FindObjectOfType<CoolDown>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
//once cooldowns are implemented, put this on one (a long one)
|
||||
if (Input.GetKeyDown(KeyCode.LeftShift) && isOnCoolDown == false){
|
||||
playerStats.CurVel = playerStats.MaxVel;
|
||||
StartCoroutine(startCoolDown());
|
||||
}
|
||||
}
|
||||
private IEnumerator startCoolDown(){
|
||||
Debug.Log("start corotine");
|
||||
isOnCoolDown = true;
|
||||
//driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(nitroItem.cooldownM);
|
||||
isOnCoolDown = false;
|
||||
Debug.Log("end corotine");
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ public class Dash : NetworkBehaviour {
|
||||
public const float maxDashTime = 1.0f;
|
||||
public float dashDistance = 10;
|
||||
public float dashStoppingSpeed = 0.1f;
|
||||
public SpecialItem dashItem;
|
||||
private bool isOnCoolDown = false;
|
||||
float currentDashTime = maxDashTime;
|
||||
float dashSpeed = 12;
|
||||
|
||||
@@ -23,9 +25,10 @@ public class Dash : NetworkBehaviour {
|
||||
void FixedUpdate(){
|
||||
if (!IsLocalPlayer) { return; }
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.E))
|
||||
if (Input.GetKeyDown(KeyCode.E) && isOnCoolDown == false)
|
||||
{
|
||||
currentDashTime = 0;
|
||||
currentDashTime = 0;
|
||||
StartCoroutine(startCoolDown());
|
||||
}
|
||||
if(currentDashTime < maxDashTime)
|
||||
{
|
||||
@@ -36,7 +39,17 @@ public class Dash : NetworkBehaviour {
|
||||
{
|
||||
moveDirection = Vector3.zero;
|
||||
}
|
||||
|
||||
characterController.Move(moveDirection * Time.deltaTime * dashSpeed);
|
||||
}
|
||||
|
||||
private IEnumerator startCoolDown(){
|
||||
Debug.Log("start corotine");
|
||||
isOnCoolDown = true;
|
||||
//driver.startUICooldown("Nitro");
|
||||
yield return new WaitForSeconds(dashItem.cooldownM);
|
||||
isOnCoolDown = false;
|
||||
Debug.Log("end corotine");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class GrapplingHook : NetworkBehaviour
|
||||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.E)) //If grapple button is hit
|
||||
if (Input.GetKeyDown(KeyCode.E) || Input.GetKeyDown(KeyCode.JoystickButton2)) //If grapple button is hit
|
||||
{
|
||||
if (!isGrappled) //If we are not grappling
|
||||
{
|
||||
@@ -59,8 +59,8 @@ public class GrapplingHook : NetworkBehaviour
|
||||
if (isGrappled)
|
||||
{
|
||||
Debug.DrawRay(gameObject.transform.position, (hookPoint.transform.position - gameObject.transform.position)); //Visual of line
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift)) //Extend hook
|
||||
|
||||
if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.JoystickButton4)) //Extend hook
|
||||
{
|
||||
ropeLength += climbRate * Time.deltaTime;
|
||||
if (ropeLength > maxGrappleDistance)
|
||||
@@ -69,7 +69,7 @@ public class GrapplingHook : NetworkBehaviour
|
||||
}
|
||||
//Debug.Log(ropeLength.ToString());
|
||||
}
|
||||
if (Input.GetKey(KeyCode.RightShift)) // Retract Hook
|
||||
if (Input.GetKey(KeyCode.RightShift) || Input.GetKey(KeyCode.JoystickButton5)) // Retract Hook
|
||||
{
|
||||
ropeLength -= climbRate * Time.deltaTime;
|
||||
if (ropeLength < 5)
|
||||
|
||||
@@ -3,12 +3,10 @@ using System.Collections.Generic;
|
||||
using MLAPI;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class PlayerMovement : NetworkBehaviour
|
||||
{
|
||||
//Controller object
|
||||
new GamePadControlls controler;
|
||||
//Scripts
|
||||
public PlayerStats pStats;
|
||||
|
||||
@@ -90,8 +88,8 @@ public class PlayerMovement : NetworkBehaviour
|
||||
capCol = GetComponent<CapsuleCollider>();
|
||||
pStats = GetComponent<PlayerStats>();
|
||||
parentObj = transform.parent.gameObject;
|
||||
controler = new GamePadControlls();
|
||||
controler.Runner.Enable();
|
||||
|
||||
|
||||
|
||||
capCol.enabled = false;
|
||||
//Wallrun
|
||||
@@ -299,13 +297,30 @@ public class PlayerMovement : NetworkBehaviour
|
||||
Vector3 lastCamPos = new Vector3(0,0,0);
|
||||
Vector3 rotOffset = transform.localEulerAngles;
|
||||
if(moveController.enabled){
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
|
||||
|
||||
//if input is received from Mouse X
|
||||
if (Input.GetAxis("Mouse X") != 0){
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
}
|
||||
//if input is received from right analog stick (horizontal)
|
||||
else if(Input.GetAxis("HorizontalCam") != 0){
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("HorizontalCam"));
|
||||
}
|
||||
|
||||
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
//if input is if input is received from Mouse Y
|
||||
if (Input.GetAxis("Mouse Y") != 0)
|
||||
{
|
||||
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
}
|
||||
//if input is received from right analog stick (vertical)
|
||||
else if (Input.GetAxis("VerticalTurn") != 0){
|
||||
camRotation.x -= Input.GetAxis("VerticalTurn") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -425,7 +440,7 @@ public class PlayerMovement : NetworkBehaviour
|
||||
|
||||
//Slide Function
|
||||
private void Slide(){
|
||||
if (Input.GetKey(KeyCode.Q)){
|
||||
if (Input.GetKey(KeyCode.JoystickButton1) || Input.GetKey(KeyCode.Q)){
|
||||
qDown = true;
|
||||
if (isSliding == false){
|
||||
originalTraction = pStats.Traction;
|
||||
|
||||
Reference in New Issue
Block a user