示例#1
0
    public void Explosion(int dmg, PlayerCharacter2D pl, float fireRate)
    {
        if (CanAttack)
        {
            if (effetAttaquePrefab != null)
            {
                Transform      clone = Instantiate(effetAttaquePrefab, firePoint.position, firePoint.rotation) as Transform;
                ShockWaveForce wave  = clone.GetComponent <ShockWaveForce>();
                wave.radius = statAttaque.eRadius * 1.3f;

                Destroy(clone.gameObject, 1f);
            }

            attaqueCooldown = fireRate;

            if (Rigidbody2DExt.AddExplosionForce(pl.GetComponent <Rigidbody2D>(), statAttaque.ePower, firePoint.position, statAttaque.eRadius, statAttaque.upwardsModifier))
            {
                pl.DommagePerso(dmg);
            }
        }
    }
示例#2
0
    public void Contact(int dmg, PlayerCharacter2D pl, float f)
    {
        //Rigidbody2DExt.AddExplosionForce(pl.GetComponent<Rigidbody2D>(), f, firePoint.position, r, upM, ForceMode2D.Force);
        var dir = my_transform.position - pl.transform.position;
        //Debug.Log(dir);
        Vector3 baseForce = -dir.normalized * f;

        baseForce.x *= 2f;
        //baseForce.x += Mathf.Sign(baseForce.x)*10f;

        if (dir.y > -0.9f && dir.y < 0.9f)
        {
            Vector2 upp = Vector2.up * 10f;
            pl.GetComponent <Rigidbody2D>().AddForce(upp, ForceMode2D.Impulse);
            baseForce.y = 0;
        }

        //Debug.Log(baseForce);
        pl.GetComponent <Rigidbody2D>().AddForce(baseForce);
        pl.DommagePerso(dmg);
    }