inventory
This commit is contained in:
@@ -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<Image>().color = Color.deepPink;
|
||||
if (energy <= 0)
|
||||
energy -= 20 * Time.deltaTime;
|
||||
dashDistanceTimer += Time.deltaTime;
|
||||
if (dashDistanceTimer > 1)
|
||||
energyFill.GetComponent<Image>().color = Color.deepPink;
|
||||
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)
|
||||
{
|
||||
dashDistance = Mathf.Floor(dashDistanceTimer * 8);
|
||||
@@ -266,17 +302,15 @@ public class PlayerMovement : MonoBehaviour
|
||||
dashDistanceTimer = 0;
|
||||
}
|
||||
}
|
||||
//if (!Input.GetMouseButton(0))
|
||||
//energyFill.GetComponent<Image>().color = new Color(196, 3, 0, 255);
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
|
||||
if (inventorySlot == 2)
|
||||
{
|
||||
energyFill.GetComponent<Image>().color = Color.darkRed;
|
||||
if (dashDistanceTimer > 1)
|
||||
{
|
||||
dashDistance = Mathf.Floor(dashDistanceTimer * 8);
|
||||
dashDuration = 15;
|
||||
}
|
||||
dashDistanceTimer = 0;
|
||||
|
||||
}
|
||||
|
||||
if (inventorySlot == 3)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user