Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void ShootLasers()
- {
- if(isTripleFireActive == true)
- {
- TripleFiring();
- }
- else if (isTripleFireActive == false)
- {
- SingleFire();
- }
- }
- public void TripleFiring()
- {
- if (Input.GetMouseButtonDown(0))
- {
- continueTripleFire = StartCoroutine(TripleNonStopFiring());
- }
- if (Input.GetMouseButtonUp(0))
- {
- StopCoroutine(continueTripleFire);
- }
- }
- public void SingleFire()
- {
- if (Input.GetMouseButtonDown(0))
- {
- continueFiring = StartCoroutine(FireNonStop());
- }
- if (Input.GetMouseButtonUp(0))
- {
- StopCoroutine(continueFiring);
- }
- }
- public void TripleFiringIsActive()
- {
- StartCoroutine(TripleFireState());
- }
- IEnumerator FireNonStop()
- {
- while (true)
- {
- GameObject laserBullet = Instantiate(playerLaser, transform.position + new Vector3(0, .5f, 0), transform.rotation) as GameObject;
- laserBullet.GetComponent<Rigidbody2D>().velocity = new Vector2(0, laserSpeed);
- yield return new WaitForSeconds(laserFiringTime);
- }
- }
- IEnumerator TripleNonStopFiring()
- {
- while(isTripleFireActive == true)
- {
- GameObject laserBulletMiddle = Instantiate(playerLaser, transform.position + new Vector3(0, .5f, 0), transform.rotation) as GameObject;
- GameObject laserBulletRight = Instantiate(playerLaser, transform.position + new Vector3(.18f, 0, 0), transform.rotation) as GameObject;
- GameObject laserBulletLeft = Instantiate(playerLaser, transform.position + new Vector3(-.2f, 0, 0), transform.rotation) as GameObject;
- laserBulletMiddle.GetComponent<Rigidbody2D>().velocity = new Vector2(0, laserSpeed);
- laserBulletRight.GetComponent<Rigidbody2D>().velocity = new Vector2(0, laserSpeed);
- laserBulletLeft.GetComponent<Rigidbody2D>().velocity = new Vector2(0, laserSpeed);
- yield return new WaitForSeconds(triplelaserFiringTime);
- }
- }
- IEnumerator TripleFireState()
- {
- isTripleFireActive = true;
- yield return new WaitForSeconds(5f);
- isTripleFireActive = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement