//this is here instead of on the attackRoot becuase it keeps a unit from firing off an attack before the last one has finished
    private IEnumerator EndAttack(AttackRoot activeAttack)
    {
        yield return(new WaitForSeconds(activeAttack.hitTime));

        attackReady = true;
        activeAttack.EndAttack();
    }
    public void EvaluateAttacking(AttackRoot activeAttack)
    {
        //I still hate this confusing 'targetHeroes' logic but it'll do for now
        if (_localBlackboard.currentTarget.heroUnit != activeAttack.targetHeroes)
        {
            return;
        }

        if (_localBlackboard.inRange && attackReady && activeAttack.attackCharged)
        {
            attackReady = false;
            PlayAttack(activeAttack);
        }
    }
    //Chooses the attack with the highest attackValue(number to represent how powerful/useful this attack is) and filters out those that would deplete this unit's energy completely.
    //default attack if all have too high an energy cost is the first attack
    //if need be, could throw in code to have default be the highest damaging attack but I don't think it'd add much
    public void SelectAttack()
    {
        highestValue = -1;
        activeAttack = attackRoots[0];

        for (int i = 0; i < attackRoots.Count; i++)
        {
            if (attackRoots[i].attackValue > highestValue && attackRoots[i].energyCost >= _localBlackboard.energyLevel)
            {
                highestValue      = attackRoots[i].attackValue;
                currentChosenAtck = i;
            }
        }

        _localBlackboard._commandMessenger.AttackButtonChosen(currentChosenAtck);
    }
Beispiel #4
0
    public void Setup(LocalBlackboard localBlackboard, AttackRoot attackRoot)
    {
        _localBlackboard = localBlackboard;
        myCollider       = _localBlackboard.healthCollider;
        _attackRoot      = attackRoot;

        if (hitBox.TryGetComponent(out TriggerSensor temp))
        {
            _triggerSensor = temp;
            _triggerSensor.Setup(this);
        }
        else
        {
            Debug.LogError(gameObject.name + " is missing a trigger sensor on it's hitbox. Add one or suffer the consequences O_O! ...x_x");
        }

        if (TryGetComponent(out DamageOverTime temp2))
        {
            _damageOverTime = temp2;
            _damageOverTime.Setup(_attackRoot);
        }
    }
 //called by input manager, sets the activeAttack to whatever the player selected
 public void AttackSelected(int chosenAttack)
 {
     activeAttack = attackRoots[chosenAttack];
     activeAttack.OnAttackSelected();
 }
 public void Setup(AttackRoot attackRoot)
 {
     _attackRoot = attackRoot;
     StartCoroutine(DealDamageOverTime());
 }
Beispiel #7
0
 public void Setup(AttackRoot attackRoot)
 {
     _attackRoot = attackRoot;
 }
 public void Setup(AttackRoot attackRoot)
 {
     attackRoot.RunAttack();
 }
    private void PlayAttack(AttackRoot activeAttack)
    {
        activeAttack.RunAttack(_localBlackboard.currentTarget.transform);

        StartCoroutine(EndAttack(activeAttack));
    }