mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-09-08 10:25:16 -05:00
Merge branch 'Sprint5Melby'
This commit is contained in:
@@ -28,8 +28,6 @@ public class dKickController : 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)
|
||||
{
|
||||
Debug.Log("dive");
|
||||
@@ -67,6 +65,9 @@ public class dKickController : NetworkBehaviour
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
Collider myCollider = collision.contacts[0].thisCollider;
|
||||
if (collision.transform.CompareTag("kickable") && myCollider == leg.GetComponent<Collider>()){
|
||||
if(collision.gameObject.GetComponent<Rigidbody>().isKinematic == true){
|
||||
collision.gameObject.GetComponent<Rigidbody>().isKinematic = false;
|
||||
}
|
||||
Vector3 direction = this.transform.forward;
|
||||
Debug.Log(direction);
|
||||
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
|
||||
|
||||
@@ -7,7 +7,7 @@ using UnityEngine.Rendering;
|
||||
public class dWallRun : NetworkBehaviour
|
||||
{
|
||||
|
||||
public float wallMaxDistance = 5;
|
||||
public float wallMaxDistance = .8f;
|
||||
public float wallSpeedMultiplier = 1.2f;
|
||||
public float minimumHeight = .1f;
|
||||
public float maxAngleRoll = 20;
|
||||
@@ -151,13 +151,35 @@ public class dWallRun : NetworkBehaviour
|
||||
Vector3 moveToSet = alongWall * vertical * playerMovementController.PlayerSpeed() * Time.deltaTime;// * wallSpeedMultiplier;
|
||||
Vector3 velNorm = playerMovementController.vel;
|
||||
velNorm.Normalize();
|
||||
|
||||
moveToSet = new Vector3(moveToSet.x * -velNorm.x, moveToSet.y, moveToSet.z * -velNorm.z);
|
||||
|
||||
Vector3 moveToSetNorm = moveToSet;
|
||||
moveToSetNorm.Normalize();
|
||||
|
||||
if((moveToSetNorm.x < 0 && velNorm.x > 0)){
|
||||
moveToSet.x = (moveToSet.x * -velNorm.x);
|
||||
}
|
||||
else if((moveToSetNorm.x > 0 && velNorm.x < 0) ){
|
||||
moveToSet.x = (-moveToSet.x * -velNorm.x);
|
||||
}
|
||||
|
||||
if((moveToSetNorm.z < 0 && velNorm.z > 0)){
|
||||
moveToSet.z = (moveToSet.z * -velNorm.z);
|
||||
}
|
||||
else if((moveToSetNorm.z > 0 && velNorm.z < 0)){
|
||||
moveToSet.z = (-moveToSet.z * -velNorm.z);
|
||||
}
|
||||
|
||||
moveToSet.y = 0;
|
||||
|
||||
|
||||
playerMovementController.SetPlayerVelocity(moveToSet);
|
||||
Debug.Log(moveToSet);
|
||||
isWallRunning = true;
|
||||
if(playerMovementController.curJumpNum != 0){
|
||||
playerMovementController.curJumpNum = 0 ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,10 +197,6 @@ public class dWallRun : NetworkBehaviour
|
||||
|
||||
public Vector3 GetWallJumpDirection() //Add call in jump where if we are wallrunning and jump, the jump vector is multiplied by this
|
||||
{
|
||||
if(isWallRunning)
|
||||
{
|
||||
return lastWallNormal * wallBouncing + Vector3.up;
|
||||
}
|
||||
return Vector3.zero;
|
||||
}
|
||||
return lastWallNormal * wallBouncing + (transform.up);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
private CharacterController moveController;
|
||||
|
||||
//Jump value
|
||||
private int curJumpNum;
|
||||
public int curJumpNum;
|
||||
private bool jumpPressed;
|
||||
bool tempSet = false;
|
||||
float tempTraction = 0.0f;
|
||||
@@ -65,7 +65,7 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
private Rigidbody rB;
|
||||
private CapsuleCollider capCol;
|
||||
private bool firstHit = false;
|
||||
private bool heldDown = false;
|
||||
//private bool heldDown = false; //Variable for testing Ragdoll reenable if needed
|
||||
private bool beginRagTimer = false;
|
||||
private float ragTime;
|
||||
private Vector3 prevRot;
|
||||
@@ -261,7 +261,14 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
//If space is pressed apply an upwards force to the player
|
||||
if (Input.GetAxis("Jump") != 0 && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
|
||||
{
|
||||
AddImpact(transform.up, pStats.JumpPow);
|
||||
if(wallRun.IsWallRunning()){
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 1.3f);
|
||||
AddImpact(transform.up, pStats.JumpPow);
|
||||
}
|
||||
else{
|
||||
AddImpact(transform.up, pStats.JumpPow);
|
||||
}
|
||||
|
||||
curJumpNum++;
|
||||
jumpPressed = true;
|
||||
}
|
||||
@@ -357,8 +364,10 @@ public class dPlayerMovement : NetworkBehaviour
|
||||
|
||||
//Wallrunning
|
||||
else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
|
||||
//If gliding
|
||||
//Go down slowly
|
||||
|
||||
else{
|
||||
vel.y -= pStats.PlayerGrav * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -62,11 +62,14 @@ public class KickController : NetworkBehaviour
|
||||
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
//if (!IsLocalPlayer) { return; }
|
||||
Collider myCollider = collision.contacts[0].thisCollider;
|
||||
if (collision.transform.CompareTag("kickable") && myCollider == leg.GetComponent<Collider>()){
|
||||
if(collision.gameObject.GetComponent<Rigidbody>().isKinematic == true){
|
||||
collision.gameObject.GetComponent<Rigidbody>().isKinematic = false;
|
||||
}
|
||||
Vector3 direction = this.transform.forward;
|
||||
Debug.Log(direction);
|
||||
collision.rigidbody.AddForce(direction * pStats.KickPow, ForceMode.Impulse);
|
||||
@@ -7,7 +7,7 @@ public class PlayerInventory : NetworkBehaviour
|
||||
{
|
||||
|
||||
//List of items
|
||||
[SerializeField] private Dictionary<string, Item> playerItemDict = new Dictionary<string, Item>();
|
||||
[SerializeField] Dictionary<string, Item> playerItemDict = new Dictionary<string, Item>();
|
||||
public Dictionary<string, Item> PlayerItemDict{
|
||||
get{ return playerItemDict; }
|
||||
}
|
||||
@@ -18,11 +18,9 @@ public class PlayerInventory : NetworkBehaviour
|
||||
}
|
||||
//Scripts
|
||||
public PlayerStats pStats;
|
||||
public InventoryManager invMan;
|
||||
|
||||
void Awake(){
|
||||
pStats = GetComponent<PlayerStats>();
|
||||
invMan = FindObjectOfType<InventoryManager>();
|
||||
pStats = GetComponent<PlayerStats>();
|
||||
}
|
||||
|
||||
//Adds player Item to a dictionary
|
||||
@@ -69,14 +67,9 @@ public class PlayerInventory : NetworkBehaviour
|
||||
}
|
||||
|
||||
//Equips All items in list at start of next scene
|
||||
public void UpdateEquips(){
|
||||
if(invMan != null){
|
||||
foreach(string itemName in networkItemList){
|
||||
invMan.ItemDict[itemName].Equip(pStats, this.gameObject);
|
||||
}
|
||||
}
|
||||
else{
|
||||
Debug.Log("invMan is currently not set or disabled");
|
||||
public void UpdateEquips(List<string> items, Dictionary<string, Item> allItems){
|
||||
foreach(string itemName in items){
|
||||
AddItem(allItems[itemName]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d808f60ee05185d43a154521748992a0
|
||||
guid: 286df2f965f4f3c4eb74950f0550e68f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -7,7 +7,7 @@ using UnityEngine.Rendering;
|
||||
public class WallRun : NetworkBehaviour
|
||||
{
|
||||
|
||||
public float wallMaxDistance = 5;
|
||||
public float wallMaxDistance = 5;
|
||||
public float wallSpeedMultiplier = 1.2f;
|
||||
public float minimumHeight = .1f;
|
||||
public float maxAngleRoll = 20;
|
||||
@@ -83,14 +83,14 @@ public class WallRun : NetworkBehaviour
|
||||
{
|
||||
Vector3 dir = transform.TransformDirection(directions[i]);
|
||||
Physics.Raycast(transform.position, dir, out hits[i], wallMaxDistance);
|
||||
// if(hits[i].collider != null)
|
||||
// {
|
||||
// Debug.DrawRay(transform.position, dir * hits[i].distance, Color.green);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Debug.DrawRay(transform.position, dir * wallMaxDistance, Color.red);
|
||||
// }
|
||||
if(hits[i].collider != null)
|
||||
{
|
||||
Debug.DrawRay(transform.position, dir * hits[i].distance, Color.green);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.DrawRay(transform.position, dir * wallMaxDistance, Color.red);
|
||||
}
|
||||
}
|
||||
|
||||
if(CanWallRun())
|
||||
@@ -151,13 +151,35 @@ public class WallRun : NetworkBehaviour
|
||||
Vector3 moveToSet = alongWall * vertical * playerMovementController.PlayerSpeed() * Time.deltaTime;// * wallSpeedMultiplier;
|
||||
Vector3 velNorm = playerMovementController.vel;
|
||||
velNorm.Normalize();
|
||||
|
||||
moveToSet = new Vector3(moveToSet.x * -velNorm.x, moveToSet.y, moveToSet.z * -velNorm.z);
|
||||
|
||||
Vector3 moveToSetNorm = moveToSet;
|
||||
moveToSetNorm.Normalize();
|
||||
|
||||
if((moveToSetNorm.x < 0 && velNorm.x > 0)){
|
||||
moveToSet.x = (moveToSet.x * -velNorm.x);
|
||||
}
|
||||
else if((moveToSetNorm.x > 0 && velNorm.x < 0) ){
|
||||
moveToSet.x = (-moveToSet.x * -velNorm.x);
|
||||
}
|
||||
|
||||
if((moveToSetNorm.z < 0 && velNorm.z > 0)){
|
||||
moveToSet.z = (moveToSet.z * -velNorm.z);
|
||||
}
|
||||
else if((moveToSetNorm.z > 0 && velNorm.z < 0)){
|
||||
moveToSet.z = (-moveToSet.z * -velNorm.z);
|
||||
}
|
||||
|
||||
moveToSet.y = 0;
|
||||
|
||||
|
||||
playerMovementController.SetPlayerVelocity(moveToSet);
|
||||
Debug.Log(moveToSet);
|
||||
isWallRunning = true;
|
||||
if(playerMovementController.curJumpNum != 0){
|
||||
playerMovementController.curJumpNum = 0 ;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,10 +197,6 @@ public class WallRun : NetworkBehaviour
|
||||
|
||||
public Vector3 GetWallJumpDirection() //Add call in jump where if we are wallrunning and jump, the jump vector is multiplied by this
|
||||
{
|
||||
if(isWallRunning)
|
||||
{
|
||||
return lastWallNormal * wallBouncing + Vector3.up;
|
||||
}
|
||||
return Vector3.zero;
|
||||
return lastWallNormal * wallBouncing + (transform.up);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ public class PlayerMovement : NetworkBehaviour
|
||||
private CharacterController moveController;
|
||||
|
||||
//Jump value
|
||||
private int curJumpNum;
|
||||
public int curJumpNum;
|
||||
private bool jumpPressed;
|
||||
bool tempSet = false;
|
||||
float tempTraction = 0.0f;
|
||||
@@ -67,7 +67,7 @@ public class PlayerMovement : NetworkBehaviour
|
||||
private Rigidbody rB;
|
||||
private CapsuleCollider capCol;
|
||||
private bool firstHit = false;
|
||||
private bool heldDown = false;
|
||||
//private bool heldDown = false; //Variable for testing ragdoll reenable if needed
|
||||
private bool beginRagTimer = false;
|
||||
private float ragTime;
|
||||
private Vector3 prevRot;
|
||||
@@ -241,7 +241,13 @@ public class PlayerMovement : NetworkBehaviour
|
||||
//If space is pressed apply an upwards force to the player
|
||||
if ((Input.GetAxis("Jump") != 0) && !jumpPressed && curJumpNum + 1 < pStats.JumpNum && !isSliding)
|
||||
{
|
||||
AddImpact(transform.up, pStats.JumpPow);
|
||||
if(wallRun.IsWallRunning()){
|
||||
AddImpact((wallRun.GetWallJumpDirection()), pStats.JumpPow * 1.3f);
|
||||
AddImpact(transform.up, pStats.JumpPow);
|
||||
}
|
||||
else{
|
||||
AddImpact(transform.up, pStats.JumpPow);
|
||||
}
|
||||
curJumpNum++;
|
||||
jumpPressed = true;
|
||||
}
|
||||
@@ -293,13 +299,13 @@ 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"));
|
||||
transform.parent.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
|
||||
|
||||
|
||||
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
camRotation.x -= Input.GetAxis("Mouse Y") * sensitivity * Time.deltaTime;
|
||||
camRotation.x = Mathf.Clamp(camRotation.x, minAngle, maxAngle);
|
||||
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
cam.transform.localEulerAngles = camRotation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +336,7 @@ public class PlayerMovement : NetworkBehaviour
|
||||
tempSet = true;
|
||||
}
|
||||
}
|
||||
else{
|
||||
else if(!jumpPressed && pStats.HasGlider){
|
||||
|
||||
if(tempSet == true){
|
||||
pStats.Traction = tempTraction;
|
||||
@@ -342,9 +348,11 @@ public class PlayerMovement : NetworkBehaviour
|
||||
}
|
||||
|
||||
//Wallrunning
|
||||
if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
|
||||
//If gliding
|
||||
//Go down slowly
|
||||
else if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
|
||||
|
||||
else{
|
||||
vel.y -= pStats.PlayerGrav * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,119 +6,118 @@ using UnityEngine.Assertions;
|
||||
public class PlayerStats : MonoBehaviour
|
||||
{
|
||||
//Maximum possible player speed
|
||||
private float maxVel = 25.0f;
|
||||
[SerializeField] private float maxVel = 25.0f;
|
||||
public float MaxVel{
|
||||
get{ return maxVel; }
|
||||
set{ maxVel = value; }
|
||||
}
|
||||
|
||||
//Minimum possible player speed
|
||||
private float minVel = 2.0f;
|
||||
[SerializeField] private float minVel = 2.0f;
|
||||
public float MinVel{
|
||||
get{ return minVel; }
|
||||
set{ minVel = value; }
|
||||
}
|
||||
|
||||
//Current player speed
|
||||
private float curVel = 0.0f;
|
||||
[SerializeField] private float curVel = 0.0f;
|
||||
public float CurVel{
|
||||
get{ return curVel; }
|
||||
set{ curVel = value; }
|
||||
}
|
||||
|
||||
//Player Acceleration
|
||||
private float acc = 0.1f;
|
||||
[SerializeField] private float acc = 0.1f;
|
||||
public float Acc{
|
||||
get{ return acc; }
|
||||
set{ acc = value; }
|
||||
}
|
||||
|
||||
//Player Jump power
|
||||
private float jumpPow = 300.0f;
|
||||
[SerializeField] private float jumpPow = 300.0f;
|
||||
public float JumpPow{
|
||||
get{ return jumpPow; }
|
||||
set{ jumpPow = value; }
|
||||
}
|
||||
|
||||
//Players Number of Jumps
|
||||
private int jumpNum = 2;
|
||||
[SerializeField] private int jumpNum = 2;
|
||||
public int JumpNum{
|
||||
get{ return jumpNum; }
|
||||
set{ jumpNum = value; }
|
||||
}
|
||||
|
||||
//Player Traction
|
||||
private float traction = 3.0f;
|
||||
[SerializeField] private float traction = 3.0f;
|
||||
public float Traction{
|
||||
get{ return traction; }
|
||||
set{ traction = value; }
|
||||
}
|
||||
|
||||
//Player Kick Power
|
||||
private float kickPow = 100.0f;
|
||||
[SerializeField] private float kickPow = 150.0f;
|
||||
public float KickPow{
|
||||
get{ return kickPow; }
|
||||
set{ kickPow = value; }
|
||||
}
|
||||
|
||||
//Player Recovery Time When Knocked Down
|
||||
private float recovTime = 3.0f;
|
||||
[SerializeField] private float recovTime = 3.0f;
|
||||
public float RecovTime{
|
||||
get{ return recovTime; }
|
||||
set{ recovTime = value; }
|
||||
}
|
||||
|
||||
//MAY BE UNNECCESARY DEPENDING ON HOW GLIDER TURNS OUT
|
||||
//Gravity Affecting the player
|
||||
private float playerGrav = 20.0f;
|
||||
[SerializeField] private float playerGrav = 20.0f;
|
||||
public float PlayerGrav{
|
||||
get{ return playerGrav; }
|
||||
set{ playerGrav = value; }
|
||||
}
|
||||
|
||||
//If The Player Has Blink
|
||||
private bool hasBlink = false;
|
||||
[SerializeField] private bool hasBlink = false;
|
||||
public bool HasBlink{
|
||||
get{ return hasBlink; }
|
||||
set{ hasBlink = value; }
|
||||
}
|
||||
|
||||
//If The Player Has Glider
|
||||
private bool hasGlider = true;
|
||||
[SerializeField] private bool hasGlider = false;
|
||||
public bool HasGlider{
|
||||
get{ return hasGlider; }
|
||||
set{ hasGlider = value; }
|
||||
}
|
||||
|
||||
//If The Player Has Grapple
|
||||
private bool hasGrapple = false;
|
||||
[SerializeField] private bool hasGrapple = false;
|
||||
public bool HasGrapple{
|
||||
get{ return hasGrapple; }
|
||||
set{ hasGrapple = value; }
|
||||
}
|
||||
|
||||
//If The Player Has Wallrun
|
||||
private bool hasWallrun = true;
|
||||
[SerializeField] private bool hasWallrun = false;
|
||||
public bool HasWallrun{
|
||||
get{ return hasWallrun; }
|
||||
set{ hasWallrun = value; }
|
||||
}
|
||||
|
||||
//If The Player Has Nitro
|
||||
private bool hasNitro = false;
|
||||
[SerializeField] private bool hasNitro = false;
|
||||
public bool HasNitro{
|
||||
get{ return hasNitro; }
|
||||
set{ hasNitro = value; }
|
||||
}
|
||||
|
||||
//If The Player Has Dash
|
||||
private bool hasDash;
|
||||
[SerializeField] private bool hasDash = false;
|
||||
public bool HasDash{
|
||||
get{ return hasDash; }
|
||||
set{ hasDash = value; }
|
||||
}
|
||||
|
||||
private int playerPoints = 15;
|
||||
[SerializeField] private int playerPoints = 15;
|
||||
public int PlayerPoints{
|
||||
get{ return playerPoints; }
|
||||
set{ playerPoints = value; }
|
||||
|
||||
Reference in New Issue
Block a user