This commit is contained in:
Evan Nydahl
2021-10-18 12:38:59 -05:00
42 changed files with 4837 additions and 310 deletions

View File

@@ -18,8 +18,9 @@ public class Item: ScriptableObject {
public float kickPowM;
public float recovTimeM;
public float playerGravM;
public int costM;
public void Equip(PlayerStats p){
public virtual void Equip(PlayerStats p){
if(maxVelM != 0){
p.MaxVel += maxVelM;
}
@@ -48,4 +49,34 @@ public class Item: ScriptableObject {
p.PlayerGrav += playerGravM;
}
}
public virtual void Unequip(PlayerStats p){
if(maxVelM != 0){
p.MaxVel -= maxVelM;
}
if(minVelM != 0){
p.MinVel -= minVelM;
}
if(curVelM != 0){
p.CurVel -= curVelM;
}
if(accM != 0){
p.Acc -= accM;
}
if(jumpPowM != 0){
p.JumpPow -= jumpPowM;
}
if(jumpNumM != 0){
p.JumpNum -= jumpNumM;
}
if(tractionM != 0){
p.Traction -= tractionM;
}
if(kickPowM != 0){
p.KickPow -= kickPowM;
}
if(playerGravM != 0){
p.PlayerGrav -= playerGravM;
}
}
}

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: Blink
m_EditorClassIdentifier:
id: 9
itemName: Blink
description: Allows Blinking 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: 1
hasGrappleM: 0
hasGliderM: 0
hasNitroM: 0
hasDashM: 0
cooldownM: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f3ec80a746c12614db0a11da845e3815
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
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: Glider
m_EditorClassIdentifier:
id: 7
itemName: Glider
description: Player Will Fall slower
maxVelM: 0
minVelM: 0
curVelM: 0
accM: 0
jumpPowM: 0
jumpNumM: 0
tractionM: 0
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 7
hasWallrunM: 0
hasBlinkM: 0
hasGrappleM: 0
hasGliderM: 1
hasNitroM: 0
hasDashM: 0
cooldownM: 10

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8fe830ac457225a4ab1031a499db94fc
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
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: Grapple
m_EditorClassIdentifier:
id: 8
itemName: Grapple
description: Allows the use of a grapple
maxVelM: 0
minVelM: 0
curVelM: 0
accM: 0
jumpPowM: 0
jumpNumM: 0
tractionM: 0
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 4
hasWallrunM: 0
hasBlinkM: 0
hasGrappleM: 1
hasGliderM: 0
hasNitroM: 0
hasDashM: 0
cooldownM: 0

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: d48485317ff858c4189d9c3a24830f42
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
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: Nitro
m_EditorClassIdentifier:
id: 10
itemName: Nitro
description: Boosts player speed
maxVelM: 0
minVelM: 0
curVelM: 0
accM: 0
jumpPowM: 0
jumpNumM: 0
tractionM: 0
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 6
hasWallrunM: 0
hasBlinkM: 0
hasGrappleM: 0
hasGliderM: 0
hasNitroM: 1
hasDashM: 0
cooldownM: 0

View File

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

View File

@@ -12,8 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: QuickStandup
m_EditorClassIdentifier:
id: 4
itemName: QuickStandup
id: 1
itemName: Quick Standup
description: Player gets up faster
maxVelM: 0
minVelM: 0
@@ -25,3 +25,4 @@ MonoBehaviour:
kickPowM: 0
recovTimeM: 20
playerGravM: 0
costM: 5

View File

@@ -12,8 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: RollerSkates
m_EditorClassIdentifier:
id: 1
itemName: RollerSkates
id: 2
itemName: Roller Skates
description: More Slidey But Faster
maxVelM: 15
minVelM: 0
@@ -25,3 +25,4 @@ MonoBehaviour:
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 6

View File

@@ -12,7 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: Springs
m_EditorClassIdentifier:
id: 2
id: 3
itemName: Springs
description: Jump Higher
maxVelM: 0
@@ -25,3 +25,4 @@ MonoBehaviour:
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 6

View File

@@ -12,9 +12,9 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: StrongerKick
m_EditorClassIdentifier:
id: 0
itemName:
description:
id: 4
itemName: Strong Kick
description: Kick Harder
maxVelM: 0
minVelM: 0
curVelM: 0
@@ -25,3 +25,4 @@ MonoBehaviour:
kickPowM: 30
recovTimeM: 0
playerGravM: 0
costM: 3

View File

@@ -12,8 +12,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d76cac0a7f5ea2a4cadbec8ef3315ec1, type: 3}
m_Name: TripleJump
m_EditorClassIdentifier:
id: 3
itemName: TripleJump
id: 5
itemName: Triple Jump
description: Player gets an extra jump but has less jump height
maxVelM: 0
minVelM: 0
@@ -25,3 +25,4 @@ MonoBehaviour:
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 5

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: Wall Run
m_EditorClassIdentifier:
id: 6
itemName: Wall Run
description: Allows player to run on walls
maxVelM: 0
minVelM: 0
curVelM: 0
accM: 0
jumpPowM: 0
jumpNumM: 0
tractionM: 0
kickPowM: 0
recovTimeM: 0
playerGravM: 0
costM: 4
hasWallrunM: 1
hasBlinkM: 0
hasGrappleM: 0
hasGliderM: 0
hasNitroM: 0
hasDashM: 0
cooldownM: 0

View File

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

View File

@@ -2,6 +2,111 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu]
public class SpecialItem : Item
{
public bool hasWallrunM;
public bool hasBlinkM;
public bool hasGrappleM;
public bool hasGliderM;
public bool hasNitroM;
public bool hasDashM;
public float cooldownM;
public override void Equip(PlayerStats p){
if(maxVelM != 0){
p.MaxVel += maxVelM;
}
if(minVelM != 0){
p.MinVel += minVelM;
}
if(curVelM != 0){
p.CurVel += curVelM;
}
if(accM != 0){
p.Acc += accM;
}
if(jumpPowM != 0){
p.JumpPow += jumpPowM;
}
if(jumpNumM != 0){
p.JumpNum += jumpNumM;
}
if(tractionM != 0){
p.Traction += tractionM;
}
if(kickPowM != 0){
p.KickPow += kickPowM;
}
if(playerGravM != 0){
p.PlayerGrav += playerGravM;
}
if(hasWallrunM != false){
p.HasWallrun = hasWallrunM;
}
if(hasBlinkM != false){
p.HasBlink = hasBlinkM;
}
if(hasGrappleM != false){
p.HasGrapple = hasGrappleM;
}
if(hasGliderM != false){
p.HasGlider = hasGliderM;
}
if(hasNitroM != false){
p.HasNitro = hasNitroM;
}
if(hasDashM != false){
p.HasDash = hasDashM;
}
}
public override void Unequip(PlayerStats p){
if(maxVelM != 0){
p.MaxVel -= maxVelM;
}
if(minVelM != 0){
p.MinVel -= minVelM;
}
if(curVelM != 0){
p.CurVel -= curVelM;
}
if(accM != 0){
p.Acc -= accM;
}
if(jumpPowM != 0){
p.JumpPow -= jumpPowM;
}
if(jumpNumM != 0){
p.JumpNum -= jumpNumM;
}
if(tractionM != 0){
p.Traction -= tractionM;
}
if(kickPowM != 0){
p.KickPow -= kickPowM;
}
if(playerGravM != 0){
p.PlayerGrav -= playerGravM;
}
if(hasWallrunM != true){
p.HasWallrun = hasWallrunM;
}
if(hasBlinkM != true){
p.HasBlink = hasBlinkM;
}
if(hasGrappleM != true){
p.HasGrapple = hasGrappleM;
}
if(hasGliderM != true){
p.HasGlider = hasGliderM;
}
if(hasNitroM != true){
p.HasNitro = hasNitroM;
}
if(hasDashM != true){
p.HasDash = hasDashM;
}
}
}

View File

@@ -4,45 +4,50 @@ using UnityEngine;
public class PlayerInventory : MonoBehaviour
{
//List of items
[SerializeField] List<Item> items;
//Scripts
public PlayerStats pStats;
public InventoryManager invMan;
public bool AddItem(Item item){
items.Add(item);
return true;
void Awake(){
pStats = GetComponent<PlayerStats>();
DontDestroyOnLoad(this.gameObject);
}
public bool AddSpecialItem<T>(T itemCandidate) { // Unless we don't want the four special items to be handled by inventory/inventory manager?
public void AddItem(Item item, bool ableToAdd){
if(!items.Contains(item) && ableToAdd){
Debug.Log("Item Added");
items.Add(item);
item.Equip(pStats);
}
else if(!ableToAdd && !items.Contains(item)){
Debug.Log("Item Cannot Be Added");
}
else{
Debug.Log("Item Removed");
RemoveItem(item);
}
}
public void AddSpecialItem<T>(T itemCandidate) { // Unless we don't want the four special items to be handled by inventory/inventory manager?
if (itemCandidate is Item) {
items.Add(itemCandidate as Item);
}
return true;
}
public bool RemoveItem(Item item){
public void RemoveItem(Item item){
if(items.Remove(item)){
return true;
item.Unequip(pStats);
}
return false;
}
void Awake(){
pStats = GetComponent<PlayerStats>();
invMan = GetComponent<InventoryManager>();//////UPDATE WHEN THIS IS NO LONGER ATTACHED TO THE PLAYER
}
void Start(){
AddItem(invMan.ItemList[0]);
AddItem(invMan.ItemList[1]);
foreach (Item item in items){
Debug.Log(item.name);
item.Equip(pStats);
}
public List<Item> GetItems(){
return items;
}

View File

@@ -12,9 +12,10 @@ public class PlayerMovement : MonoBehaviour
//Variable Section
/////
//Speed Variables
public Vector3 vel;
private Vector3 moveZ;
private Vector3 moveX;
private Vector3 vel;
private Vector3 driftVel;
//Character Moving
@@ -66,7 +67,6 @@ public class PlayerMovement : MonoBehaviour
//Initialize Components
moveController = GetComponent<CharacterController>();
pStats = GetComponent<PlayerStats>();
Cursor.lockState = CursorLockMode.Locked;
ignoreP = LayerMask.GetMask("Player");
@@ -76,37 +76,48 @@ public class PlayerMovement : MonoBehaviour
beam.enabled = false;
//camera transform
cam = Camera.main;
cam = GetComponentInChildren<Camera>();
//Wallrun
wallRun = gameObject.GetComponent<WallRun>();
//wallRun = gameObject.GetComponent<WallRun>();
}
void Start(){
Cursor.lockState = CursorLockMode.Locked;
distToGround = GetComponent<Collider>().bounds.extents.y;
}
// Update is called once per frame
void FixedUpdate(){
//input controls for movement
InputController();
//Controls for camera
Rotate();
if(moveController.enabled == true){
//input controls for movement
InputController();
//if suffiecient impact magnitude is applied then move player
if (impact.magnitude > 0.2F) moveController.Move(impact * Time.deltaTime);
//if suffiecient impact magnitude is applied then move player
if (impact.magnitude > 0.2F) moveController.Move(impact * Time.deltaTime);
// consumes the impact energy each cycle:
impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime);
// consumes the impact energy each cycle:
impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime);
Blink();
}
else{
Debug.Log("MoveController is either Disabled or wasn't retrieved correctly");
}
//Checks if player should respawn
Respawn();
Blink();
}
@@ -187,15 +198,15 @@ public class PlayerMovement : MonoBehaviour
//NEEDS TO BE MASSIVELY CHANGE LIKELY USE RAYCAST TO CHECK IF ACTUALLY ON GROUND
//CANNOT USE CHARACTERCONTROLLER.ISGROUNDED IT IS UNRELIABLE
//If grounded no jumps have been used
// if(IsGrounded()){
// curJumpNum = 0;
// }
if(IsGrounded()){
curJumpNum = 0;
}
//If space isn't being pressed then jump is false
if(Input.GetAxis("Jump")==0) jumpPressed = false;
}
public bool GetJumpPressed() {
public bool GetJumpPressed(){
return jumpPressed;
}
@@ -235,8 +246,32 @@ public class PlayerMovement : MonoBehaviour
//Gravity Function for adjusting y-vel due to wallrun/glide/etc
private void Gravity(){
//Normal Gravity
vel.y -= pStats.PlayerGrav * Time.deltaTime;
//Temp Values for Glider
float tempTraction = 0.0f;
bool tempSet = false;
//ADD CHECKER FOR GLIDER WHEN FULLY IMPLEMENTED
if(jumpPressed && pStats.HasGlider){
vel.y -= (pStats.PlayerGrav-18) * Time.deltaTime;
if(tempSet == false){
tempTraction = pStats.Traction;
pStats.Traction = 1.0f;
tempSet = true;
}
}
else{
if(tempSet == true){
pStats.Traction = tempTraction;
tempSet = false;
}
//Normal Gravity
vel.y -= pStats.PlayerGrav * Time.deltaTime;
}
//Wallrunning
if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
//If gliding
@@ -247,7 +282,6 @@ public class PlayerMovement : MonoBehaviour
{
// Make sure that the ground check distance while already in air is very small, to prevent suddenly snapping to ground
float chosenGroundCheckDistance = isGrounded ? (moveController.skinWidth + groundCheckDistance) : groundCheckDistanceInAir;
// reset values before the ground check
isGrounded = false;
Vector3 groundNormal = Vector3.up;
@@ -255,16 +289,19 @@ public class PlayerMovement : MonoBehaviour
// only try to detect ground if it's been a short amount of time since last jump; otherwise we may snap to the ground instantly after we try jumping
if (Time.time >= lastTimeJumped + jumpGroundingPreventionTime)
{
Debug.Log("detect ground");
// if we're grounded, collect info about the ground normal with a downward capsule cast representing our character capsule
if (Physics.CapsuleCast(GetCapsuleBottomHemisphere(), GetCapsuleTopHemisphere(moveController.height), moveController.radius, Vector3.down, out RaycastHit hit, chosenGroundCheckDistance, groundCheckLayers, QueryTriggerInteraction.Ignore))
{
Debug.Log("Collect info");
// storing the upward direction for the surface found
groundNormal = hit.normal;
// Only consider this a valid ground hit if the ground normal goes in the same direction as the character up
// and if the slope angle is lower than the character controller's limit
if (Vector3.Dot(hit.normal, transform.up) > 0f && IsNormalUnderSlopeLimit(groundNormal))
if (Vector3.Dot(hit.normal, transform.up) > 0.0f && IsNormalUnderSlopeLimit(groundNormal))
{
Debug.Log("isGrounded");
isGrounded = true;
// handle snapping to the ground
@@ -277,6 +314,11 @@ public class PlayerMovement : MonoBehaviour
}
}
//Improved IsGrounded
private bool IsGrounded(){
return Physics.Raycast(transform.position, -Vector3.up, distToGround + 0.1f, ~ignoreP);
}
private bool IsNormalUnderSlopeLimit(Vector3 normal){ // Returns true if the slope angle represented by the given normal is under the slope angle limit of the character controller
return Vector3.Angle(transform.up, normal) <= moveController.slopeLimit;
}

View File

@@ -5,6 +5,7 @@ using UnityEngine;
public class PlayerStats : MonoBehaviour
{
//Maximum possible player speed
[SerializeField]
private float maxVel = 25.0f;
public float MaxVel{
get{ return maxVel; }
@@ -12,6 +13,7 @@ public class PlayerStats : MonoBehaviour
}
//Minimum possible player speed
[SerializeField]
private float minVel = 2.0f;
public float MinVel{
get{ return minVel; }
@@ -19,6 +21,7 @@ public class PlayerStats : MonoBehaviour
}
//Current player speed
[SerializeField]
private float curVel = 0.0f;
public float CurVel{
get{ return curVel; }
@@ -26,6 +29,7 @@ public class PlayerStats : MonoBehaviour
}
//Player Jump power
[SerializeField]
private float acc = 0.1f;
public float Acc{
get{ return acc; }
@@ -33,6 +37,7 @@ public class PlayerStats : MonoBehaviour
}
//Player Jump power
[SerializeField]
private float jumpPow = 300.0f;
public float JumpPow{
get{ return jumpPow; }
@@ -40,6 +45,7 @@ public class PlayerStats : MonoBehaviour
}
//Players Number of Jumps
[SerializeField]
private int jumpNum = 2; ////// UPDATE TO 2 WHEN THE JUMP ISSUE IS FIXED
public int JumpNum{
get{ return jumpNum; }
@@ -47,6 +53,7 @@ public class PlayerStats : MonoBehaviour
}
//Player Traction
[SerializeField]
private float traction = 3.0f;
public float Traction{
get{ return traction; }
@@ -54,13 +61,15 @@ public class PlayerStats : MonoBehaviour
}
//Player Kick Power
[SerializeField]
private float kickPow;
public float KickPow{
get{ return kickPow; }
set{ kickPow = value; }
}
//Player Recovery Time When Knocked Down
//Player Recovery Time When Knocked Down
[SerializeField]
private float recovTime;
public float RecovTime{
get{ return recovTime; }
@@ -69,6 +78,7 @@ public class PlayerStats : MonoBehaviour
//MAY BE UNNECCESARY DEPENDING ON HOW GLIDER TURNS OUT
//Gravity Affecting the player
[SerializeField]
private float playerGrav = 20.0f;
public float PlayerGrav{
get{ return playerGrav; }
@@ -76,6 +86,7 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Blink
[SerializeField]
private bool hasBlink = false;
public bool HasBlink{
get{ return hasBlink; }
@@ -83,6 +94,7 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Glider
[SerializeField]
private bool hasGlider = false;
public bool HasGlider{
get{ return hasGlider; }
@@ -90,6 +102,7 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Grapple
[SerializeField]
private bool hasGrapple = false;
public bool HasGrapple{
get{ return hasGrapple; }
@@ -97,9 +110,33 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Wallrun
[SerializeField]
private bool hasWallrun = false;
public bool HasWallrun{
get{ return hasWallrun; }
set{ hasWallrun = value; }
}
//If The Player Has Nitro
[SerializeField]
private bool hasNitro = false;
public bool HasNitro{
get{ return hasNitro; }
set{ hasNitro = value; }
}
//If The Player Has Dash
[SerializeField]
private bool hasDash = false;
public bool HasDash{
get{ return hasDash; }
set{ hasDash = value; }
}
[SerializeField]
private int playerPoints = 15;
public int PlayerPoints{
get{ return playerPoints; }
set{ playerPoints = value; }
}
}