Added UI to let player know if gun is ready to fire

This commit is contained in:
Gregory Campbell
2020-07-11 14:33:20 -04:00
parent 3295e58965
commit 5ef8a35f08
7 changed files with 199 additions and 1 deletions
+16 -1
View File
@@ -13,18 +13,26 @@ public class PlayerScript : MonoBehaviour
private float rotation;
private float nextFire = 0.5f;
private float myTime = 0.0f;
private GameObject reloaded;
private Rigidbody2D rb;
void Awake()
{
rb = this.GetComponent<Rigidbody2D>();
reloaded = GameObject.Find("Reloaded");
}
void Update()
{
reloaded.SetActive(false);
myTime += Time.deltaTime;
if(myTime > nextFire)
{
reloaded.SetActive(true);
}
if(Input.GetButton("Fire1") && myTime > nextFire)
{
nextFire = myTime + 0.5f;
@@ -62,12 +70,19 @@ public class PlayerScript : MonoBehaviour
void GunFire(float aim)
{
int gunSelect = Random.Range(0,4);
int gunSelect = 0;
GameObject newBullet;
float scaleChange = 1.0f;
Vector3 pos = PlayerCircle(transform.position);
Quaternion rot = Quaternion.FromToRotation(Vector3.down, transform.position-pos);
if(Random.Range(0,10) == 0)
{
gunSelect = Random.Range(1,4);
}
switch(gunSelect)
{