Пример #1
0
    void GiveSpellDamage(int attackNumber)
    {
        this.attackNumber[curSpellTitle] = attackNumber;
        attackNumber--;
        GameObject  _inst;
        int         _targetLayer = 12;
        PlayerSpell _spell       = curSpell.spell;
        Vector2     _boxPosition = Vector2.zero;

        switch (curSpell.spell.useType)
        {
        case SpellUseTypes.Single:
            Invoke("NextAnimation", _spell.timeBtwAttack[attackNumber]);     // Start next attack after delay
            break;

        case SpellUseTypes.Charging:
            chargingDamageMultiplier = chargingDamageMultiplier > 0f ? chargingDamageMultiplier : 1f;
            Invoke("NextAnimation", _spell.timeBtwAttack[attackNumber]);     // Start next attack after delay
            break;

        case SpellUseTypes.Multiuse:
            StartCoroutine(TimeToNextUseSpell(curSpellTitle, curSpell.spell.timeToUse));
            Invoke("SetSpellToWaitingState", _spell.timeBtwAttack[attackNumber]);
            break;
        }

        switch (_spell.type)
        {
        case SpellTypes.Melee:
            _boxPosition = attack.weapon.position;
            _inst        = Instantiate(attack.damageBox, transform);
            DamageBox _damageBox = _inst.GetComponent <DamageBox>();
            _damageBox.GetParameters(_spell.damage[attackNumber], _spell.damageType[attackNumber], _spell.element, _boxPosition, _spell.damageRange[attackNumber], _spell.timeBtwAttack[attackNumber], _spell.audioImpact, _targetLayer, attributes, true);
            break;

        case SpellTypes.MeleeAOE:
            _boxPosition = myTransform.position;
            _inst        = Instantiate(_spell.spellPrefab, _boxPosition, _spell.spellPrefab.transform.rotation, myTransform);
            _inst.GetComponent <SpellDamageAOE>().SetParameters(_spell, curSpellTitle, attackNumber);
            break;

        case SpellTypes.Range:
            _boxPosition = attack.weapon.position;
            curSpell.GiveSpellDamage(this, _boxPosition);
            break;

        case SpellTypes.RangeAOE:
            _boxPosition = new Vector2(attack.weapon.position.x + _spell.castDistance[attackNumber], attack.weapon.position.y);
            break;
        }
    }
Пример #2
0
    void GiveDamage()
    {
        if (!movement.isAttacking)
        {
            return;
        }

        attackState         = AttackState.Damage;
        movement.canFlip    = false;
        curDelayResetCombo  = Time.time + delayResetCombo;
        curForceDurtaion    = Time.time + forceDuration;
        attributes.Stamina -= staminaCosts;

        if (weaponAttackType != WeaponAttackType.Melee)
        {
            shellObj = Instantiate(shellPrefab, transform.position, Quaternion.Euler(0f, 0f, rotZ));
            shell    = shellObj.GetComponent <Shell>();
            shell.SetParameters(damage, weaponDamageType, weaponElement, shellSpeed, shellFlyTime, weaponImpactClip);
        }
        else
        {
            if (attackType == AttackTypes.TopDown)
            {
                rigidBody.AddForce(Vector2.up * -attackForceDistance, ForceMode2D.Impulse);
            }
            else
            {
                rigidBody.AddForce(Vector2.right * movement.direction * attackForceDistance, ForceMode2D.Impulse);
            }

            GameObject _inst       = Instantiate(damageBox, transform);
            DamageBox  _damageBox  = _inst.GetComponent <DamageBox>();
            int        targetLayer = 12;
            _damageBox.GetParameters(damage, weaponDamageType, weaponElement, weapon.position, new Vector2(attackRangeX, attackRangeY), attackDuration - Time.time, weaponImpactClip, targetLayer, attributes);
        }

        AudioManager.PlayAttackAudio(weaponAudioClip);
    }