Пример #1
0
    public static void calculateDirectionForce(Entity target, ThrowableItem it)
    {
        target.receiveDamage(it.getDamage());
        Rigidbody2D trbd          = target.GetComponent <Rigidbody2D>();
        Rigidbody2D itrbd         = it.GetComponent <Rigidbody2D>();
        float       lostLife      = target.getMaxLife() - target.getLife();
        float       itemknockBack = calculateKnockBack(lostLife, it.getDamage(), itrbd.mass, it.getKnockBack());

        switch (it.getDirection())
        {
        case Utilities.direction.Up: trbd.AddForce(new Vector2(0f, itemknockBack * 1.5f), ForceMode2D.Impulse); break;

        case Utilities.direction.Down: trbd.AddForce(new Vector2(0f, -itemknockBack), ForceMode2D.Impulse); break;

        case Utilities.direction.Left: trbd.AddForce(new Vector2(-itemknockBack, itemknockBack), ForceMode2D.Impulse); break;

        case Utilities.direction.Right: trbd.AddForce(new Vector2(itemknockBack, itemknockBack), ForceMode2D.Impulse); break;

        case Utilities.direction.UpLeft: trbd.AddForce(new Vector2(-itemknockBack, itemknockBack * 1.5f), ForceMode2D.Impulse); break;

        case Utilities.direction.UpRight: trbd.AddForce(new Vector2(itemknockBack, itemknockBack * 1.5f), ForceMode2D.Impulse); break;

        case Utilities.direction.DownLeft: trbd.AddForce(new Vector2(-itemknockBack, -itemknockBack), ForceMode2D.Impulse); break;

        case Utilities.direction.DownRight: trbd.AddForce(new Vector2(itemknockBack, -itemknockBack), ForceMode2D.Impulse); break;
        }

        target.StartCoroutine(target.hitStun(itemknockBack));
    }
Пример #2
0
    void Hurl(int number)
    {
        throwFan.SetActive(false);
        slowDownTime = false;
        goingUp      = false; // Start falling if was mid-jump
        hasThrown    = true;

        currentItem.GetThrown();

        float forward = Mathf.Cos((number - 1) * 10 * Mathf.Deg2Rad);
        float up      = Mathf.Sin(number * 10 * Mathf.Deg2Rad);

        ThrowMe(currentItem.GetComponent <Rigidbody>(), forward * currentItem.forwardForceMult, up * currentItem.upwardForceMult);

        currentSpeed   = 0;
        selectedNumber = -1;
    }