private void OnCollisionEnter(Collision collision) { Debug.Log("Collided with: " + collision.gameObject.tag); if (collision.gameObject.CompareTag("Enemy")) { collision.gameObject.GetComponent <Rigidbody>().AddForce(Player.transform.forward * RepelStrength, ForceMode.Force); Instantiate(enemyDamage, transform.position, Quaternion.identity); Ripple.Ripple(); manager.IncrementScore(); } if (collision.gameObject.CompareTag("Collectible")) { DestroyCollectible(collision.gameObject); manager.emTokens += 1; } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Bullet")) { health -= Time.deltaTime + decreaseFactor; if (health <= 0) { Instantiate(deathEffect, transform.position, Quaternion.identity); DestroyEnemy(); } else { Instantiate(hurtEffect, transform.position, Quaternion.identity); } } ripple.Ripple(); }
public void OnTriggerEnter(Collider other) { if (update.GameOver()) { return; } collisionClipWrong.mute = false; collisionClip.mute = false; collisionClip.volume = 1; collisionClipWrong.volume = 1; if (other.gameObject.CompareTag("Puzzle")) { Material puzzleMaterial = other.gameObject.GetComponent <Renderer>().material; Material myMaterial = gameObject.GetComponent <Renderer>().material; PuzzleMover mover = other.gameObject.GetComponent <PuzzleMover>(); if (puzzleMaterial.color != myMaterial.color) { wallLife -= 1; collisionClipWrong.Play(); Debug.Log("WallLife: " + wallLife); bar.UpdateBar(wallLife, maxWallLife); cameraShaker.ShakeOnce(magn, rough, fadeIn, fadeOut); if (wallLife <= 0) { DestroyWall(); } } if (puzzleMaterial.color == myMaterial.color) { collisionClip.Play(); update.UpdateScore(1); ripller.Ripple(); Debug.Log("Score: " + score); collisionClip.volume = 1; } Destroy(other.gameObject); } //collisionClipWrong.mute = true; //collisionClip.mute = true; }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("Bullet")) { health -= Time.deltaTime + decreaseFactor; if (health <= 0) { Instantiate(deathEffect, transform.position, Quaternion.identity); manager.updateScore(Random.Range(10, 101)); main.ShakeOnce(magn, rough, fadeIn, fadeOut); DestroyEnemy(); SpawnCollectable(); } else { Instantiate(hurtEffect, transform.position, Quaternion.identity); manager.updateScore(Random.Range(10, 51)); } Kills.text = manager.Score.ToString(); } ripple.Ripple(); }