mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-07-01 00:40:23 -05:00
Added Inventory
Player Inventory takes scriptable objects Items defines a scriptable object that modifies stats
This commit is contained in:
parent
c16f07986d
commit
3569ef0366
|
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,16 +63,14 @@ public class PlayerMovement : MonoBehaviour
|
|||
|
||||
//camera transform
|
||||
cam = Camera.main.transform;
|
||||
Cam = Camera.main;
|
||||
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();
|
||||
|
||||
|
|
@ -90,18 +88,9 @@ public class PlayerMovement : MonoBehaviour
|
|||
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.5f;
|
||||
|
||||
void Update(){
|
||||
if(moveController.isGrounded) curJumpNum = 0;
|
||||
}
|
||||
|
||||
//Reads inputs and moves player
|
||||
|
|
@ -116,17 +105,13 @@ public class PlayerMovement : MonoBehaviour
|
|||
//player vector should be under the circumstances
|
||||
vel = moveX + moveZ;
|
||||
|
||||
//Gravity
|
||||
vel.y -= pStats.PlayerGrav * Time.deltaTime;
|
||||
|
||||
driftVel = Vector3.Lerp(driftVel, vel, 1.8f*Time.deltaTime);
|
||||
if(moveController.isGrounded) curJumpNum = 0;
|
||||
driftVel = Vector3.Lerp(driftVel, vel, pStats.Traction*Time.deltaTime);
|
||||
//Jump Function
|
||||
Jump();
|
||||
|
||||
//Gravity
|
||||
//moveY -= transform.up * pStats.PlayerGrav * Time.deltaTime;
|
||||
|
||||
|
||||
moveController.Move(driftVel);
|
||||
}
|
||||
|
||||
|
|
@ -205,7 +190,8 @@ public class PlayerMovement : MonoBehaviour
|
|||
|
||||
|
||||
|
||||
//Might adjust
|
||||
//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.
|
||||
|
|
@ -248,7 +234,6 @@ public class PlayerMovement : MonoBehaviour
|
|||
Vector3 bump = new Vector3(0, .5f, 0);
|
||||
//if teleporting due to hit to object, bump them a bit outside normal
|
||||
if(hit.point != null) {
|
||||
Debug.Log("warp");
|
||||
transform.position = endPoint + hit.normal * 1.25f;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user