private void Die() { myBody.enabled = !myBody.enabled; myFeet.enabled = !myFeet.enabled; switch (name) { case "Large Enemy": DeathAnim(); SpawnChildren(enemyMediumPreFab); myGameSession.AddScore(100); hasSpawned = true; break; case "Medium Enemy": DeathAnim(); SpawnChildren(enemySmallPreFab); myGameSession.AddScore(50); hasSpawned = true; break; case "Small Enemy": DeathAnim(); myGameSession.AddScore(10); break; } }
private void DestroyBlock() { AudioSource.PlayClipAtPoint(breakSound, transform.position); Destroy(gameObject); level.BlockDestroyed(); session.AddScore(); }
private void ProcessHit(DamageDealer damageDealer) { health -= damageDealer.GetDamage(); damageDealer.Hit(); if (health <= 0) { //death logic GameSession gameSession = FindObjectOfType <GameSession>(); if (gameSession) { gameSession.AddScore(score); //Sum the Score gameSession.killOneEnemy(); //game recognize that a enemy died } //deathVFX GameObject deathParticles = Instantiate( deathVFX, transform.position, Quaternion.identity ) as GameObject; //deathSFX AudioSource.PlayClipAtPoint(deathSFX, Camera.main.transform.position, deathSFXVolume); //death Destroy Objects Destroy(deathParticles, 1f); Destroy(gameObject); } }
private void DestroyBlock() { PlaySFX(); Destroy(gameObject); TriggerSparklesVFX(); level.RemoveBlock(); gameSession.AddScore(); }
private void DestroyBlock() { AudioSource.PlayClipAtPoint(destroySound, Camera.main.transform.position, 0.2f); Destroy(gameObject); level.BlockDestroyed(); gamestatus.AddScore(); TriggerParticlesVFX(); }
private void Die() { PlayDeathVFX(); PlayDeathSFX(); gameSession.AddScore(scoreValue); Destroy(gameObject); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.GetComponent <Player>()) { AudioSource.PlayClipAtPoint(pickUpSFX, Camera.main.transform.position); gameSessionController.AddScore(scorePoints); Destroy(gameObject); } }
private void Die() { gameSession.AddScore(scoreValue); GameObject explosion = Instantiate(explosionVFX, transform.position, Quaternion.identity); Destroy(explosion, 1f); Destroy(gameObject); AudioSource.PlayClipAtPoint(deathSFX, Camera.main.transform.position, deathSoundVolume); }
private void Die() { if (gameSession != null) { gameSession.AddScore(pointsUponDeath); } Destroy(gameObject); AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathSoundVolume); }
private void Die() { Destroy(gameObject); var explosionParticle = Instantiate(explosionVFX, transform.position, Quaternion.identity); Destroy(explosionParticle, durationOfExplosion); myGameSession.AddScore(); AudioSource.PlayClipAtPoint(deathSFX, Camera.main.transform.position, deathSoundVolume); }
// Quando inimigo "morre" private void Die() { gameSession.AddScore(scoreValue); Destroy(gameObject); GameObject explosionEffect = Instantiate(deathVFX, transform.position, transform.rotation) as GameObject; Destroy(explosionEffect, durationOfExplosion); AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathSoundVolume); }
private void Die() { AudioSource.PlayClipAtPoint(enemyDieSound, transform.position); GameObject explosion = Instantiate(explosionParticle, transform.position, Quaternion.identity) as GameObject; Destroy(gameObject); Destroy(explosion, durationOfExplosion); gameSession.AddScore(scoreValue); }
// Update is called once per frame void Update() { timer += Time.deltaTime; if (timer > 0.5f && FindObjectOfType <Player>() != null) { gameSession.AddScore(1); scoreDisplay.text = gameSession.GetScore().ToString(); timer = 0; } }
private void addScore() { if (gameSession) { gameSession.AddScore(damageSprites.Length + 1); } else if (!gameSession) { print("Brick/addScore: no gameSession Found"); } }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.gameObject.layer == 8) { var sfxIndex = Random.Range(0, sFXArray.Length); AudioSource.PlayClipAtPoint(sFXArray[sfxIndex], Camera.main.transform.position, sFXVolume); gameSession = FindObjectOfType <GameSession>(); gameSession.AddScore(diamondValue); Destroy(gameObject); TriggerDiamondDeath(); } }
private void Die() { GameSession gs = FindObjectOfType <GameSession>(); gs.AddScore(scoreValue); Destroy(gameObject); GameObject explosion = Instantiate(deathVFX, transform.position, transform.rotation); Destroy(explosion, durationOfExplosion); AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position, deathVolume); gs.AddDeadEnemy(); }
private void Die() { gameSession.AddToKilledEnemies(); gameSession.AddScore(scoreValue); Destroy(gameObject); GameObject explosion = Instantiate(explosionVFX, transform.position, transform.rotation); Destroy(explosion, 0.7f); if (UnityEngine.Random.Range(1, 12) == 6) { RespawnBonus(); } AudioSource.PlayClipAtPoint(dieSound, Camera.main.transform.position, dieSoundVolume); }
private void DestructSelf() { GameObject explotion = Instantiate(deathExplosion, transform.position, Quaternion.identity) as GameObject; Destroy(explotion, 1f); GameSession gameSession = FindObjectOfType <GameSession>(); if (gameSession) { gameSession.AddScore(pointsObtainedAtKill); } AudioSource.PlayClipAtPoint(deathAudioClip, Camera.main.transform.position, deathAudioVolume); FindObjectOfType <CameraShaker>().StartShake(deathShakeduration); Destroy(gameObject); }
void OnTriggerEnter2D(Collider2D col) { if (col.CompareTag("mainball")) { gameSession.AddScore((DestinationIndex != 0)?0:1); if (this.gameObject.name.Contains("Super")) { GameObject.Instantiate(FlashFire, this.transform.position, Quaternion.identity); } ballController = col.GetComponent <BallController>(); mfa = col.GetComponent <MoveForwardAuto>(); mfa.IsMoving = true; ballController.ResetBallSize(); ballController.enabled = false; } }
public void Die() { isDead = true; health = 0; if (healthBar != null) { healthBar.UpdateHealthBar(health); } // different character types might have different components // first check them if they null or not, then disable if (GetComponent <BoxCollider2D>() != null) { GetComponent <BoxCollider2D>().enabled = false; } if (GetComponent <PolygonCollider2D>() != null) { GetComponent <PolygonCollider2D>().enabled = false; } if (GetComponent <CapsuleCollider2D>() != null) { GetComponent <CapsuleCollider2D>().enabled = false; } if (GetComponent <EnemyAI>() != null) { audioManager.PlaySound("enemyDie"); gameSession.AddScore(GetComponent <EnemyStats>().GetPoints()); GetComponent <EnemyAI>().enabled = false; } if (GetComponent <PlayerControl>() != null) { audioManager.PlaySound("playerDie"); GetComponent <PlayerControl>().enabled = false; StartCoroutine(gameSession.LoadGameOverScreen()); } if (hasDeathForce) { GetComponent <Rigidbody2D>().velocity = deathForce; } GetComponent <Animator>().SetTrigger("die"); }
private void OnTriggerEnter2D(Collider2D collision) { // Piranha plant and projectile if (collision.gameObject.tag == "Enemy" && readyForCollision) { TakeDamageBehaviour(); } if (collision.gameObject.tag == "Pickup") { audioManager.PlaySound("pickup"); gameSession.AddScore(collision.gameObject.GetComponent <Pickup>().GetScore()); Destroy(collision.gameObject); } if (collision.gameObject.tag == "Bottom") { GetComponent <Health>().Die(); } }
private void OnTriggerEnter2D(Collider2D collision) { DamageDealer damageDealer = collision.gameObject.GetComponent <DamageDealer>(); if (damageDealer && !damageDealer.GetAttackPlayer()) { healt -= damageDealer.GetDamage(); if (healt <= 0) { //Particle animation Destroy(gameObject); GameObject expolision = Instantiate(deathVFX, transform.position, transform.rotation); AudioSource.PlayClipAtPoint(deathSound, Camera.main.transform.position); gameSession.AddScore(score); Destroy(expolision, 1f); } damageDealer.Hit(); } }
void OnCollisionEnter2D(Collision2D collision) { SpriteRenderer sr = collision.transform.GetComponent <SpriteRenderer>(); if (!sr) { return; } if (collision.transform.GetComponent <SpriteRenderer>().color == currentColor) { AudioSource.PlayClipAtPoint(destroySfx, Camera.main.transform.position, destroySfxVolume); gameSession.AddScore((int)collision.relativeVelocity.magnitude); gameSession.DecreaseAmountOfBreakablesLeft(1); screenShake.StartShaking(collision); StartCoroutine(SpawnDeathEffect(collision.transform.GetComponent <SpriteRenderer>())); collision.gameObject.SetActive(false); Vector2 direction = rb.velocity; direction.Normalize(); direction *= rb.velocity.magnitude / 2; rb.AddForce(direction); } else { float radiants = 0; while (radiants == 0) { radiants = Random.Range(0, 2 * Mathf.PI); } Vector2 direction = new Vector2(Mathf.Cos(radiants), Mathf.Sin(radiants)); direction.Normalize(); direction *= rb.velocity.magnitude / 2; rb.AddForce(direction); } }
private void OnCollisionEnter2D(Collision2D collision) { if (CompareTag("Breakable")) { timeHit++; if (timeHit >= maxHit) { level.RemoveBlock(); gameStatus.AddScore(); AudioSource.PlayClipAtPoint(breakAudio, Camera.main.transform.position); Destroy(gameObject); GameObject newParticleVFX = Instantiate(myPrefab, transform.position, Quaternion.identity); Destroy(newParticleVFX, 1); } else { GetComponent <SpriteRenderer>().sprite = sprites[timeHit - 1]; } } /*hitNumber += 1; * //Debug.Log(GetComponent<SpriteRenderer>().color = Color.gray); * //gameObject.SetActive(false); * if (hitNumber > 2) * { * Destroy(gameObject); * } else * { * if(hitNumber == 1) * { * GetComponent<SpriteRenderer>().sprite = broken1; * } else if (hitNumber == 2) * { * GetComponent<SpriteRenderer>().sprite = broken2; * } * }*/ }
public void TakeHit() { gameSession.AddScore(scoreValue); AudioSource.PlayClipAtPoint(deathSfx, Camera.main.transform.position, deathSfxVolume); Destroy(gameObject); }
private void AddToScore() { _currentGame.AddScore(_score); }