private void OnTriggerStay(Collider other) { if (other.gameObject.tag == "Starship") { starSnaphost.TransitionTo(0.5f); Starship.ApplyDamage(demage); Debug.Log("Star damage"); } }
private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Starship") { if (Starship.getVelocity() > velocityDamage) { Starship.ApplyDamage(damage); } } }
private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Starship") { Starship.ApplyDamage(demage); Destroy(gameObject); } else { Destroy(gameObject); } }
private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Starship") { if (hasFuel) { Starship.fuel += fuel; fuelCollison.Play(); this.gameObject.SetActive(false); } else { Starship.ApplyDamage(damage); Debug.Log("Asteroid collision demage"); } } }
private void OnCollisionEnter(Collision other) { if (other.gameObject.tag == "Starship") { if (other.relativeVelocity.magnitude > 15) { Starship.ApplyDamage(demageToStarshipOnCollision); this.ApplyDamage(demageFactorToEnemyOnStarshipCollision * other.relativeVelocity.magnitude); } } if (other.gameObject.tag == "Asteroids") { if (other.relativeVelocity.magnitude > 20) { // Debug.Log("Enemy-Asteroid Collision: " + other.relativeVelocity.magnitude); ApplyDamage(demageFactorToEnemyOnAsteroidCollision * other.relativeVelocity.magnitude); } } else if (other.gameObject.tag == "Planet" || other.gameObject.tag == "Vesta" || other.gameObject.tag == "Mars") { // Debug.Log("Enemy-Planet Collision: " + other.relativeVelocity.magnitude); if (other.relativeVelocity.magnitude > 20) { ApplyDamage(demageFactorToEnemyOnPlanetCollision * other.relativeVelocity.magnitude); } } if (other.gameObject.tag == "Enemy") { // Debug.Log("Enemy-Enemy Collision: " + other.relativeVelocity.magnitude); if (other.relativeVelocity.magnitude > 57) { Debug.Log("Enemy-Enemy Destroy"); ApplyDamage(100); other.gameObject.GetComponent <Enemy>().ApplyDamage(demageToEnemyOnEnemyCollision); } } }
private void OnCollisionStay(Collision other) { if (other.gameObject.tag == "Starship") { timer = 0; if (hasLava) { Starship.ApplyDamage(lavaDamage); } if (starshipRigidbody.velocity.magnitude < 5 && Vector3.Angle(-starship.transform.up, transform.position - starship.transform.position) < angle) { // Docking starshipRigidbody.velocity = Vector2.Lerp(starshipRigidbody.velocity, Vector3.zero, 2 * Time.deltaTime); if ((Starship.fuel < 100 || Starship.health < 100 || Starship.oxygen < 96) && (currentOxygen > 0 || currentFuel > 0)) { oxygenAndFuel.Play(); if (dockingAudio != null) { dockingAudio.UnPause(); dockingAudio.volume = 0.0178f; } if (currentOxygen > 0) { Starship.oxygen += 8 * Time.deltaTime; currentOxygen -= 8 * Time.deltaTime; atmosphere.localScale = Vector3.Lerp(atmosphere.localScale, new Vector3(1f, 1f, 1f), Time.deltaTime * 0.3f); } if (currentFuel > 0) { Starship.fuel += 10 * Time.deltaTime; currentFuel -= 10 * Time.deltaTime; } if (Starship.health < 100 && !hasLava) { Starship.health += 8 * Time.deltaTime; } } else { oxygenAndFuel.Stop(); if (dockingAudio != null) { dockingAudio.volume = 0f; dockingAudio.Pause(); } } } else { Starship.ApplyDamage(0.23f); dockingAudio.Pause(); oxygenAndFuel.Stop(); if (dockingAudio != null) { dockingAudio.volume = 0f; } } } }