Example #1
0
    public void Attack(int amount, Vector2 force)
    {
        Assert.IsNotNull(body);

        flashing = true;
        sp.color = new Color(255.0f, 255.0f, 255.0f, minOpacity);

        hp -= amount;
        if (hp < 1 && !dead)
        {
            dead = true;

            ParticleDropper drop = GetComponent <ParticleDropper>();
            if (drop != null)
            {
                drop.CreateParticles(transform.position,
                                     Random.Range(4, 7));
            }
            // Destroy( gameObject );
            DestroyThis();
        }
        else if (willKnockback)
        {
            body.AddForce(force * forceOffset,
                          ForceMode2D.Impulse);
        }
    }
    public void Attack(int amount, Vector2 force)
    {
        Assert.IsNotNull(body);

        hp -= amount;
        if (hp < 1 && !dead)
        {
            dead = true;

            ParticleDropper drop = GetComponent <ParticleDropper>();
            if (drop != null)
            {
                drop.CreateParticles(transform.position,
                                     Random.Range(4, 7));
            }
            Destroy(gameObject);
        }
        else if (willKnockback)
        {
            body.AddForce(force, ForceMode2D.Impulse);
        }
    }