using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class PlayerShootPower : MonoBehaviour {

    public GameObject bullets;
    public Transform bulletSpawn1;
    public Transform bulletSpawn2;
    public Transform bulletSpawn3;

    public float fireRate;
    private float fireNext = 0.50f;

    [SerializeField]
    public Button fireButton;

    public AudioSource audioSource;
    public AudioClip playerShoot;


    void Start () {
		
	}
	
	void Update () {
		
	}

    public void FireBullets() {
        if (fireButton && Time.time >= fireNext)
        {
            fireNext = Time.time + fireRate;
            audioSource.PlayOneShot(playerShoot);
            Instantiate(bullets, bulletSpawn1.position, bulletSpawn1.rotation);
            Instantiate(bullets, bulletSpawn2.position, bulletSpawn2.rotation);
            Instantiate(bullets, bulletSpawn3.position, bulletSpawn3.rotation);
        }
    }
}
