private void OnCollisionEnter2D(Collision2D col)
 {
     if (col.gameObject.CompareTag("Player"))
     {
         if (CheckMovement())
         {
             LifeInteraction interaction = col.gameObject.GetComponent <LifeInteraction>();
             print("FallingObject.cs - 충돌 발생 ");
             if (interaction != null)
             {
                 interaction.TakeHit(1);
             }
         }
     }
 }
Esempio n. 2
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (collisionTagName.Count == 0)
     {
         print("shoter.cs - 모두 충돌 발생 : selectedType");
         LifeInteraction interaction = col.gameObject.GetComponent <LifeInteraction>();
         if (interaction != null)
         {
             interaction.TakeHit(1);
         }
         transform.position = bulletStartingPoint;
         gameObject.SetActive(false);
     }
     else if (selectedType == 0 || selectedType == 3)
     {
         foreach (var v in collisionTagName)
         {
             if (col.CompareTag(v))
             {
                 LifeInteraction interaction = col.gameObject.GetComponent <LifeInteraction>();
                 print("shoter.cs - 충돌 발생 : selectedType");
                 if (selectedType == 0)
                 {
                     print("shoter.cs - shotkey : 0");
                     if (interaction != null)
                     {
                         interaction.TakeHit(1);
                     }
                     transform.position = bulletStartingPoint;
                     gameObject.SetActive(false);
                 }
                 else if (shoterMoveTrigger)
                 {
                     if (interaction != null)
                     {
                         interaction.TakeHit(1);
                     }
                 }
             }
         }
     }
 }
    private void OnCollisionEnter2D(Collision2D col)
    {
        if (!ballCollisionTrigger)
        {
            if (!col.gameObject.CompareTag("BOUNCEBALL"))
            {
                direction = GetReflectAngleVector2D(col, direction);
            }
        }
        else
        {
            direction = GetReflectAngleVector2D(col, direction);
        }

        if (tags.Count > 0)
        {
            foreach (var v in tags)
            {
                if (col.gameObject.CompareTag(v))
                {
                    LifeInteraction interaction = col.gameObject.GetComponent <LifeInteraction>();
                    if (interaction != null)
                    {
                        interaction.TakeHit(1);
                    }

                    if (disapperCollisionPlayer)
                    {
                        state = false;
                    }
                    else
                    {
                        if (!col.gameObject.CompareTag("Player"))
                        {
                            state = false;
                        }
                    }
                    break;
                }
            }
        }
    }