diff --git a/Assets/WeaponHandling.cs b/Assets/WeaponHandling.cs index 883d840f1893ff3436907eeca3d97855a41ded8c..d4e073be476a79ec6197f60ab387774c2580aabe 100644 --- a/Assets/WeaponHandling.cs +++ b/Assets/WeaponHandling.cs @@ -17,7 +17,7 @@ public class WeaponHandling : MonoBehaviour Player = GetComponent<PlayerMovement>(); } // Update is called once per frame - void FixedUpdate() + void Update() { if (Input.GetKeyDown("1")) { @@ -27,6 +27,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Bow.SetActive(false); Sword.SetActive(false); + return; } if (Input.GetKeyDown("2") && Player.shotgun == 1) { @@ -36,6 +37,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(true); Sword.SetActive(false); Bow.SetActive(false); + return; } if (Input.GetKeyDown("3") && Player.sword == 1) { @@ -45,6 +47,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Bow.SetActive(false); Sword.SetActive(true); + return; } if (Input.GetKeyDown("4") && Player.bow == 1) { @@ -54,6 +57,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Bow.SetActive(true); Sword.SetActive(false); + return; } // scroll change weapon if (weaponIdx==0 && Input.GetAxis("Mouse ScrollWheel") < 0f) // downward @@ -66,6 +70,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(true); Sword.SetActive(false); Bow.SetActive(false); + return; } else if (Player.sword == 1) { @@ -75,6 +80,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(true); Bow.SetActive(false); + return; } else if (Player.bow == 1) { @@ -85,9 +91,11 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(true); + return; } else { weaponIdx = 0; + return; } } //upward @@ -101,6 +109,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(true); + return; } else if (Player.sword == 1) { @@ -110,6 +119,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(true); Bow.SetActive(false); + return; } else if (Player.shotgun == 1) { @@ -119,10 +129,12 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(true); Sword.SetActive(false); Bow.SetActive(false); + return; } else { weaponIdx = 0; + return; } } // downward shotgun @@ -136,6 +148,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(true); Bow.SetActive(false); + return; } else if (Player.bow == 1) { @@ -145,15 +158,18 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(true); + return; } else { + Debug.Log("Lol"); weaponIdx = 0; Rifle.SetActive(true); RifleEnd.SetActive(true); Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(false); + return; } } // upward shotgun @@ -165,6 +181,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(false); + return; } // downward sword if (weaponIdx == 2 && Input.GetAxis("Mouse ScrollWheel") < 0f) @@ -177,6 +194,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(true); + return; } else { @@ -186,6 +204,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(false); + return; } } // upward sword @@ -199,6 +218,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(true); Sword.SetActive(false); Bow.SetActive(false); + return; } else { @@ -208,6 +228,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(false); + return; } } // downward bow @@ -219,6 +240,7 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(false); + return; } // upward bow if (weaponIdx == 3 && Input.GetAxis("Mouse ScrollWheel") > 0f) @@ -231,15 +253,25 @@ public class WeaponHandling : MonoBehaviour Shotgun.SetActive(false); Sword.SetActive(true); Bow.SetActive(false); + return; } - else - { + else if (Player.shotgun == 1) { + weaponIdx = 1; + Rifle.SetActive(false); + RifleEnd.SetActive(false); + Shotgun.SetActive(true); + Sword.SetActive(false); + Bow.SetActive(false); + return; + } + else { weaponIdx = 0; Rifle.SetActive(true); RifleEnd.SetActive(true); Shotgun.SetActive(false); Sword.SetActive(false); Bow.SetActive(false); + return; } } }