예제 #1
0
    void ExecuteAttack(Alive a, bool ignoreCooldown, bool ignoreSlow = false, int customDamage = 0)
    {
        if (!ignoreCooldown && actCoolDown != 0)
        {
            return;
        }

        if (!ignoreCooldown)
        {
            ApplyCooldown();
        }
        if (!ignoreSlow)
        {
            ApplySlow();
        }

        bool received = a.TakeDamage(customDamage == 0 ? Damage : customDamage, this.gameObject);

        if (a.TryGetComponent <Motor>(out Motor m) && received)
        {
            float   height    = m.WallColliderSize.y / 2;
            Vector2 playerPos = (Vector2)a.transform.position + new Vector2(0, height);

            Vector2 direction = ((Vector2)transform.position - playerPos).normalized * -1;
            direction += new Vector2(0, 0.5f);

            Force f = new Force(pushForce);
            f.ForceApplied = direction * pushForce.ForceToApply;
            f.ActualForce  = direction * pushForce.ForceToApply;

            m.AddForce(f, false, true, true);
        }
    }