Exemple #1
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (chara.dashing == true)
     {
         if (collision.gameObject.tag == "LRBreak" && dashDirection.Equals("leftRight"))
         {
             Destroy(collision.gameObject);
         }
         else if (collision.gameObject.tag == "UpBreak" && dashDirection.Equals("up"))
         {
             Destroy(collision.gameObject);
         }
         else if (collision.gameObject.tag == "DownBreak" && dashDirection.Equals("down"))
         {
             Destroy(collision.gameObject);
         }
         else if (collision.gameObject.tag == "break")
         {
             //Destroy(collision.gameObject);
         }
     }
     else if (collision.gameObject.tag == "break")
     {
         chara.PlayerDamage();
     }
 }
Exemple #2
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "Player")
     {
         if (player.dashing)
         {
             if (health == 1)
             {
                 Debug.Log("Destoying this object");
                 Destroy(this.gameObject);
             }
             else
             {
                 StartCoroutine("Damage");
             }
         }
         else
         {
             player.PlayerDamage();
             Debug.Log("Damage");
             //StartCoroutine(Respawn());
             if (sr.flipX && !(this.gameObject.name.Contains("boss")))
             {
                 sr.flipX   = false;
                 enem.speed = -enem.speed;
             }
             else if (!(this.gameObject.name.Contains("boss")))
             {
                 sr.flipX   = true;
                 enem.speed = -enem.speed;
             }
         }
     }
 }
Exemple #3
0
  public void OnTriggerEnter(Collider col)
  {
      if (col.gameObject.CompareTag("bullet"))                                                             //check object colliding in tag player
      {
          GameObject explosionprefab = Instantiate(explosion, col.transform.position, transform.rotation); // instantieate a particle system
          Destroy(explosionprefab, 3f);                                                                    //destroy particle

          Destroy(col.gameObject);                                                                         //destroy bullet
          lifeEnemy--;

          if (lifeEnemy <= 0)
          {
              lifeEnemy = 0;
              type      = typeEnemy.dead;
          }
      }

      if (col.gameObject.CompareTag("Player"))
      {
          type = typeEnemy.dead;
          PlayerScript.PlayerDamage();
      }
  }