Exemplo n.º 1
0
    protected virtual void OnTriggerEnter2D(Collider2D other)
    {
        GameObject go = other.gameObject;

        if (noHit != (noHit | (1 << go.layer)))
        {
            /*if(go.layer == 15)
             * {
             *  Debug.Log("Ricoche dans trigger");
             *  return;
             * }*/

            //if (statAttaque.ePower == 0 || statAttaque.eRadius == 0) {
            if (dommageHit == (dommageHit | (1 << go.gameObject.layer)))
            {
                Personnages en = go.GetComponent <Personnages>() as Personnages;
                en.DommagePerso(dmg);
            }
            //}else if
            if (myTransform != null)
            {
                Collider2D[] colliders = Physics2D.OverlapCircleAll(myTransform.position, statAttaque.eRadius, dommageHit);
                foreach (Collider2D nerbyObject in colliders)
                {
                    if (dommageHit == (dommageHit | (1 << nerbyObject.gameObject.layer)))
                    {
                        if (Rigidbody2DExt.AddExplosionForce(nerbyObject.GetComponent <Rigidbody2D>(), statAttaque.ePower, myTransform.position, statAttaque.eRadius, statAttaque.upwardsModifier))
                        {
                            // if (nerbyObject == other)
                            // continue;

                            Personnages en = nerbyObject.GetComponent <Personnages>() as Personnages;
                            en.DommagePerso(dmg);
                        }
                    }
                }

                if (effetExplosion != null && statAttaque.eRadius != 0)
                {
                    Transform      clone = Instantiate(effetExplosion, myTransform.position, myTransform.rotation) as Transform;
                    ShockWaveForce wave  = clone.GetComponent <ShockWaveForce>();
                    wave.radius = statAttaque.eRadius * 1.3f;
                    Destroy(clone.gameObject, 1f);
                }
            }

            if (effetContact != null && myTransform != null)
            {
                Transform clone = Instantiate(effetContact, myTransform.position, myTransform.rotation) as Transform;
                Destroy(clone.gameObject, 1f);
            }
            Destroy(gameObject);
        }
    }
Exemplo n.º 2
0
    //  si le joueur est détecter, l'écrase et lui fait des DMG
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            GameObject coll = collision.gameObject;

            if (dommageHit == (dommageHit | (1 << coll.layer)))
            {
                Personnages en = coll.GetComponent <Personnages>() as Personnages;
                en.DommagePerso(m_dmg);
            }
        }
    }
Exemplo n.º 3
0
    //  si le joueur est détecter, l'écrase et lui fait des DMG
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            GameObject coll = collision.gameObject;

            if (m_getScale == false)
            {
                m_ScaleY   = coll.transform.lossyScale.y;
                m_getScale = true;
            }

            if (dommageHit == (dommageHit | (1 << coll.layer)))
            {
                Personnages en = coll.GetComponent <Personnages>() as Personnages;
                en.DommagePerso(m_dmg);
            }

            if (m_descend == false)
            {
                //  désactive les controle
                PlayerCharacter2D p = coll.GetComponent <PlayerCharacter2D>();

                Rigidbody2D rbp = coll.GetComponent <Rigidbody2D>() as Rigidbody2D;
                rbp.collisionDetectionMode = CollisionDetectionMode2D.Discrete;

                if (p)
                {
                    p.setEnableInput(false);
                }

                //  rapetisse le joueur
                Sequence ecrase = DOTween.Sequence();

                ecrase.Append(coll.transform.DOScaleY(1.0f, 0.2f));
                ecrase.Insert(0.0f, coll.transform.DOMoveY(coll.transform.position.y - 0.4f, 0.2f));
                ecrase.Play();
            }
        }
    }