public void Take_damage(int damage, Ability attack_stats, float score)
    {
        damage = CheckElementalEffects(attack_stats, damage);
        switch (attack_stats._typ)
        {
        case ability_typ.physical:
            damage -= ApplyScore(defence, score);
            break;

        case ability_typ.magical:
            damage -= ApplyScore(resistance, score);
            break;

        default:

            break;
        }



        if (Effects.Check_for_effect(attack_stats.effect_array, effects.absorb) != null)
        {
            var effect_stats = Effects.Check_for_effect(attack_stats.effect_array, effects.absorb);
            attack_stats.GetUser().Heal(Effects.Absorb(damage, effect_stats.value1));
        }

        if (damage > 0)
        {
            GetComponent <CharacterAnimation>().Take_Damage();
        }
        showDamageNumber(damage);
        hp -= Mathf.Max(0, damage);
        if (hp <= 0)
        {
            if (CheckForPassiv(passiveSkill.Phenix) && !phenix_used)
            {
                phenix_used = true;
                mp          = Mathf.Max(0, mp - 10);
                hp          = 0;
                Heal(hp_max / 2, false);
            }
            else
            {
                Debug.Log("plea ded");
                FindObjectOfType <SceneTransitioner>().LoadGameFile();
                shaker.ShakeCam(shake.extrem);
            }
        }
        else if (damage > 0)
        {
            shaker.ShakeCam(shake.medium);
        }

        UI.UpdateSlider();
    }
    public void Player_move(float score, bool typos_made, Ability ability)
    {
        int power          = 0;
        int playerStrenght = player.strenght;

        if (player.CheckForPassiv(passiveSkill.rage) && player.hp * 2 <= player.hp_max)
        {
            playerStrenght += playerStrenght;
        }

        if (player.CheckForPassiv(passiveSkill.itemBoost) && !typos_made && (ability._typ == ability_typ.item_heal || ability._typ == ability_typ.mp_heal))
        {
            Debug.Log("itemBoost");
            Debug.Log(score);
            score += 0.5f;
            Debug.Log(score);
        }


        switch (ability._typ)
        {
        case ability_typ.physical:
            power = PlayerPowerCalculation(ability.power, (int)(playerStrenght * ability.stat_strenght), score);
            break;

        case ability_typ.magical:
            power = PlayerPowerCalculation(ability.power, (int)(player.intellect * ability.stat_strenght), score);
            if (player.CheckForPassiv(passiveSkill.big_brain) && ability._typ == ability_typ.magical)
            {
                power = (int)(power * 1.30f);
            }
            break;

        case ability_typ.heal:
            power = PlayerPowerCalculation(ability.power, (int)(player.intellect * ability.stat_strenght), score);
            break;

        case ability_typ.item_heal:
        case ability_typ.mp_heal:
            if (player.CheckForPassiv(passiveSkill.itemBoost) && !typos_made && (ability._typ == ability_typ.item_heal || ability._typ == ability_typ.mp_heal))
            {
                power = ItemPowerCalculation(ability.power, score);
            }
            else
            {
                power = PlayerPowerCalculation(ability.power, 0, score);
            }
            break;

        default:
            power = (int)((ability.power) * (1 + score));
            break;
        }

        // low hp power boost
        if (Effects.Check_for_effect(ability.effect_array, effects.low_hp_power_boost) != null)
        {
            var effect_stats = Effects.Check_for_effect(ability.effect_array, effects.low_hp_power_boost);
            if ((float)player.Get_HP_before_Attack() / (float)player.hp_max <= (float)effect_stats.value1)
            {
                power = (int)(power * effect_stats.value2);
            }
        }

        if (Effects.Check_for_effect(ability.effect_array, effects.full_hp_boost) != null)
        {
            var effect_stats = Effects.Check_for_effect(ability.effect_array, effects.full_hp_boost);
            if ((float)player.Get_HP_before_Attack() / (float)player.hp_max >= 1f)
            {
                power = (int)(power * effect_stats.value1);
            }
        }


        if (enemies.Count == 1)
        {
            selected_enemy = enemies[0];
        }

        switch (ability._target)
        {
        case Target.one:
            Save_Action(power, typos_made, ability, selected_enemy.gameObject, score);
            break;

        case Target.multible:
            foreach (EnemyStats enemy in enemies)
            {
                Save_Action(power, typos_made, ability, enemy.gameObject, score);
            }
            break;

        case Target.self:
            Save_Action(power, typos_made, ability, player.gameObject, score);
            break;

        case Target.all:
        {
            Save_Action(power, typos_made, ability, player.gameObject, score);
            foreach (EnemyStats enemy in enemies)
            {
                Save_Action(power, typos_made, ability, enemy.gameObject, score);
            }
        }
        break;
        }
        _current_ability = ability;
    }
    public void Enemy_move(float score, bool typos_made, Ability ability)
    {
        if (ability.castSound != null)
        {
            FindObjectOfType <AudioBox>().PlaySound(ability.castSound, ability.soundVolume);
        }
        int power = 0;

        switch (ability._typ)
        {
        case ability_typ.physical:
            power = (int)(ability.power + ability.GetUser().strenght);
            break;

        case ability_typ.magical:
            power = (int)(ability.power + (ability.GetUser().intellect));
            break;

        case ability_typ.heal:
            power = (int)(ability.power + (ability.GetUser().intellect));
            break;

        default:
            power = (int)(ability.power);
            break;
        }

        // low hp power boost
        if (Effects.Check_for_effect(ability.effect_array, effects.low_hp_power_boost) != null)
        {
            var effect_stats = Effects.Check_for_effect(ability.effect_array, effects.low_hp_power_boost);
            Debug.Log(player.hp / player.hp_max);
            Debug.Log(effect_stats.value1);
            if (player.hp / player.hp_max <= effect_stats.value1)
            {
                power = (int)(power * effect_stats.value2);
            }
        }

        if (Effects.Check_for_effect(ability.effect_array, effects.full_hp_boost) != null)
        {
            var effect_stats = Effects.Check_for_effect(ability.effect_array, effects.full_hp_boost);
            Debug.Log(player.hp / player.hp_max);
            if (player.hp / player.hp_max >= 1)
            {
                power = (int)(power * effect_stats.value1);
            }
        }


        Save_Action(power, typos_made, ability, score);
        //switch (ability._target)
        //{
        //    case Target.one:
        //        Save_Action(power, typos_made, ability, player.gameObject, score);
        //        break;
        //    case Target.multible:
        //        foreach (EnemyStats enemy in enemies)
        //        {
        //            Save_Action(power, typos_made, ability, enemy.gameObject, score);
        //        }
        //        break;
        //    case Target.self:
        //        Save_Action(power, typos_made, ability, selected_enemy.gameObject, score);
        //        break;
        //    case Target.all:
        //        {
        //            Save_Action(power, typos_made, ability, player.gameObject, score);
        //            foreach (EnemyStats enemy in enemies)
        //            {
        //                Save_Action(power, typos_made, ability, enemy.gameObject, score);
        //            }
        //        }
        //        break;
        //}

        _current_ability = ability;
    }
Exemple #4
0
    public void Take_damage(int damage, Ability attack_stats)
    {
        switch (attack_stats._typ)
        {
        case ability_typ.physical:
            damage -= defence;
            break;

        case ability_typ.magical:
            damage -= resistance;
            break;

        default:

            break;
        }

        damage = CheckForElementEffects(damage, attack_stats);

        switch (resistens)
        {
        case EnemyResistens.Resistend:
            if (attack_stats._typ == ability_typ.magical)
            {
                damage = damage / 2;
            }
            break;

        case EnemyResistens.Defesive:
            if (attack_stats._typ == ability_typ.physical)
            {
                damage = damage / 2;
            }
            break;

        default:

            break;
        }

        if (Effects.Check_for_effect(attack_stats.effect_array, effects.absorb) != null)
        {
            var effect_stats = Effects.Check_for_effect(attack_stats.effect_array, effects.absorb);
            FindObjectOfType <PlayerStats>().Heal(Effects.Absorb(Mathf.Min(hp, damage), effect_stats.value1), true);
        }
        if (Effects.Check_for_effect(attack_stats.effect_array, effects.oneShotBoost) != null)
        {
            if (Effects.maxHealthBoost(hp_max, hp))
            {
                var effect_stats = Effects.Check_for_effect(attack_stats.effect_array, effects.oneShotBoost);
                damage = (int)(damage * effect_stats.value1);
            }
        }
        if (damage > 0)
        {
            GetComponent <CharacterAnimation>().Take_Damage();
        }
        hp -= Mathf.Max(0, damage);
        showDamageNumber(damage);
        UI.slider.maxValue = hp_max;
        UI.slider.value    = hp;
        UI.hp_text.text    = hp.ToString() + "/" + hp_max.ToString();
        if (hp <= 0)
        {
            showXPNumber(souls_drop);
            Defeated(attack_stats);
            shaker.ShakeCam(shake.big);
        }
        else if (damage > 0)
        {
            shaker.ShakeCam(shake.small);
        }
    }