示例#1
0
        private void DecideNextAction()
        {
            if (timeSinceLastAttack >= timeBetweenAttacks)
            {
                // actionModifier should probably affect this...
                float foodValue = fullness.DigestFood(digestSpeed);
                // TODO: figure out base mana recovery when stomach is empty
                float manaAmount = Mathf.Max(1, foodValue * manaConversion);
                selfMana.GainAttribute(manaAmount);
                timeSinceLastAttack = 0;
                string chatMessage = null;

                float fullPercent = fullness.GetPercentage();
                // Check for hunger and whether inventory has consumable
                if (fullPercent <= starveValue && consumableIndex.Count > 0)
                {
                    chatMessage = GetItemToEat();
                }
                else if (AttackInQueue())
                {
                    FollowerAttackStats attackStats = attackManager.GetAttackStats(currentAttack);

                    // Check if have mana to cover attack cost
                    if (attackStats.Cost < selfMana.GetAttributeValue())
                    {
                        attackSpeed    = 100 / fighter.GetStat(Stat.AttackSpeed);
                        timeToAct      = attackStats.CastTime * attackSpeed;
                        actionModifier = attackStats.ActionModifier;
                        selfMana.UseMana(attackStats.Cost);
                        timeSinceActionStart = 0;
                        isAttackActive       = true;
                        isEffectOnHit        = attackStats.ApplyEffect == ApplyEffectOn.OnHit;

                        Sprite sprite = followerAttackIconDB.GetSprite(currentAttack);
                        SpawnHitTimer(sprite);
                        CheckEffectActivation(false);

                        if (isFromQueue)
                        {
                            atkQueue.Dequeue();
                        }
                        if (attackStats.isRecastSkill)
                        {
                            float recastTime = attackStats.RecastTimer + timeToAct;
                            skillRecastRoutines[currentAttack] = StartCoroutine(SkillRecast(currentAttack, recastTime));
                        }
                        chatMessage = "Casting " + attackStats.Name;
                    }
                    else
                    {
                        // Message out of mana, extra check for hunger
                        chatMessage    = "I'm OOMing!";
                        actionModifier = 2f;
                        if (fullPercent <= hungerValue && consumableIndex.Count > 0)
                        {
                            chatMessage = GetItemToEat();
                        }
                    }
                }
                // check if under soft cap for hunger
                else if (fullPercent <= hungerValue && consumableIndex.Count > 0)
                {
                    chatMessage = GetItemToEat();
                }
                else
                {
                    chatMessage    = "Nothing to do?";
                    actionModifier = 2f;
                }

                combatLog.SendMessageToChat(chatMessage);
            }
        }