public KeyValuePair <FollowerAttackName, int> GetAttackCost(FollowerAttackPool movePool)
 {
     if (lookupTable[characterClass].ContainsKey(movePool))
     {
         FollowerAttackName attackName = lookupTable[characterClass][movePool];
         return(new KeyValuePair <FollowerAttackName, int>(attackName, statList[attackName].Cost));
     }
     return(new KeyValuePair <FollowerAttackName, int>(FollowerAttackName.None, int.MaxValue));
 }
Beispiel #2
0
        private bool AttackInQueue()
        {
            isFromQueue = false;
            KeyValuePair <FollowerAttackName, int> attackAndCost;
            // Check player HP threshold over attack queue
            float hp   = playerHealth.GetPercentage();
            float mana = playerMana.GetAttributeValue();

            if (hp <= healThreshold)
            {
                FollowerAttackPool[] healSkills = new FollowerAttackPool[2]
                {
                    FollowerAttackPool.HealBig,
                    FollowerAttackPool.HealSmall
                };

                foreach (var heal in healSkills)
                {
                    attackAndCost = attackManager.GetAttackCost(heal);
                    if (!IsOnCooldown(attackAndCost.Key) && attackAndCost.Value <= mana)
                    {
                        currentAttack    = attackAndCost.Key;
                        resourceTypes    = new IAttribute[1];
                        resourceTypes[0] = playerHealth as IAttribute;
                        return(true);
                    }
                }
            }

            // Check player mana
            if (playerMana.GetPercentage() <= manaThreshold && attackManager.HasAttackInPool(FollowerAttackPool.ManaGain))
            {
                attackAndCost = attackManager.GetAttackCost(FollowerAttackPool.ManaGain);
                if (!IsOnCooldown(attackAndCost.Key))
                {
                    currentAttack    = attackAndCost.Key;
                    resourceTypes    = new IAttribute[2];
                    resourceTypes[0] = playerMana as IAttribute;
                    resourceTypes[1] = selfMana as IAttribute;
                    return(true);
                }
            }

            // Check for lower priority heal over time threshold
            if (hp < regenThreshold)
            {
                attackAndCost = attackManager.GetAttackCost(FollowerAttackPool.HealOverTime);
                if (!IsOnCooldown(attackAndCost.Key) && !IsAttackQueued(attackAndCost.Key))
                {
                    atkQueue.Enqueue(attackAndCost.Key);
                }
            }

            if (atkQueue.Count > 0)
            {
                currentAttack = atkQueue.Peek();
                if (!IsOnCooldown(currentAttack))
                {
                    isFromQueue = true;
                    return(true);
                }
                Debug.Log("Attack in queue is on cooldown? " + currentAttack);
            }

            return(false);
        }
 public FollowerAttackName GetAttackOfType(FollowerAttackPool movePool)
 {
     return(lookupTable[characterClass][movePool]);
 }
 public bool HasAttackInPool(FollowerAttackPool movePool)
 {
     return(lookupTable[characterClass].ContainsKey(movePool));
 }