Пример #1
0
    protected virtual void OnCollisionWithPlayer()
    {
        float multiplier = 1;
        bool  critical   = false;

        float criticalValue = 100 * Random.value;

        if (criticalValue < (attacks[attackType].criticalChance))
        {
            critical    = true;
            multiplier *= 2;
        }
        float damage = playerScript.ReceiveDamage(CalculateDirection(player), attacks[attackType].damageForce, multiplier * attacks[attackType].damage, critical, attacks[attackType].attackElement, this);

        if (damage > 0)
        {
            DealDamageOnPlayer(damage);
        }
    }
Пример #2
0
    protected virtual void OnTriggerEnter2D(Collider2D colisor) //attack
    {
        if (colisor.GetComponent <Floor>() != null && colisor.gameObject != null)
        {
            ////print(("Floor");
            if (GetComponent <Rigidbody2D>() != null)
            {
                floorRotation = (int)colisor.GetComponent <Floor>().GetRotation(transform.position.x);

                GetComponent <Rigidbody2D>().velocity    = Vector2.zero;
                GetComponent <Rigidbody2D>().isKinematic = true;
            }
        }


        if (Utilities.HitAsderek(colisor))
        {
            Asderek enemy = colisor.gameObject.GetComponentInParent <Asderek>();

            float weakness = enemy.getDamageModifier(Commandments.Element.FIRE);

            enemy.ReceiveDamage(Utilities.standardVector(colisor.transform.position.x - transform.position.x), damageForce, attackDamage);
        }
    }