inventory

This commit is contained in:
IsaacWarhol
2025-11-13 14:37:48 -08:00
parent ccc0103e06
commit e6616444d0

View File

@@ -46,6 +46,8 @@ public class PlayerMovement : MonoBehaviour
public float HP = 10; public float HP = 10;
public int inventorySlot = 1;
public float energy = 100; public float energy = 100;
public float swungTimer; public float swungTimer;
public bool swung; public bool swung;
@@ -125,6 +127,25 @@ public class PlayerMovement : MonoBehaviour
HP = 10; 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 (Input.GetKeyDown(KeyCode.Escape))
{ {
if (Time.timeScale == 1) 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); 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) if (GameObject.FindGameObjectsWithTag("Sword").Length < 1)
SwingSword(); {
if (energy > 7)
SwingSword();
}
else
{
swung = true;
swungTimer = 0;
holdSwingTimer = 0;
holdSwing = true;
}
} }
else if (Input.GetMouseButton(0))
{ {
swung = true; swung = true;
swungTimer = 0; swungTimer = 0;
holdSwingTimer = 0; timeSinceLastSwing = 0;
holdSwing = true;
}
}
if (Input.GetMouseButton(0))
{
swung = true;
swungTimer = 0;
timeSinceLastSwing = 0;
energy -= 20 * Time.deltaTime; energy -= 20 * Time.deltaTime;
dashDistanceTimer += Time.deltaTime; dashDistanceTimer += Time.deltaTime;
if (dashDistanceTimer > 1) if (dashDistanceTimer > 1)
energyFill.GetComponent<Image>().color = Color.deepPink; energyFill.GetComponent<Image>().color = Color.deepPink;
if (energy <= 0) if (energy <= 0)
{
if (dashDistanceTimer > 1)
{
dashDistance = Mathf.Floor(dashDistanceTimer * 8);
dashDuration = 15;
}
dashDistanceTimer = 0;
}
}
//if (!Input.GetMouseButton(0))
//energyFill.GetComponent<Image>().color = new Color(196, 3, 0, 255);
if (Input.GetMouseButtonUp(0))
{ {
energyFill.GetComponent<Image>().color = Color.darkRed;
if (dashDistanceTimer > 1) if (dashDistanceTimer > 1)
{ {
dashDistance = Mathf.Floor(dashDistanceTimer * 8); dashDistance = Mathf.Floor(dashDistanceTimer * 8);
@@ -266,17 +302,15 @@ public class PlayerMovement : MonoBehaviour
dashDistanceTimer = 0; dashDistanceTimer = 0;
} }
} }
//if (!Input.GetMouseButton(0))
//energyFill.GetComponent<Image>().color = new Color(196, 3, 0, 255); if (inventorySlot == 2)
if (Input.GetMouseButtonUp(0))
{ {
energyFill.GetComponent<Image>().color = Color.darkRed;
if (dashDistanceTimer > 1) }
{
dashDistance = Mathf.Floor(dashDistanceTimer * 8); if (inventorySlot == 3)
dashDuration = 15; {
}
dashDistanceTimer = 0;
} }
} }
} }