From e6616444d07debe7a873091ee9185194067769f3 Mon Sep 17 00:00:00 2001 From: IsaacWarhol <65301558+IsaacWarhol@users.noreply.github.com> Date: Thu, 13 Nov 2025 14:37:48 -0800 Subject: [PATCH] inventory --- Assets/Scripts/PlayerMovement.cs | 92 ++++++++++++++++++++++---------- 1 file changed, 63 insertions(+), 29 deletions(-) diff --git a/Assets/Scripts/PlayerMovement.cs b/Assets/Scripts/PlayerMovement.cs index 2ab1481..5181ca1 100644 --- a/Assets/Scripts/PlayerMovement.cs +++ b/Assets/Scripts/PlayerMovement.cs @@ -46,6 +46,8 @@ public class PlayerMovement : MonoBehaviour public float HP = 10; + public int inventorySlot = 1; + public float energy = 100; public float swungTimer; public bool swung; @@ -125,6 +127,25 @@ public class PlayerMovement : MonoBehaviour HP = 10; } + + + if (Input.GetKeyDown(KeyCode.Alpha1)) + { + inventorySlot = 1; + } + if (Input.GetKeyDown(KeyCode.Alpha2)) + { + inventorySlot = 2; + } + if (Input.GetKeyDown(KeyCode.Alpha3)) + { + inventorySlot = 3; + } + if (inventorySlot > 3) + inventorySlot = 3; + if (inventorySlot < 1) + inventorySlot = 1; + if (Input.GetKeyDown(KeyCode.Escape)) { if (Time.timeScale == 1) @@ -231,33 +252,48 @@ public class PlayerMovement : MonoBehaviour healthUI.sizeDelta = new Vector2((Mathf.Ceil(HP)-1) + (9 * HP), healthUI.sizeDelta.y); - if (Input.GetMouseButtonDown(0)) + if (inventorySlot == 1) { - if (GameObject.FindGameObjectsWithTag("Sword").Length < 1) + if (Input.GetMouseButtonDown(0)) { - if (energy > 7) - SwingSword(); + if (GameObject.FindGameObjectsWithTag("Sword").Length < 1) + { + if (energy > 7) + SwingSword(); + } + else + { + swung = true; + swungTimer = 0; + holdSwingTimer = 0; + holdSwing = true; + } } - else + if (Input.GetMouseButton(0)) { swung = true; swungTimer = 0; - holdSwingTimer = 0; - holdSwing = true; - } - } - if (Input.GetMouseButton(0)) - { - swung = true; - swungTimer = 0; - timeSinceLastSwing = 0; + timeSinceLastSwing = 0; - energy -= 20 * Time.deltaTime; - dashDistanceTimer += Time.deltaTime; - if (dashDistanceTimer > 1) - energyFill.GetComponent().color = Color.deepPink; - if (energy <= 0) + energy -= 20 * Time.deltaTime; + dashDistanceTimer += Time.deltaTime; + if (dashDistanceTimer > 1) + energyFill.GetComponent().color = Color.deepPink; + if (energy <= 0) + { + if (dashDistanceTimer > 1) + { + dashDistance = Mathf.Floor(dashDistanceTimer * 8); + dashDuration = 15; + } + dashDistanceTimer = 0; + } + } + //if (!Input.GetMouseButton(0)) + //energyFill.GetComponent().color = new Color(196, 3, 0, 255); + if (Input.GetMouseButtonUp(0)) { + energyFill.GetComponent().color = Color.darkRed; if (dashDistanceTimer > 1) { dashDistance = Mathf.Floor(dashDistanceTimer * 8); @@ -266,17 +302,15 @@ public class PlayerMovement : MonoBehaviour dashDistanceTimer = 0; } } - //if (!Input.GetMouseButton(0)) - //energyFill.GetComponent().color = new Color(196, 3, 0, 255); - if (Input.GetMouseButtonUp(0)) + + if (inventorySlot == 2) { - energyFill.GetComponent().color = Color.darkRed; - if (dashDistanceTimer > 1) - { - dashDistance = Mathf.Floor(dashDistanceTimer * 8); - dashDuration = 15; - } - dashDistanceTimer = 0; + + } + + if (inventorySlot == 3) + { + } } }