mirror of
https://github.com/Leahnaya/TheKingsRace.git
synced 2026-09-08 18:35:18 -05:00
small changes to player and items for cleanup
This commit is contained in:
@@ -815,6 +815,10 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 4367973138255890080, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
propertyPath: cam
|
||||
value:
|
||||
objectReference: {fileID: 2127720128}
|
||||
- target: {fileID: 5633209979457551608, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
propertyPath: m_Name
|
||||
value: DebugPlayerPrefab
|
||||
@@ -1380,3 +1384,8 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 283, y: -71}
|
||||
m_SizeDelta: {x: 100, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!20 &2127720128 stripped
|
||||
Camera:
|
||||
m_CorrespondingSourceObject: {fileID: 4654986889578046791, guid: 362ca97b75c291a47ab81d628a81f440, type: 3}
|
||||
m_PrefabInstance: {fileID: 885603619}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
|
||||
@@ -544,7 +544,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 724425600}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 2.0000002, y: 2.1131458, z: -0.73}
|
||||
m_LocalPosition: {x: 2.0000002, y: 2.1131458, z: 33.4}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1650963653}
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08ce0ad440e9031429d13663cf77c6f0
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4399d7276b3edf446ac51c5145539a5e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 11400000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -46,22 +46,30 @@ public class InvSceneSettings : MonoBehaviour
|
||||
if(itemOptPrefab != null){
|
||||
foreach(Item item in invMan.ItemList){
|
||||
|
||||
//Positioning Buttons
|
||||
if(index < 5){
|
||||
position = new Vector3(((index)),3,0);
|
||||
}
|
||||
else{
|
||||
position = new Vector3(((index-5)),2,0);
|
||||
}
|
||||
|
||||
//Creates Button
|
||||
var iOpt = Instantiate(itemOptPrefab, position, Quaternion.identity);
|
||||
|
||||
//Uses Item Variables to update button
|
||||
iOpt.name = item.itemName;
|
||||
iOpt.transform.SetParent(GameObject.Find("Items").transform);
|
||||
iOpt.transform.localScale = new Vector3(1.5f,1.5f,1.5f);
|
||||
|
||||
//Button Adds item if it can
|
||||
iOpt.GetComponent<Button>().onClick.AddListener(delegate{pInv.AddItem(item, UpdateObject(item.costM, item, iOpt));});
|
||||
|
||||
//Changes Button Texts
|
||||
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++;
|
||||
}
|
||||
}
|
||||
@@ -72,19 +80,27 @@ public class InvSceneSettings : MonoBehaviour
|
||||
}
|
||||
|
||||
private bool UpdateObject(int itemCost, Item item, GameObject button){
|
||||
|
||||
if(pInv.GetItems().Contains(item)){
|
||||
//Player can remove the 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){
|
||||
//Player can add the item
|
||||
pointsLeft -= itemCost;
|
||||
pointText.text = "Points Left: " + pointsLeft;
|
||||
button.GetComponent<Image>().color = new Color(.5f,.5f,.5f);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
else{
|
||||
//Player cannot add or remove the item
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,10 @@ EditorBuildSettings:
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/Game-Mountain.unity
|
||||
guid: f6e50dc4cb4a9b2449937a34f68b7e26
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/Demos/InventorySelection.unity
|
||||
guid: 087e255255a646a4b895d4c7b60e2e3e
|
||||
- enabled: 1
|
||||
path: Assets/Scenes/Demos/MovementScene.unity
|
||||
guid: 4282c79fedd3def4fa3c93c0a77f914f
|
||||
m_configObjects: {}
|
||||
|
||||
@@ -6,6 +6,9 @@ EditorUserSettings:
|
||||
serializedVersion: 4
|
||||
m_ConfigSettings:
|
||||
RecentlyUsedScenePath-0:
|
||||
value: 22424703114646680e0b0227036c7b151b180b6501273035202c1327d1e33136e7a923e7ee2e26
|
||||
flags: 0
|
||||
RecentlyUsedScenePath-1:
|
||||
value: 22424703114646680e0b0227036c7b151b180b6505263035233d1221fbd33134e7e422e0e8347129370bfb25
|
||||
flags: 0
|
||||
vcSharedLogLevel:
|
||||
|
||||
Reference in New Issue
Block a user