Esempio n. 1
0
    public void Attack(GameObject target)
    {
        int damage = playerStats.GetNextTapDamage();

        //Might want to move crit logic on to the player pawn since it makes more sense
        float critChance = playerStats.GetCriticalChance();
        bool  crit       = Random.Range(0, 100) < critChance;

        if (crit)
        {
            Debug.Log("Adding: " + damage * playerStats.GetCriticalDamage());
            damage += (int)(damage * playerStats.GetCriticalDamage());
        }
        int childIndex = -1;

        if (target.GetComponent <EnemyComponent>())
        {
            childIndex = target.GetComponent <EnemyComponent>().childIndex;
            pPawn.CmdAttack(target.GetComponent <EnemyComponent>().baseObject, childIndex, damage);
        }
        else
        {
            pPawn.CmdAttack(target, childIndex, damage);
        }

        dealtTapDamageEvent.Invoke(damage, target);
        float manaPerTap = GetComponent <PlayerStats>().GetTotalStatStruct().manaPerTap;

        GetPlayerPawn().GetComponent <Mana>().GainMana(manaPerTap);
    }