Exemplo n.º 1
0
    private IEnumerator EnemyAttack(int index, CharacterBase caster, CharacterBase target, AbilityScriptableObject ability)
    {
        HighlightTarget(target);

        yield return(new WaitForSeconds(1f));

        var value = ability.GetValueRoll();

        value = Mathf.CeilToInt(value *
                                _damageController.GetMultiplier(caster.attackType,
                                                                target.attackType));

        target.DoDamage(value);
        memberElements[index].UpdateUI();

        if (value > 0)
        {
            ability.ApplyEffectOnTarget(target);
        }

        yield return(new WaitForSeconds(2f));

        if (!IsAlive(playerCharacters))
        {
            StartCoroutine(ShowTurnTextCoroutine("Defeat", Color.red));
        }
    }
Exemplo n.º 2
0
    private void SelectTarget(AbilityScriptableObject ability, CharacterBase target)
    {
        int value = ability.GetValueRoll();

        //TODO I should confirm the selection
        switch (ability.AbilityType)
        {
        case AbilityType.LightAttack:
        case AbilityType.HeavyAttack:
            value = Mathf.CeilToInt(value *
                                    _damageController.GetMultiplier(playerCharacters[selectedCharacterIndex].attackType,
                                                                    target.attackType));

            //Damage character, based on chance and on range
            target.DoDamage(value);
            if (value > 0)
            {
                ability.ApplyEffectOnTarget(target);
            }

            if (!IsAlive(enemyCharacters))
            {
                //TODO Need a way of wrapping up match
                StartCoroutine(ShowTurnTextCoroutine("Victory", Color.green));
            }

            break;

        case AbilityType.Stun:
            //Stuns Target
            target.Stun(1);
            ability.ApplyEffectOnTarget(target);

            break;

        case AbilityType.Heal:
            //Add health, based on range
            target.Heal(value);
            memberElements.Find(x => x.m_character == target).UpdateUI();
            ability.ApplyEffectOnTarget(target);

            break;

        case AbilityType.Block:
            //Sets target to be blocking
            target.Block();
            break;

        case AbilityType.Poison:
            target.Poison(ability);
            break;

        case AbilityType.AOE:

            foreach (var enemyCharacter in enemyCharacters)
            {
                enemyCharacter.DoDamage(ability.GetValueRoll());
                ability.ApplyEffectOnTarget(enemyCharacter);
            }

            break;

        default:
            throw new ArgumentOutOfRangeException();
        }

        playerCharacters[selectedCharacterIndex].EndTurn();
        SetGameState(GAMESTATE.CHARACTER_SELECT);
    }