small changes to player and items for cleanup

This commit is contained in:
Melbyj1125
2021-11-17 12:21:15 -06:00
parent 2fe2fa5764
commit e2a1a9150c
20 changed files with 135 additions and 46 deletions

View File

@@ -9,7 +9,7 @@ public class dBlink : NetworkBehaviour{
// Start is called before the first frame update
private Camera cam;
public Camera cam;
public CharacterController controller;
//Blink Variables
private LineRenderer beam;
@@ -36,12 +36,11 @@ public class dBlink : NetworkBehaviour{
// Grab the main camera.
//camera transform
cam = GetComponentInChildren<Camera>();
}
//ADJUST SO DISTANCE IS DETERMINED BY SCROLL WHEEL
//blinks the player forwards
private void BlinkMove()
public void BlinkMove()
{
//if (!IsLocalPlayer) { return; }

View File

@@ -22,21 +22,22 @@ public class dDash : NetworkBehaviour{
//UPDATE CHECK FOR MOVEMENT ONLY WHEN DASHING
void FixedUpdate(){
//if (!IsLocalPlayer) { return; }
if (Input.GetKeyDown(KeyCode.E))
{
currentDashTime = 0;
if(characterController.enabled == true){
if (Input.GetKeyDown(KeyCode.E))
{
currentDashTime = 0;
}
if(currentDashTime < maxDashTime)
{
moveDirection = transform.forward * dashDistance;
currentDashTime += dashStoppingSpeed;
}
else
{
moveDirection = Vector3.zero;
}
characterController.Move(moveDirection * Time.deltaTime * dashSpeed);
}
if(currentDashTime < maxDashTime)
{
moveDirection = transform.forward * dashDistance;
currentDashTime += dashStoppingSpeed;
}
else
{
moveDirection = Vector3.zero;
}
characterController.Move(moveDirection * Time.deltaTime * dashSpeed);
}
}

View File

@@ -41,7 +41,6 @@ public class dWallRun : NetworkBehaviour
bool CanWallRun()
{
float verticalAxis = Input.GetAxisRaw("Vertical");
return !isPlayergrounded() && verticalAxis > 0 && VerticalCheck();
}
@@ -155,6 +154,7 @@ public class dWallRun : NetworkBehaviour
playerMovementController.SetPlayerVelocity(moveToSet);
//Debug.Log("On Wall");
isWallRunning = true;
Debug.Log("Is Wallrunning");
}
}

View File

@@ -78,7 +78,8 @@ public class dPlayerMovement : NetworkBehaviour
private Vector3 up;
private bool qDown;
//Kick Variables
//Blink
private dBlink blink;
void Awake()
{
@@ -93,6 +94,8 @@ public class dPlayerMovement : NetworkBehaviour
//Wallrun
wallRun = gameObject.GetComponent<dWallRun>();
blink = gameObject.GetComponent<dBlink>();
up = this.gameObject.GetComponentInParent<Transform>().up;
}
@@ -155,12 +158,16 @@ public class dPlayerMovement : NetworkBehaviour
//TEMP FOR TESTING RAGDOLL
//Right Click to ragdoll the player
if (Input.GetMouseButton(1) && heldDown == false){
getHit(new Vector3(vel.x, 0, vel.z), 30);
heldDown = true;
}
if(!Input.GetMouseButton(1)){
heldDown = false;
// if (Input.GetMouseButton(1) && heldDown == false){
// getHit(new Vector3(vel.x, 0, vel.z), 30);
// heldDown = true;
// }
// if(!Input.GetMouseButton(1)){
// heldDown = false;
// }
if(pStats.HasBlink == true){
blink.BlinkMove();
}
//TEMP FOR TESTING

View File

@@ -4,7 +4,10 @@ using UnityEngine;
public class InventoryManager : MonoBehaviour
{
//allItems array
public Item[] allItems;
//Item list
private List<Item> itemList;
public List<Item> ItemList{
get{ return itemList; }
@@ -13,8 +16,8 @@ public class InventoryManager : MonoBehaviour
void Awake(){
//Gets Items in Resource Folder
allItems = Resources.LoadAll<Item>("ItemObjects");
itemList = new List<Item>(allItems);
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 08ce0ad440e9031429d13663cf77c6f0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,35 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 220c578e08133f54a95a442eb87b3702, type: 3}
m_Name: Dash
m_EditorClassIdentifier:
id: 11
itemName: Dash
description: Quickly Moves the player forwards
maxVelM: 0
minVelM: 0
curVelM: 0
accM: 0
jumpPowM: 0
jumpNumM: 0
tractionM: 0
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 5
hasWallrunM: 0
hasBlinkM: 0
hasGrappleM: 0
hasGliderM: 0
hasNitroM: 0
hasDashM: 1
cooldownM: 15

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 4399d7276b3edf446ac51c5145539a5e
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -17,28 +17,35 @@ public class PlayerInventory : MonoBehaviour
}
//Add item to player Inventory
public void AddItem(Item item, bool ableToAdd){
if(!items.Contains(item) && ableToAdd){
Debug.Log("Item Added");
//Add item to player inventroy list
items.Add(item);
//Equip item
item.Equip(pStats, this.gameObject);
}
else if(!ableToAdd && !items.Contains(item)){
//Item cannot be added
Debug.Log("Item Cannot Be Added");
}
else{
//If player already has the item it removes it
Debug.Log("Item Removed");
RemoveItem(item);
}
}
//Remove Item player inv
public void RemoveItem(Item item){
if(items.Remove(item)){
item.Unequip(pStats, this.gameObject);
}
}
//GetItems
public List<Item> GetItems(){
return items;
}

View File

@@ -101,7 +101,7 @@ public class PlayerMovement : NetworkBehaviour
// Don't do movement unless this is the local player controlling it
// Otherwise we let the server handle moving us
//if (!IsLocalPlayer) { return; }
if (!IsLocalPlayer) { return; }
// Don't lock the cursor multiple times if this isn't the local player
// Also don't want to lock the cursor for the king
@@ -151,20 +151,6 @@ public class PlayerMovement : NetworkBehaviour
//Debug.LogWarning("MoveController is either Disabled or wasn't retrieved correctly");
}
//TESTING RAGDOLL STUFF NEEDS SOME WORK
//Checks if player should respawn
//Respawn();
//if (Input.GetMouseButton(1) && heldDown == false){
// getHit(new Vector3(vel.x, 0, vel.z), 30);
// heldDown = true;
//}
if(!Input.GetMouseButton(1)){
heldDown = false;
}
//TEMP FOR TESTING
//Checks if player should respawn
Respawn();
@@ -189,6 +175,7 @@ public class PlayerMovement : NetworkBehaviour
//Gravity
Gravity();
//Adds persisting momentum to player
driftVel = Vector3.Lerp(driftVel, vel, pStats.Traction * Time.deltaTime);
//Moving outside basic wasd

View File

@@ -133,9 +133,9 @@ public class PlayerStats : MonoBehaviour
Debug.Assert((minVel >= 0), "minVel cannot be below zero");
Debug.Assert((curVel >= 0), "curVel cannot be below zero");
Debug.Assert((jumpPow >= 0), "jumpPow cannot be below zero");
Debug.Assert((jumpNum >= 2), "jumpNum cannot be below zero");
Debug.Assert((jumpNum >= 2), "jumpNum cannot be below 2");
Debug.Assert((traction >= 0), "traction cannot be below zero");
//Debug.Assert((kickPow >= 0), "Playerpoints cannot be below zero");
Debug.Assert((kickPow >= 0), "Playerpoints cannot be below zero");
Debug.Assert((recovTime >= 0), "recovTime cannot be below zero");
Debug.Assert((playerGrav >= 0), "playerGrav cannot be below zero");
Debug.Assert((playerPoints >= 0), "Playerpoints cannot be below zero");