public GameObject bulletPrefab;
public GameObject SuperballPrefabe;
private int speed = 500;
public static bool stoprunning;
//audios
private AudioSource audio;
public AudioClip FireBull;
// Use this for initialization
void Start () {
audio = GameObject.Find("SoundSettings").GetComponent<AudioSource>();
}
// Update is called once per frame
void Update () {
}
public void FireBullet()
{
if (GameManager.FireTimer > 0) {
//Clone of the bullet
Player.attack = true;
stoprunning = true;
GameObject Clone;
audio.PlayOneShot (FireBull, 0.8f);
if (Player.superpower == false || GameManager.SuperFireTimer == 0) {
//spawning the bullet at position
Clone = (Instantiate (bulletPrefab, transform.position, transform.rotation)) as GameObject;
//add force to the spawned objected
Destroy (Clone, 1f);
if (Player.face == false) {
Clone.GetComponent<Rigidbody2D> ().AddForce (transform.right * speed);
}
if (Player.face == true) {
Clone.GetComponent<Rigidbody2D> ().AddForce (-transform.right * speed);
}
GameManager.FireTimer -= 5;
} else {
//spawning the bullet at position
Clone = (Instantiate (SuperballPrefabe, transform.position, transform.rotation)) as GameObject;
//add force to the spawned objected
Destroy (Clone, 1f);
if (Player.face == false) {
Clone.GetComponent<Rigidbody2D> ().AddForce (transform.right * speed);
}
if (Player.face == true) {
Clone.GetComponent<Rigidbody2D> ().AddForce (-transform.right * speed);
}
GameManager.SuperFireTimer -= 5;
}
}
StartCoroutine(Example());
}
IEnumerator Example()
{
yield return new WaitForSeconds(0.2f);
Player.attack = false;
stoprunning = false;
}
public GameObject SuperballPrefabe;
private int speed = 500;
public static bool stoprunning;
//audios
private AudioSource audio;
public AudioClip FireBull;
// Use this for initialization
void Start () {
audio = GameObject.Find("SoundSettings").GetComponent<AudioSource>();
}
// Update is called once per frame
void Update () {
}
public void FireBullet()
{
if (GameManager.FireTimer > 0) {
//Clone of the bullet
Player.attack = true;
stoprunning = true;
GameObject Clone;
audio.PlayOneShot (FireBull, 0.8f);
if (Player.superpower == false || GameManager.SuperFireTimer == 0) {
//spawning the bullet at position
Clone = (Instantiate (bulletPrefab, transform.position, transform.rotation)) as GameObject;
//add force to the spawned objected
Destroy (Clone, 1f);
if (Player.face == false) {
Clone.GetComponent<Rigidbody2D> ().AddForce (transform.right * speed);
}
if (Player.face == true) {
Clone.GetComponent<Rigidbody2D> ().AddForce (-transform.right * speed);
}
GameManager.FireTimer -= 5;
} else {
//spawning the bullet at position
Clone = (Instantiate (SuperballPrefabe, transform.position, transform.rotation)) as GameObject;
//add force to the spawned objected
Destroy (Clone, 1f);
if (Player.face == false) {
Clone.GetComponent<Rigidbody2D> ().AddForce (transform.right * speed);
}
if (Player.face == true) {
Clone.GetComponent<Rigidbody2D> ().AddForce (-transform.right * speed);
}
GameManager.SuperFireTimer -= 5;
}
}
StartCoroutine(Example());
}
IEnumerator Example()
{
yield return new WaitForSeconds(0.2f);
Player.attack = false;
stoprunning = false;
}
No comments:
Post a Comment