Example #1
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag == "DeathZone")
     {
         SoundManager.managerSound.MakeDeathSound();
         CameraShaker.Instance.ShakeOnce(1f, 1f, 0.1f, 1f);
         TimeToDie();
     }
     else if (collision.gameObject.tag == "Wall")
     {
         BreakableWalls wall = collision.gameObject.GetComponent <BreakableWalls>();
         if (IsKnocked())
         {
             wall.TakeDamage();
             controller.mainPlayer.SetVibration(motorIndex, motorLevel, duration);
         }
         HittingWall();
     }
     else if (collision.gameObject.tag == "Pillar")
     {
         HittingWall();
     }
     else if (collision.gameObject.tag == "Pickable" && !collision.gameObject.GetComponent <PickupableObject>().isPickable)
     {
         SoundManager.managerSound.MakeHitSound();
     }
     else if (collision.gameObject.CompareTag("Player") && isKnocked && !_isPlayerRepulsed)
     {
         PlayerEntity otherPlayer = collision.gameObject.GetComponent <PlayerEntity>();
         otherPlayer.Knockback(speed.normalized, speed.magnitude);
         HittingWall();
         otherPlayer._isPlayerRepulsed = true;
         _isPlayerRepulsed             = true;
     }
 }
Example #2
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.CompareTag("Player") && isThrown)
     {
         if (hitParticle != null)
         {
             GameObject _instance = Instantiate(hitParticle, transform.position, Quaternion.identity);
             Destroy(_instance, 2f);
         }
         SoundManager.managerSound.MakeHitSound();
         collision.gameObject.GetComponent <PlayerEntity>().Knockback(orient, powerKnock);
         GameManager.managerGame.SpawnObject();
         ClearPlayer();
         Destroy(gameObject);
     }
     else if (collision.gameObject.CompareTag("Pillar") || collision.gameObject.CompareTag("Canon"))
     {
         if (hitParticle != null)
         {
             GameObject _instance = Instantiate(hitParticle, transform.position, Quaternion.identity);
             Destroy(_instance, 2f);
         }
         SoundManager.managerSound.MakeItemBreakSound();
         GameManager.managerGame.SpawnObject();
         ClearPlayer();
         Destroy(gameObject);
     }
     else if (collision.gameObject.CompareTag("Wall") && isThrown)
     {
         GameManager.managerGame.SpawnObject();
         BreakableWalls wall = collision.gameObject.GetComponent <BreakableWalls>();
         wall.TakeDamage();
         ClearPlayer();
         Destroy(gameObject);
     }
     else if (collision.gameObject.CompareTag("Barrel") && isThrown)
     {
         if (hitParticle != null)
         {
             GameObject _instance = Instantiate(hitParticle, transform.position, Quaternion.identity);
             Destroy(_instance, 2f);
         }
         GameManager.managerGame.SpawnObject();
         _rigidbody.velocity = Vector3.zero;
         velocity            = Vector2.zero;
         ClearPlayer();
         Destroy(gameObject);
     }
     else if (collision.gameObject.CompareTag("DeathZone"))
     {
         GameManager.managerGame.SpawnObject();
         ClearPlayer();
         Destroy(gameObject);
     }
     else if (collision.gameObject.CompareTag("Pickable"))
     {
         isThrown            = false;
         _rigidbody.velocity = Vector3.zero;
         velocity            = Vector2.zero;
         collision.gameObject.GetComponent <PickupableObject>().Throw(orient);
         GetComponent <SphereCollider>().enabled = true;
         isPickable = true;
     }
     else if (collision.gameObject.CompareTag("Ground") && isThrown)
     {
         if (hitParticle != null)
         {
             GameObject _instance = Instantiate(hitParticle, transform.position, Quaternion.identity);
             Destroy(_instance, 2f);
         }
         SoundManager.managerSound.MakeItemBreakSound();
         GameManager.managerGame.SpawnObject();
         ClearPlayer();
         Destroy(gameObject);
     }
 }