public void AddCameraTrauma(float value) { if (_shakyCamera != null) { _shakyCamera.AddTrauma(value); } }
void OnBreakableHit(Breakable breakable) { PlayAudio(m_BreakableSound); StartCoroutine(StunPlayer(m_StunTime)); m_Rigidbody.velocity = Vector3.zero; m_CurrentEnergy -= breakable.m_EnergyLost; breakable.DestoryBreakable(); Vector3 direction = breakable.transform.position - transform.position; m_Rigidbody.AddForce(-direction.normalized * 1000); m_CameraShake.AddTrauma(0.8f); GameManager.m_Singleton.AddPenalty(); UpdateUI(); }
public void GotHit(float hitForce, Vector3 position) { Vector2 hitDir = (transform.position - position).normalized * hitForce * 1.0f; Vector2 facingDir = new Vector2(hitDir.x, hitDir.y); float angle = Mathf.Atan2(facingDir.y, facingDir.x) * Mathf.Rad2Deg; Quaternion quat = Quaternion.AngleAxis(angle, Vector3.forward); Quaternion quat2 = Quaternion.AngleAxis(angle + 80, Vector3.forward); if (!gfm.disableBlockStun) { rb.velocity = hitDir; } if (!gfm.disableAnimations) { transform.rotation = quat; } if (!gfm.disableSoundEffects) { //SFX float pitch = (1 / (hitForce / 40)) - 0.5f; aud.PlayWithPitch("EnemyHit", pitch); } if (!gfm.disableParticles) { //VFX GameObject particles = Instantiate(ps, transform.position - new Vector3(0, 0.5f, 0), Quaternion.identity); ParticleSystem hitParticles = particles.GetComponent <ParticleSystem>(); hitParticles.Play(); //VFX GameObject particle = Instantiate(slashParticles, transform.position + new Vector3(0, 0.5f, 0), quat2); ParticleSystem hitParticle = particle.GetComponent <ParticleSystem>(); hitParticle.Play(); //VFX GameObject slashPart = Instantiate(slashParticles, transform.position + new Vector3(0, 0.5f, 0), quat); ParticleSystem hitPart = slashPart.GetComponent <ParticleSystem>(); hitPart.Play(); } if (!gfm.disableScreenShake) { //Camera shake CameraShake.AddTrauma((hitForce) / 40); } }
public void TakeDamage() { if (godMode) { return; } if (immune) { return; } immune = true; immuneTimer = 0; immuneFlash = 0; float trauma = 0.7f; currentLives--; var shape = explosion.shape; var main = explosion.main; var emm = explosion.emission; shape.shapeType = ParticleSystemShapeType.Cone; shape.angle = 7.5f * (maxLives - currentLives); main.startSpeed = 15.0f; emm.rateOverTime = 250 * (maxLives - currentLives); hitSound.Play(); if (currentLives <= 0) { emm.rateOverTime = 2000; shape.shapeType = ParticleSystemShapeType.Sphere; main.startSpeed = 5.0f; emm = ps.emission; emm.enabled = false; main = ps.main; main.startSpeed = 0.0f; trauma = 0.9f; hyper = false; desiredFOV = baseFOV; Game.GameSpeed = 1.0f; StartCoroutine("CameraHyperdrive"); Game.GameOver(); //body.gameObject.transform.position = new Vector3(0, -2.5f, -15); ship.transform.rotation = Quaternion.Euler(0, 0, 0); ship.gameObject.GetComponent <MeshRenderer>().enabled = false; immune = false; deathSound.Play(); shipSound.volume = 0; } StartCoroutine(Explosion()); CameraShake shake = cam.gameObject.GetComponent <CameraShake>(); if (shake) { shake.AddTrauma(trauma); } }
public void GotHit(float hitForce, Vector3 position) { if (toughEnemy) { Vector2 hitDir = (transform.position - position).normalized; Vector2 facingDir = new Vector2(hitDir.x, hitDir.y); float angle = Mathf.Atan2(facingDir.y, facingDir.x) * Mathf.Rad2Deg; Quaternion quat = Quaternion.AngleAxis(angle, Vector3.forward); Quaternion quat2 = Quaternion.AngleAxis(angle + 80, Vector3.forward); if (!gfm.disableBlockStun) { //Blockstun blockStun = true; rb.velocity = new Vector2(0, rb.velocity.y); } if (!gfm.disableSoundEffects) { //SFX audioManager.Play("ToughEnemyHit"); } if (!gfm.disableParticles) { //VFX GameObject particles = Instantiate(slashParticles, transform.position + new Vector3(0, 0.5f, 0), quat); ParticleSystem hitParticles = particles.GetComponent <ParticleSystem>(); hitParticles.Play(); //VFX GameObject particle = Instantiate(slashParticles, transform.position + new Vector3(0, 0.5f, 0), quat2); ParticleSystem hitParticle = particle.GetComponent <ParticleSystem>(); //hitParticle.Play(); //VFX GameObject particles3 = Instantiate(gotHitParticles3, transform.position + new Vector3(0, 0.0f, 0), Quaternion.identity); ParticleSystem hitParticles3 = particles3.GetComponent <ParticleSystem>(); hitParticles3.Play(); //VFX GameObject particles2 = Instantiate(gotHitParticles2, transform.position + new Vector3(0, 0.0f, 0), Quaternion.identity); particles2.transform.parent = this.transform; ParticleSystem hitParticles2 = particles2.GetComponent <ParticleSystem>(); hitParticles2.Play(); } if (!gfm.disableScreenShake) { //Camera shake CameraShake.AddTrauma((hitForce) / 40); } } if (!toughEnemy) { Vector2 hitDir = (transform.position - position).normalized; Vector2 facingDir = new Vector2(hitDir.x, hitDir.y); float angle = Mathf.Atan2(facingDir.y, facingDir.x) * Mathf.Rad2Deg; Quaternion quat = Quaternion.AngleAxis(angle, Vector3.forward); Quaternion quat2 = Quaternion.AngleAxis(angle + 80, Vector3.forward); if (!gfm.disableBlockStun) { rb.velocity += new Vector2(10, 10); } if (!gfm.disableSoundEffects) { //SFX audioManager.Play("EnemySwordHit"); } if (!gfm.disableParticles) { //VFX GameObject particles = Instantiate(slashParticles, transform.position + new Vector3(0, 0.5f, 0), quat); ParticleSystem hitParticles = particles.GetComponent <ParticleSystem>(); hitParticles.Play(); //VFX GameObject particle = Instantiate(slashParticles, transform.position + new Vector3(0, 0.5f, 0), quat2); ParticleSystem hitParticle = particle.GetComponent <ParticleSystem>(); hitParticle.Play(); //VFX GameObject particles3 = Instantiate(gotHitParticles3, transform.position + new Vector3(0, 0.0f, 0), Quaternion.identity); ParticleSystem hitParticles3 = particles3.GetComponent <ParticleSystem>(); hitParticles3.Play(); //VFX GameObject particles2 = Instantiate(gotHitParticles2, transform.position + new Vector3(0, 0.0f, 0), Quaternion.identity); particles2.transform.parent = this.transform; ParticleSystem hitParticles2 = particles2.GetComponent <ParticleSystem>(); hitParticles2.Play(); } if (!gfm.disableScreenShake) { //Camera shake CameraShake.AddTrauma((hitForce) / 40); } } }