Ejemplo n.º 1
0
    public void OnCollisionEnter2D(Collision2D collision)
    {
        Stunnable stunnable = collision.collider.GetComponentInParent <Stunnable>();

        if (stunnable != null && (firstCollision || rigid.velocity.magnitude > stunVelocity))
        {
            stunnable.Stun(stunTime);
        }
        firstCollision = false;
    }
Ejemplo n.º 2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        GameObject     enemyPlayer         = collision.gameObject;
        PlayerMovement enemyPlayerMovement = enemyPlayer.GetComponent <PlayerMovement>();

        if (enemyPlayerMovement && enemyPlayerMovement.IsFalling() && enemyPlayer.layer != transform.parent.gameObject.layer)
        {
            if (stunControl.Stun())
            {
                enemyPlayerMovement.Bounce();
            }
        }
    }
Ejemplo n.º 3
0
    void OnTriggerStay2D(Collider2D other)
    {
        Rigidbody2D r = other.GetComponent <Rigidbody2D>();

        if (r != null)
        {
            r.AddForce(force * (transform.position - r.transform.position).normalized, ForceMode2D.Force);
            if (stun)
            {
                Stunnable s = r.GetComponent <Stunnable>();
                if (s != null)
                {
                    s.Stun(0.1f);
                }
            }
        }
    }
Ejemplo n.º 4
0
    public void OnTriggerStay2D(Collider2D other)
    {
        Rigidbody2D r = other.GetComponentInParent <Rigidbody2D>();

        if (r != null && !r.isKinematic)
        {
            float dis = Vector2.Distance(transform.position, r.transform.position);
            if (dis > range)
            {
                return;
            }

            r.AddForce(transform.right * pushForce * (1f - (dis / range)), ForceMode2D.Force);

            if (dis < range / 2f)
            {
                Stunnable stunnable = r.GetComponent <Stunnable>();
                if (stunnable != null)
                {
                    stunnable.Stun(0.3f);
                }
            }
        }
    }