Ejemplo n.º 1
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);
    }