Implemented Item Scripts into objects

Implemented Ragdoll kinda
There are some issues with getting hit while ragdolling that need to be
fixed
Adjusted Dash
Dash still needs some adjustments before being fully implemented
This commit is contained in:
Melbyj1125 2021-10-25 03:38:56 -05:00
parent cc99ababff
commit 702bb555f0
33 changed files with 290 additions and 319 deletions

View File

@ -17,7 +17,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &5926263001551059217
RectTransform:
m_ObjectHideFlags: 0
@ -75,6 +75,85 @@ MonoBehaviour:
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &2772603729019833927
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4929802560832325088}
- component: {fileID: 2852435069663319190}
- component: {fileID: 6139331568733360395}
m_Layer: 5
m_Name: Cost
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4929802560832325088
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2772603729019833927}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 8447329698821624897}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -14.9}
m_SizeDelta: {x: 10, y: 20}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2852435069663319190
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2772603729019833927}
m_CullTransparentMesh: 1
--- !u!114 &6139331568733360395
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2772603729019833927}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 1
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0
--- !u!1 &8447329698570405367
GameObject:
m_ObjectHideFlags: 0
@ -87,7 +166,7 @@ GameObject:
- component: {fileID: 8447329698570405360}
- component: {fileID: 8447329698570405361}
m_Layer: 5
m_Name: Text
m_Name: Name
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -109,7 +188,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 11.7}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &8447329698570405360
@ -186,6 +265,7 @@ RectTransform:
m_Children:
- {fileID: 5926263001551059217}
- {fileID: 8447329698570405366}
- {fileID: 4929802560832325088}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

View File

@ -378,7 +378,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 7188906082087890184, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}
propertyPath: m_IsActive
value: 0
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a9840baa4cc526b44bfef27c6fea042a, type: 3}

View File

@ -1,48 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dash : MonoBehaviour{
public float dashTime = 0.5f;
private float _currentDashTime = 0f;
private bool _isDashing = false;
private Vector3 _dashStart, _dashEnd;
private float m_DashDist = 1.0f;
private CharacterController characterController;
void Start(){
characterController = this.gameObject.GetComponent<CharacterController>();
}
void FixedUpdate(){
Vector3 tdashStart = this.gameObject.transform.position;
Vector3 tdashEnd = tdashStart + (this.gameObject.transform.forward * m_DashDist);
Debug.DrawLine(tdashStart, tdashEnd);
if (Input.GetKeyDown(KeyCode.E)){
if (_isDashing == false) {
// dash start
_isDashing = true;
_currentDashTime = 0;
_dashStart = this.gameObject.transform.position;
_dashEnd = _dashStart + (this.gameObject.transform.forward * m_DashDist);
}
}
if (_isDashing){
// incrementing time
_currentDashTime += Time.deltaTime;
// a value between 0 and 1
float perc = Mathf.Clamp01(_currentDashTime / dashTime);
// updating position
characterController.Move(Vector3.Lerp(_dashStart, _dashEnd, perc));
if (_currentDashTime >= dashTime){
// dash finished
_isDashing = false;
this.gameObject.transform.position = _dashEnd;
}
}
}
}

View File

@ -1,69 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour
{
private CharacterController cc;
public float speed = 5;
public float gravity = -5;
float velocityY = 0;
// Start is called before the first frame update
void Start()
{
cc = GetComponent<CharacterController>();
}
// Update is called once per frame
void FixedUpdate()
{
velocityY += gravity * Time.deltaTime;
Vector3 temp = Vector3.zero;
if (Input.GetKey(KeyCode.A))
{
temp += transform.right * -1;
}
if (Input.GetKey(KeyCode.S))
{
temp += transform.forward * -1;
}
if (Input.GetKey(KeyCode.D))
{
temp += transform.right;
}
if (Input.GetKey(KeyCode.W))
{
temp += transform.forward;
}
Vector3 vel = temp * speed;
vel.y = velocityY;
cc.Move(vel * Time.deltaTime);
if (cc.isGrounded)
{
velocityY = 0;
if (Input.GetKey(KeyCode.Space))
{
velocityY = 3;
}
}
if (cc.transform.position.y < -2)
{
cc.transform.position = new Vector3(0, (float)1.25, 0);
}
}
private void OnControllerColliderHit(ControllerColliderHit hit)
{
if (hit.gameObject.CompareTag("WallRun"))
{
velocityY = 0;
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 13c04f815bd0149499ce2ee3eb3a39b7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -20,7 +20,7 @@ public class Item: ScriptableObject {
public float playerGravM;
public int costM;
public virtual void Equip(PlayerStats p){
public virtual void Equip(PlayerStats p, GameObject player){
if(maxVelM != 0){
p.MaxVel += maxVelM;
}
@ -50,7 +50,7 @@ public class Item: ScriptableObject {
}
}
public virtual void Unequip(PlayerStats p){
public virtual void Unequip(PlayerStats p, GameObject player){
if(maxVelM != 0){
p.MaxVel -= maxVelM;
}

View File

@ -33,3 +33,4 @@ MonoBehaviour:
hasNitroM: 0
hasDashM: 0
cooldownM: 0
scriptM: {fileID: 11500000, guid: 5162a84172831f4449df60b9ad0ce22f, type: 3}

View File

@ -33,3 +33,4 @@ MonoBehaviour:
hasNitroM: 0
hasDashM: 0
cooldownM: 0
scriptM: {fileID: 11500000, guid: 535009eaa735a4c4e95c6fc270e32741, type: 3}

View File

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CreateAssetMenu]
public class SpecialItem : Item
@ -12,8 +13,9 @@ public class SpecialItem : Item
public bool hasNitroM;
public bool hasDashM;
public float cooldownM;
public MonoScript scriptM;
public override void Equip(PlayerStats p){
public override void Equip(PlayerStats p, GameObject player){
if(maxVelM != 0){
p.MaxVel += maxVelM;
}
@ -59,9 +61,12 @@ public class SpecialItem : Item
if(hasDashM != false){
p.HasDash = hasDashM;
}
if(scriptM != null){
player.AddComponent(scriptM.GetClass());
}
}
public override void Unequip(PlayerStats p){
public override void Unequip(PlayerStats p, GameObject player){
if(maxVelM != 0){
p.MaxVel -= maxVelM;
}
@ -89,23 +94,26 @@ public class SpecialItem : Item
if(playerGravM != 0){
p.PlayerGrav -= playerGravM;
}
if(hasWallrunM != true){
p.HasWallrun = hasWallrunM;
if(hasWallrunM != false){
p.HasWallrun = false;
}
if(hasBlinkM != true){
p.HasBlink = hasBlinkM;
if(hasBlinkM != false){
p.HasBlink = false;
}
if(hasGrappleM != true){
p.HasGrapple = hasGrappleM;
if(hasGrappleM != false){
p.HasGrapple = false;
}
if(hasGliderM != true){
p.HasGlider = hasGliderM;
if(hasGliderM != false){
p.HasGlider = false;
}
if(hasNitroM != true){
p.HasNitro = hasNitroM;
if(hasNitroM != false){
p.HasNitro = false;
}
if(hasDashM != true){
p.HasDash = hasDashM;
if(hasDashM != false){
p.HasDash = false;
}
if(scriptM != null){
Destroy(player.GetComponent(scriptM.GetClass()));
}
}
}

View File

@ -1,15 +0,0 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WallRunItem : Item
{
public void Equip(PlayerStats p){
p.HasWallrun = true;
}
public void Unequip(PlayerStats p)
{
p.HasWallrun = false;
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 80dbcf4212f11a74ebd5289c2b5eb309
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

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

View File

@ -10,26 +10,42 @@ public class Blink : MonoBehaviour{
private Camera cam;
public CharacterController controller;
//Blink Variables
private LineRenderer beam;
private Vector3 origin;
private Vector3 endPoint;
private Vector3 mousePos;
private RaycastHit hit;
LayerMask ignoreP;
/////
private void Awake()
{
beam = gameObject.AddComponent<LineRenderer>();
beam.startWidth = 0.2f;
beam.endWidth = 0.2f;
beam.enabled = false;
ignoreP = LayerMask.GetMask("Player");
controller = GetComponent<CharacterController>();
}
void Start(){
// Grab the main camera.
cam = Camera.main;
//camera transform
cam = GetComponentInChildren<Camera>();
}
private void Update(){
if (Input.GetMouseButton(1)){
//ADJUST SO DISTANCE IS DETERMINED BY SCROLL WHEEL
//blinks the player forwards
private void BlinkMove()
{
if (Input.GetMouseButton(1))
{
// Finding the origin and end point of laser.
origin = this.transform.position + this.transform.forward * this.transform.lossyScale.z;
origin = transform.position + transform.forward * transform.lossyScale.z;
// Finding mouse pos in 3D space.
mousePos = Input.mousePosition;
@ -41,43 +57,43 @@ public class Blink : MonoBehaviour{
dir.Normalize();
// Are we hitting any colliders?
if (Physics.Raycast(origin, dir, out hit, 20f)){
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);
LineRenderer.SetPosition(1, raycastHit.point);
}*/
}
if (Input.GetMouseButtonUp(1)){
//disable character controller for a brief second for teleportation
//this.gameObject.GetComponent<CharacterController>().enabled = false;
//get
Vector3 bump = new Vector3(0, .5f, 0);
else if (!Input.GetMouseButton(1) && beam.enabled == true)
{
beam.enabled = false;
//if teleporting due to hit to object, bump them a bit outside normal
if(hit.point != null) {
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
//this.gameObject.GetComponent<CharacterController>().enabled = true;
}
}
// Update is called once per frame
void FixedUpdate()
{
}
}

View File

@ -0,0 +1,39 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dash : MonoBehaviour{
public Vector3 moveDirection;
public const float maxDashTime = 1.0f;
public float dashDistance = 10;
public float dashStoppingSpeed = 0.1f;
float currentDashTime = maxDashTime;
float dashSpeed = 12;
CharacterController characterController;
void Start(){
characterController = this.gameObject.GetComponent<CharacterController>();
}
//UPDATE CHECK FOR MOVEMENT ONLY WHEN DASHING
void FixedUpdate(){
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);
}
}

View File

@ -21,7 +21,7 @@ public class PlayerInventory : MonoBehaviour
if(!items.Contains(item) && ableToAdd){
Debug.Log("Item Added");
items.Add(item);
item.Equip(pStats);
item.Equip(pStats, this.gameObject);
}
else if(!ableToAdd && !items.Contains(item)){
Debug.Log("Item Cannot Be Added");
@ -42,7 +42,7 @@ public class PlayerInventory : MonoBehaviour
public void RemoveItem(Item item){
if(items.Remove(item)){
item.Unequip(pStats);
item.Unequip(pStats, this.gameObject);
}
}

View File

@ -24,13 +24,14 @@ public class PlayerMovement : MonoBehaviour
//Jump value
private int curJumpNum;
private bool jumpPressed;
bool tempSet = false;
float tempTraction = 0.0f;
//Jump physics
private float mass = 5.0F; // defines the character mass
private Vector3 impact = Vector3.zero;
private float distToGround;
//Wallrunning
private WallRun wallRun;
@ -43,7 +44,6 @@ public class PlayerMovement : MonoBehaviour
private Ray groundRay;
private RaycastHit groundHit;
//Camera Variables
private LayerMask ignoreP;
private Vector3 camRotation;
@ -56,26 +56,20 @@ public class PlayerMovement : MonoBehaviour
[Range(50, 500)]
public int sensitivity = 200;
//Blink Variables
private LineRenderer beam;
private Vector3 origin;
private Vector3 endPoint;
private Vector3 mousePos;
private RaycastHit hit;
/////
//Ragdoll variables
private Vector3 hit;
private Rigidbody rB;
private bool firstHit = false;
private bool heldDown = false;
private Vector3 prevRot;
private Vector3 hitForce;
void Awake()
{
//Initialize Components
moveController = GetComponent<CharacterController>();
rB = GetComponent<Rigidbody>();
pStats = GetComponent<PlayerStats>();
ignoreP = LayerMask.GetMask("Player");
beam = gameObject.AddComponent<LineRenderer>();
beam.startWidth = 0.2f;
beam.endWidth = 0.2f;
beam.enabled = false;
//camera transform
cam = GetComponentInChildren<Camera>();
@ -84,9 +78,6 @@ public class PlayerMovement : MonoBehaviour
//wallRun = gameObject.GetComponent<WallRun>();
}
void Start()
{
distToGround = GetComponent<Collider>().bounds.extents.y;
@ -98,7 +89,7 @@ public class PlayerMovement : MonoBehaviour
{
//Controls for camera
Rotate();
Rotation();
if(moveController.enabled == true){
@ -110,11 +101,34 @@ public class PlayerMovement : MonoBehaviour
// 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");
//if suffiecient impact magnitude is applied then move player
if (rB.velocity.magnitude < 0.2f){
firstHit = false;
DisableRagdoll();
}
//Gravity without moveController
vel.y -= pStats.PlayerGrav * Time.deltaTime;
rB.AddForce(new Vector3(0,vel.y,0));
//Debug.LogWarning("MoveController is either Disabled or wasn't retrieved correctly");
}
//TESTING RAGDOLL STUFF NEEDS SOME WORk
/*
if (Input.GetMouseButton(1) && heldDown == false){
Debug.Log("yup");
getHit(new Vector3(1,1,1), 2000);
heldDown = true;
}
*/
if(!Input.GetMouseButton(1)){
heldDown = false;
}
//Checks if player should respawn
@ -207,8 +221,6 @@ public class PlayerMovement : MonoBehaviour
lastTimeJumped = Time.time;
//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;
@ -218,6 +230,9 @@ public class PlayerMovement : MonoBehaviour
if (Input.GetAxis("Jump") == 0) jumpPressed = false;
}
//PlayerScript
public bool GetJumpPressed(){
return jumpPressed;
}
@ -237,8 +252,10 @@ public class PlayerMovement : MonoBehaviour
vel = newVelocity;
}
//Camera
private void Rotate()
//Camera and Player Rotation
private void Rotation()
{
transform.Rotate(Vector3.up * sensitivity * Time.deltaTime * Input.GetAxis("Mouse X"));
@ -260,13 +277,12 @@ public class PlayerMovement : MonoBehaviour
}
}
//Gravity Function for adjusting y-vel due to wallrun/glide/etc
private void Gravity(){
//Temp Values for Glider
float tempTraction = 0.0f;
bool tempSet = false;
//ADD CHECKER FOR GLIDER WHEN FULLY IMPLEMENTED
//Gliding
if(jumpPressed && pStats.HasGlider){
vel.y -= (pStats.PlayerGrav-18) * Time.deltaTime;
@ -275,7 +291,6 @@ public class PlayerMovement : MonoBehaviour
pStats.Traction = 1.0f;
tempSet = true;
}
}
else{
@ -287,13 +302,15 @@ public class PlayerMovement : MonoBehaviour
//Normal Gravity
vel.y -= pStats.PlayerGrav * Time.deltaTime;
}
//Wallrunning
if (pStats.HasWallrun) { wallRun.WallRunRoutine(); } //adjusted later if we are wallrunning
//If gliding
//Go down slowly
}
void GroundCheck()
{
// Make sure that the ground check distance while already in air is very small, to prevent suddenly snapping to ground
@ -316,62 +333,27 @@ public class PlayerMovement : MonoBehaviour
}
}
//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;
//Ragdoll Functions
private void getHit(Vector3 dir, float force){
if(firstHit == false){
EnableRagdoll();
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);
}*/
rB.AddForce(dir * force);
firstHit = true;
}
}
private void EnableRagdoll(){
prevRot = transform.localEulerAngles;
moveController.enabled = false;
rB.isKinematic = false;
rB.detectCollisions = true;
}
else if (!Input.GetMouseButton(1) && beam.enabled == true)
{
beam.enabled = false;
//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
}
private void DisableRagdoll(){
moveController.enabled = true;
rB.isKinematic = true;
rB.detectCollisions = false;
transform.localEulerAngles = prevRot;
}

View File

@ -1,11 +1,11 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Assertions;
public class PlayerStats : MonoBehaviour
{
//Maximum possible player speed
[SerializeField]
private float maxVel = 25.0f;
public float MaxVel{
get{ return maxVel; }
@ -13,7 +13,6 @@ public class PlayerStats : MonoBehaviour
}
//Minimum possible player speed
[SerializeField]
private float minVel = 2.0f;
public float MinVel{
get{ return minVel; }
@ -21,7 +20,6 @@ public class PlayerStats : MonoBehaviour
}
//Current player speed
[SerializeField]
private float curVel = 0.0f;
public float CurVel{
get{ return curVel; }
@ -29,7 +27,6 @@ public class PlayerStats : MonoBehaviour
}
//Player Jump power
[SerializeField]
private float acc = 0.1f;
public float Acc{
get{ return acc; }
@ -37,7 +34,6 @@ public class PlayerStats : MonoBehaviour
}
//Player Jump power
[SerializeField]
private float jumpPow = 300.0f;
public float JumpPow{
get{ return jumpPow; }
@ -45,7 +41,6 @@ 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; }
@ -53,7 +48,6 @@ public class PlayerStats : MonoBehaviour
}
//Player Traction
[SerializeField]
private float traction = 3.0f;
public float Traction{
get{ return traction; }
@ -61,7 +55,6 @@ public class PlayerStats : MonoBehaviour
}
//Player Kick Power
[SerializeField]
private float kickPow;
public float KickPow{
get{ return kickPow; }
@ -69,7 +62,6 @@ public class PlayerStats : MonoBehaviour
}
//Player Recovery Time When Knocked Down
[SerializeField]
private float recovTime;
public float RecovTime{
get{ return recovTime; }
@ -78,7 +70,6 @@ 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; }
@ -86,7 +77,6 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Blink
[SerializeField]
private bool hasBlink = false;
public bool HasBlink{
get{ return hasBlink; }
@ -94,7 +84,6 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Glider
[SerializeField]
private bool hasGlider = false;
public bool HasGlider{
get{ return hasGlider; }
@ -102,7 +91,6 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Grapple
[SerializeField]
private bool hasGrapple = false;
public bool HasGrapple{
get{ return hasGrapple; }
@ -110,7 +98,6 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Wallrun
[SerializeField]
private bool hasWallrun = false;
public bool HasWallrun{
get{ return hasWallrun; }
@ -118,7 +105,6 @@ public class PlayerStats : MonoBehaviour
}
//If The Player Has Nitro
[SerializeField]
private bool hasNitro = false;
public bool HasNitro{
get{ return hasNitro; }
@ -126,17 +112,24 @@ public class PlayerStats : MonoBehaviour
}
//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; }
}
// void Update(){
// VariableValidation();
// }
// void VariableValidation(){
// Debug.Assert((playerPoints != null && playerPoints > 0), "Not valid value");
// }
}

View File

@ -23,7 +23,7 @@ public class InvSceneSettings : MonoBehaviour
pointText = GameObject.Find("PlayerPoints").GetComponentInChildren<Text>();
pInv = player1.GetComponent<PlayerInventory>();
player1.GetComponent<PlayerMovement>().enabled = false;
player1.transform.GetChild(0).gameObject.SetActive(false);
player1.transform.Find("PlayerCam").gameObject.SetActive(false);
invMan = GetComponent<InventoryManager>();
}
@ -50,8 +50,9 @@ public class InvSceneSettings : MonoBehaviour
iOpt.name = item.itemName;
iOpt.transform.SetParent(GameObject.Find("Items").transform);
iOpt.transform.localScale = new Vector3(1.5f,1.5f,1.5f);
iOpt.GetComponent<Button>().onClick.AddListener(delegate{pInv.AddItem(item, UpdatePoints(item.costM, item));});
iOpt.GetComponentInChildren<Text>().text = item.itemName;
iOpt.GetComponent<Button>().onClick.AddListener(delegate{pInv.AddItem(item, UpdateObject(item.costM, item, iOpt));});
iOpt.transform.Find("Name").GetComponent<Text>().text = item.itemName;
iOpt.transform.Find("Cost").GetComponent<Text>().text = item.costM.ToString();
//iOpt.GetComponentInChildren<Image>() = item.image; // IMPLEMENT WHEN ITEM OBJECT CONTAIN IMAGE REFERENCE
index++;
@ -63,15 +64,17 @@ public class InvSceneSettings : MonoBehaviour
}
private bool UpdatePoints(int itemCost, Item item){
private bool UpdateObject(int itemCost, Item item, GameObject button){
if(pInv.GetItems().Contains(item)){
pointsLeft += itemCost;
pointText.text = "Points Left: " + pointsLeft;
button.GetComponent<Image>().color = new Color(1,1,1);
return true;
}
else if(!pInv.GetItems().Contains(item) && (pointsLeft - itemCost) >= 0){
pointsLeft -= itemCost;
pointText.text = "Points Left: " + pointsLeft;
button.GetComponent<Image>().color = new Color(.5f,.5f,.5f);
return true;
}
else{

View File

@ -12,26 +12,20 @@ EditorUserSettings:
value: 22424703114646680e0b0227036c7b151b180b65082d2b3f6004083ff6e92434e3fe33fba92f31352d1b
flags: 0
RecentlyUsedScenePath-2:
value: 224247031146466f181a033019225303593b17282e3169032e2c1336f1af073be7e933d6cb353d3e204cfa320d2a18
flags: 0
RecentlyUsedScenePath-3:
value: 224247031146466f181a033019225303593b17282e3169032e2c1336f1af073be7e933d6ca3b36327717e1351027
flags: 0
RecentlyUsedScenePath-4:
value: 224247031146466f181a033019225303593b17282e3169032e2c1336f1af073be7e933d6ca3f31297717e1351027
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
flags: 0
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c731f1415016439262f2434
flags: 0
RecentlyUsedScenePath-7:
RecentlyUsedScenePath-3:
value: 22424703114646680e0b0227036c6b19021b1d192f2d2835633c133af6f9
flags: 0
RecentlyUsedScenePath-8:
RecentlyUsedScenePath-4:
value: 22424703114646680e0b0227036c6f02131b172b282d347e38271427fb
flags: 0
RecentlyUsedScenePath-5:
value: 22424703114646680e0b0227036c7b151b180b6505263035233d1221fbd33134e7e422e0e8347129370bfb25
flags: 0
RecentlyUsedScenePath-6:
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
flags: 0
UnityRemoteCompression:
value: 337f73
flags: 0