void UpdatePlayersLives(ExtraShips eShip) { // Player's Lives if (eShip.getMaxLive() <= lives) { PlayerLivesBar.displayPlayersLives("Lives: Max - "); } else { PlayerLivesBar.displayPlayersLives(); } }
void OnTriggerEnter2D(Collider2D col) { ExtraShips eShip = col.gameObject.GetComponent <ExtraShips> (); if (col.gameObject.name.Contains("Ship")) { if (eShip) { if (eShip.getMaxLive() > lives) { lives += eShip.GetExtraShip(); eShip.extraShipUsed(); } } } else if (col.gameObject.name.Contains("Health")) { ExtraHealths extraHealth = col.gameObject.GetComponent <ExtraHealths>(); if (extraHealth) { health += extraHealth.GetExtraHealth(); extraHealth.extraHealthUsed(); } } else if (col.gameObject.name.Contains("Speed")) { ExtraSpeeds extraSpeed = col.gameObject.GetComponent <ExtraSpeeds>(); if (extraSpeed) { projectileSpeed += extraSpeed.GetExtraSpeed(); extraSpeed.extraSpeedUsed(); } } else if (col.gameObject.name.Contains("ExtraWeapon")) { ExtraWeapons extraWeapon = col.gameObject.GetComponent <ExtraWeapons>(); if (extraWeapon) { if (extraWeapon.getMaxWeapons() >= numFire) { numFire += extraWeapon.GetExtraWeapon(); extraWeapon.extraWeaponUsed(); } } } else if (col.gameObject.name.Contains("Laser")) { Projectile missile = col.gameObject.GetComponent <Projectile> (); if (missile) { // Remove the damage from the player health health -= missile.GetDamage(); // Then destory the missile missile.Hit(); // If Health goes below 0 if (health <= 0) { Debug.Log("Current Lives Count: " + lives); ReSetHealth(); lives -= 1; if (lives == 0) { Debug.Log("Live Count: " + lives); ReSetLives(); Die(); } } } } Update(); // Player's Health PlayerHealth.displayPlayersHealth(); // Player's Lives UpdatePlayersLives(eShip); Update(); }