Created
November 5, 2021 19:26
-
-
Save curious-username/55baf2ebb88d30ae8fc16108a89c20c2 to your computer and use it in GitHub Desktop.
big laser changes to player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Player : MonoBehaviour | |
{ | |
[SerializeField] | |
private GameObject _bigLaser, _laserCharge; | |
private bool _isBigLaserActive = false; | |
[SerializedField] | |
AudioSource _chargingSound, _bigLaserSound; | |
void FireLaser() | |
{ | |
_canFire = Time.time + _fireRate; | |
Vector3 offset = new Vector3(0, 1.05f, 0); | |
if(_isBigLaserActive == false) { | |
_ammoCount--; | |
if (_ammoCount < 0) | |
{ | |
_ammoEmpty.Play(); | |
_ammoCount = 0; | |
} | |
else if (_isTripleShotActive == true && _ammoCount > 0) | |
{ | |
Instantiate(_tripleShot, transform.position, Quaternion.identity); | |
_laserSound.Play(); | |
} | |
else if (_ammoCount > 0) | |
{ | |
Instantiate(_laserPrefab, transform.position + offset, Quaternion.identity); | |
_laserSound.Play(); | |
} | |
_uiManager.UpdateAmmoCount(_ammoCount); | |
} | |
} | |
public void BigLaserActive() | |
{ | |
_powerupSound.Play(); | |
if (_isBigLaserActive != true) { | |
_isBigLaserActive = true; | |
if (_bigLaser != null) | |
{ | |
_chargingSound.Play(); | |
_laserCharge.SetActive(true); | |
StartCoroutine(ChargeOff()); | |
} | |
} | |
} | |
IEnumerator ChargeOff() | |
{ | |
yield return new WaitForSeconds(2.0f); | |
_laserCharge.SetActive(false); | |
BigLaser(); | |
} | |
void BigLaser() | |
{ | |
_bigLaserSound.Play(); | |
_bigLaser.SetActive(true); | |
StartCoroutine(BigLaserCoolDown()); | |
} | |
IEnumerator BigLaserCoolDown() | |
{ | |
yield return new WaitForSeconds(5.0f); | |
_isBigLaserActive = false; | |
_bigLaser.SetActive(false); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment