Merge branch 'main' into UI-Prototypes

This commit is contained in:
Vincent Wheat 2021-10-08 13:55:29 -05:00
commit 349d99b238
6 changed files with 126 additions and 1399 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 4282c79fedd3def4fa3c93c0a77f914f
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -4,15 +4,4 @@ using UnityEngine;
public class Player : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -4,15 +4,27 @@ using UnityEngine;
public class PlayerInventory : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
[SerializeField] List<Item> items;
public PlayerStats pStats;
public bool AddItem(Item item){
items.Add(item);
return true;
}
// Update is called once per frame
void Update()
{
public bool RemoveItem(Item item){
if(items.Remove(item)){
return true;
}
return false;
}
void Awake(){
pStats = GetComponent<PlayerStats>();
foreach (Item item in items){
item.Equip(pStats);
}
}
}

View File

@ -12,7 +12,11 @@ public class PlayerMovement : MonoBehaviour
//Variable Section
/////
//Speed Variables
private Vector3 moveZ;
private Vector3 moveX;
private Vector3 vel;
private Vector3 driftVel;
//Character Moving
private CharacterController moveController;
@ -46,6 +50,14 @@ public class PlayerMovement : MonoBehaviour
public int maxAngle = 45;
[Range(50, 500)]
public int sensitivity = 200;
//Blink Variables
private LineRenderer beam;
private Vector3 origin;
private Vector3 endPoint;
private Vector3 mousePos;
private RaycastHit hit;
private Camera Cam;
/////
void Awake(){
@ -53,23 +65,28 @@ public class PlayerMovement : MonoBehaviour
moveController = GetComponent<CharacterController>();
pStats = GetComponent<PlayerStats>();
Cursor.lockState = CursorLockMode.Locked;
beam = gameObject.AddComponent<LineRenderer>();
beam.startWidth = 0.2f;
beam.endWidth = 0.2f;
//camera transform
cam = Camera.main.transform;
Cam = Camera.main; //RENAME WHEN CLEANING UP BLINK
}
void Start(){
InitializeStats();
}
// Update is called once per frame
void FixedUpdate()
{
void FixedUpdate(){
//input controls for movement
InputController();
//Controls for camera
Rotate();
//if suffiecient impact magnitude is applied then move player
if (impact.magnitude > 0.2F) moveController.Move(impact * Time.deltaTime);
@ -78,20 +95,11 @@ public class PlayerMovement : MonoBehaviour
//Checks if player should respawn
Respawn();
Blink();
}
//REMOVE OR ADJUST ONCE INVENTORY IS IMPLEMENTED
//Initializes variables for player when inventory is implemented it would be set there
private void InitializeStats(){
pStats.MaxVel = 30.0f;
pStats.MinVel = 2.0f;
pStats.CurVel = 0.0f;
pStats.Acc = 0.06f;
pStats.JumpPow = 100.0f;
pStats.JumpNum = 50;///SET IT LIKE THIS BC OF THE ISSUE WITH ISGROUNDED
pStats.Traction = 3.0f;
pStats.PlayerGrav= 7.0f;
void Update(){
if(moveController.isGrounded) curJumpNum = 0;
}
//Reads inputs and moves player
@ -99,21 +107,24 @@ public class PlayerMovement : MonoBehaviour
//Keyboard inputs
//Checks if movement keys have been pressed and calculates correct vector
Vector3 moveX = transform.right * Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed();
Vector3 moveZ = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed();
moveX = transform.right * Input.GetAxis("Horizontal") * Time.deltaTime * PlayerSpeed();
moveZ = transform.forward * Input.GetAxis("Vertical") * Time.deltaTime * PlayerSpeed();
//Adds vectors based on movement keys and other conditions to check what the
//player vector should be under the circumstances
vel = moveX + moveZ;
if(moveController.isGrounded) curJumpNum = 0;
//Gravity
vel.y -= pStats.PlayerGrav * Time.deltaTime;
driftVel = Vector3.Lerp(driftVel, vel, pStats.Traction*Time.deltaTime);
//Jump Function
Jump();
//Gravity
vel.y -= Gravity();
moveController.Move(vel);
moveController.Move(driftVel);
}
@ -166,6 +177,8 @@ public class PlayerMovement : MonoBehaviour
if(Input.GetAxis("Jump")==0) jumpPressed = false;
}
//Camera
private void Rotate()
{
@ -177,6 +190,8 @@ public class PlayerMovement : MonoBehaviour
cam.localEulerAngles = camRotation;
}
//REMOVE WHEN UNNECCESARY
//Respawns player if they fall below a certain point
private void Respawn(){
@ -211,4 +226,63 @@ public class PlayerMovement : MonoBehaviour
//Else normal gravity
return pStats.PlayerGrav * Time.deltaTime;
}
//ADJUST SO DISTANCE IS DETERMINED BY SCROLL WHEEL
//blinks the player forwards
private void Blink(){
if (Input.GetMouseButton(1)){
// Finding the origin and end point of laser.
origin = transform.position + transform.forward * transform.lossyScale.z;
// Finding mouse pos in 3D space.
mousePos = Input.mousePosition;
mousePos.z = 20f;
endPoint = Cam.ScreenToWorldPoint(mousePos);
// Find direction of beam.
Vector3 dir = endPoint - origin;
dir.Normalize();
// Are we hitting any colliders?
if (Physics.Raycast(origin, dir, out hit, 20f)){
// If yes, then set endpoint to hit-point.
endPoint = hit.point;
}
// Set end point of laser.
beam.SetPosition(0, origin);
beam.SetPosition(1, endPoint);
// Draw the laser!
beam.enabled = true;
/*Ray ray = camera.ScreenPointToRay(Input.mousePosition);
RaycastHit raycastHit;
if (Physics.Raycast(ray, out raycastHit, 5.0f)){
LineRenderer.SetPosition(1, raycastHit.point);
}*/
}
else if(!Input.GetMouseButton(1) && beam.enabled == true){
beam.enabled = false;
//disable character controller for a brief second for teleportation
//gameObject.GetComponent<CharacterController>().enabled = false;
//get
Vector3 bump = new Vector3(0, .5f, 0);
//if teleporting due to hit to object, bump them a bit outside normal
if(hit.point != null) {
transform.position = endPoint + hit.normal * 1.25f;
}
//if teleporting in the air or something, just spawn at endpoint
else{
transform.position = endPoint;
}
//reenable character controller
}
}
}

View File

@ -5,49 +5,49 @@ using UnityEngine;
public class PlayerStats : MonoBehaviour
{
//Maximum possible player speed
private float maxVel;
private float maxVel = 30.0f;
public float MaxVel{
get{ return maxVel; }
set{ maxVel = value; }
}
//Minimum possible player speed
private float minVel;
private float minVel = 2.0f;
public float MinVel{
get{ return minVel; }
set{ minVel = value; }
}
//Current player speed
private float curVel;
private float curVel = 0.0f;
public float CurVel{
get{ return curVel; }
set{ curVel = value; }
}
//Player Jump power
private float acc;
private float acc = 0.06f;
public float Acc{
get{ return acc; }
set{ acc = value; }
}
//Player Jump power
private float jumpPow;
private float jumpPow = 300.0f;
public float JumpPow{
get{ return jumpPow; }
set{ jumpPow = value; }
}
//Players Number of Jumps
private int jumpNum;
private int jumpNum = 60; ////// UPDATE TO 2 WHEN THE JUMP ISSUE IS FIXED
public int JumpNum{
get{ return jumpNum; }
set{ jumpNum = value; }
}
//Player Traction
private float traction;
private float traction = 3.0f;
public float Traction{
get{ return traction; }
set{ traction = value; }
@ -69,35 +69,35 @@ public class PlayerStats : MonoBehaviour
//MAY BE UNNECCESARY DEPENDING ON HOW GLIDER TURNS OUT
//Gravity Affecting the player
private float playerGrav;
private float playerGrav = 20.0f;
public float PlayerGrav{
get{ return playerGrav; }
set{ playerGrav = value; }
}
//If The Player Has Blink
private bool hasBlink;
private bool hasBlink = false;
public bool HasBlink{
get{ return hasBlink; }
set{ hasBlink = value; }
}
//If The Player Has Glider
private bool hasGlider;
private bool hasGlider = false;
public bool HasGlider{
get{ return hasGlider; }
set{ hasGlider = value; }
}
//If The Player Has Grapple
private bool hasGrapple;
private bool hasGrapple = false;
public bool HasGrapple{
get{ return hasGrapple; }
set{ hasGrapple = value; }
}
//If The Player Has Wallrun
private bool hasWallrun;
private bool hasWallrun = false;
public bool HasWallrun{
get{ return hasWallrun; }
set{ hasWallrun = value; }