Пример #1
0
    //---------------------------------------------------------------------------------------//

    public void StartTurn()
    {
        if (IsDead)
        {
            return;
        }

        if (poisonTime > 0)
        {
            poisonTime--;
            DoDamage(poisonProfile.valueRange.x, true);
            poisonProfile.ApplyEffectOnTarget(this);

            if (poisonTime == 0)
            {
                poisonProfile = null;
            }
        }

        if (currentState == STATE.STUNNED)
        {
            if (stunTime == 0)
            {
                SetCurrentState(STATE.WAITING);
            }
            else
            {
                stunTime--;
            }
        }

        turnDone = false;
    }
Пример #2
0
    private IEnumerator EnemyPassive(CharacterBase caster, CharacterBase target, AbilityScriptableObject ability,
                                     Action onPreCall)
    {
        onPreCall?.Invoke();

        ability.ApplyEffectOnTarget(target);
        yield return(new WaitForSeconds(2f));
    }
Пример #3
0
    public void Poison(AbilityScriptableObject ability)
    {
        //TODO Going to need to consider having some sort of poison resist
        if (ability.AbilityType != AbilityType.Poison)
        {
            return;
        }

        poisonProfile = ability;
        poisonTime    = poisonProfile.hitCount;

        DoDamage(poisonProfile.valueRange.x * 2, true);
        poisonProfile.ApplyEffectOnTarget(this);
    }
    //new offset from player of the firefly
    public void TriggerAbility()
    {
        if (abilities.Length == 0 || currentAbilityIndex > abilities.Length - 1)
        {
            return;
        }

        if (m_CurrentAbility != abilities[currentAbilityIndex])
        {
            m_CurrentAbility = abilities[currentAbilityIndex];

            //m_CurrentAbility.Initialize(abilityHolder);
        }


        //re initialize every time we trigger ability isn't effective (change later)
        m_CurrentAbility.Initialize(abilityHolder);
        m_CurrentAbility.Trigger();
    }
Пример #5
0
    //---------------------------------------------------------------------------------------//
    private void GenerateTargetList(AbilityScriptableObject ability, out List <CharacterBase> targets)
    {
        targets = new List <CharacterBase>();

        switch (ability.TargetType)
        {
        case TargetType.Enemy:
            //targets.AddRange(enemyCharacters);
            foreach (var enemyCharacter in enemyCharacters)
            {
                if (!enemyCharacter.IsDead)
                {
                    targets.Add(enemyCharacter);
                }
            }

            break;

        case TargetType.Friendly:
            targets.AddRange(playerCharacters);
            foreach (var character in playerCharacters)
            {
                if (!character.IsDead)
                {
                    targets.Add(character);
                }
            }

            break;

        case TargetType.Self:
            targets.Add(playerCharacters[selectedCharacterIndex]);
            break;
        }

        if (ability.CanTargetSelf && ability.TargetType != TargetType.Self)
        {
            targets.Add(playerCharacters[selectedCharacterIndex]);
        }

        targets = targets.Distinct().ToList();
    }
Пример #6
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));
        }
    }
Пример #7
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);
    }