Beispiel #1
0
    public void Attack(GameObject victim)
    {
        attackerStats = owner.GetComponent <FighterStats>();
        targetStats   = victim.GetComponent <FighterStats>();

        if (magicAttack && attackerStats.magic < magicCost)
        {
            Invoke("SkipTurnContinueGame", 2);
        }
        else
        {
            float multiplier = Random.Range(minAttackMultiplier, maxAttackMultiplier);

            if (attackerStats.magic >= magicCost && magicAttack)
            {
                if (magicCost > 0)
                {
                    attackerStats.updateMagicFill(magicCost);
                }
                damage = multiplier * attackerStats.magicRange;
            }
            else
            {
                damage = multiplier * attackerStats.melee;
            }

            float defenseMultiplier = Random.Range(minDefenseMultiplier, maxDefenseMultiplier);
            damage = Mathf.Max(0, damage - (defenseMultiplier * targetStats.defense));
            owner.GetComponent <Animator>().Play(animationName);
            targetStats.ReceiveDamage(Mathf.CeilToInt(damage));
        }
    }
Beispiel #2
0
    public void Attack(GameObject victim)
    {
        attackerStats = owner.GetComponent <FighterStats>();
        targetStats   = victim.GetComponent <FighterStats>();

        if (attackerStats.magic >= magicCost)
        {
            float multiplier = Random.Range(minAttackMultiplier, maxAttackMultiplier);

            damage = multiplier * attackerStats.melee;
            if (magicAttack)
            {
                damage = multiplier * attackerStats.magicRange;
            }

            float defenseMultiplier = Random.Range(minDefenseMultiplier, maxDefenseMultiplier);
            damage = Mathf.Max(0, damage - (defenseMultiplier * targetStats.defense));
            owner.GetComponent <Animator>().Play(animationName);
            targetStats.ReceiveDamage(Mathf.CeilToInt(damage));
            attackerStats.UpdateMagicFill(magicCost);
        }
        else
        {
            Task.Delay(2000);
            Debug.Log("Turn skipped");
            attackerStats.ContinueGame();
        }
    }
Beispiel #3
0
    public void Attack(GameObject victim)
    {
        attackerStats = owner.GetComponent <FighterStats>();
        targetStats   = victim.GetComponent <FighterStats>();

        if (attackerStats.magic >= magicCost)
        {
            float multiplier = Random.Range(minAttackMultiplier, maxAttackMultiplier);

            damage = multiplier * attackerStats.attack;
            if (magicAttack)
            {
                damage = multiplier * attackerStats.intelligence;
            }

            float defenseMultiplier = Random.Range(minDefenseMultiplier, maxDefenseMultiplier);
            damage = targetStats.block - Mathf.Max(0, damage - (defenseMultiplier * targetStats.defense));
            if (damage < 0)
            {
                damage = 0;
            }
            owner.GetComponent <Animator>().Play(animationName);
            targetStats.ReceiveDamage(Mathf.CeilToInt(damage));
            attackerStats.UpdateMagicFill(magicCost);
        }
        else
        {
            Invoke("SkipTurnContinueGame", 2);
        }
    }