diff options
Diffstat (limited to 'Assets/Scripts/Boss1/Boss1FireScript.cs')
-rwxr-xr-x | Assets/Scripts/Boss1/Boss1FireScript.cs | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/Assets/Scripts/Boss1/Boss1FireScript.cs b/Assets/Scripts/Boss1/Boss1FireScript.cs new file mode 100755 index 0000000..35978b3 --- /dev/null +++ b/Assets/Scripts/Boss1/Boss1FireScript.cs @@ -0,0 +1,89 @@ +using UnityEngine; +using System.Collections; + +public class Boss1FireScript : MonoBehaviour { + public float FireRate = 1.5f; + float fireCounter; + bool PlayerInRange = false; + public GameObject Bullet; + public float BulletSpeed = 20; + bool active; + + AudioSource EnemyFireAudio; + + + void Start() + { + EnemyFireAudio = GameObject.FindGameObjectWithTag("EnemyFireAudio").GetComponent<AudioSource>(); + } + + void Update() + { + if (active) + { + fireCounter += Time.deltaTime; + if (fireCounter >= FireRate && PlayerInRange) + { + fireCounter = 0; + EnemyFireAudio.Play(); + Fire(); + + } + } + } + + void Fire() + { + //var Bullet1 = Instantiate(Bullet, gameObject.transform.position, Quaternion.identity) as GameObject; + //Bullet1.GetComponent<Rigidbody2D>().velocity = Vector2.up * BulletSpeed; + //var Bullet2 = Instantiate(Bullet, gameObject.transform.position, Quaternion.identity) as GameObject; + //Bullet2.GetComponent<Rigidbody2D>().velocity = Vector2.right * BulletSpeed; + //var Bullet3 = Instantiate(Bullet, gameObject.transform.position, Quaternion.identity) as GameObject; + //Bullet3.GetComponent<Rigidbody2D>().velocity = Vector2.down * BulletSpeed; + //var Bullet4 = Instantiate(Bullet, gameObject.transform.position, Quaternion.identity) as GameObject; + //Bullet4.GetComponent<Rigidbody2D>().velocity = Vector2.left * BulletSpeed; + //Destroy(Bullet1, 1.5f); + //Destroy(Bullet2, 1.5f); + //Destroy(Bullet3, 1.5f); + //Destroy(Bullet4, 1.5f); + + for (int i = 0; i < 24; i++) + { + var b = Instantiate(Bullet, gameObject.transform.position, Quaternion.identity) as GameObject; + b.GetComponent<Rigidbody2D>().velocity = new Vector2( + (Mathf.Cos(i*Mathf.PI*.1f)) * 20, + (Mathf.Sin(i*Mathf.PI*.1f)) * 20 + ); + Destroy(b, 2.5f); + } + } + + + void OnTriggerEnter2D(Collider2D other) + { + var player = other.gameObject.GetComponentInParent<PlayerHealthScript>(); + if (player != null) + { + PlayerInRange = true; + } + } + + void OnTriggerExit2D(Collider2D other) + { + var player = other.gameObject.GetComponentInParent<PlayerHealthScript>(); + if (player != null) + { + PlayerInRange = false; + } + } + + public void EnableBoss1Fire() + { + active = true; + } + public void DisableBoss1Fire() + { + active = false; + } + +} |