예제 #1
0
        /// <summary>
        /// Executes a monster's attack, by first getting the attack it wants to use, and then selecting
        /// its target based on its AI
        /// </summary>
        /// <returns> IEnumerator to play animations after each action </returns>
        private IEnumerator ExecuteMonsterAttack()
        {
            int    targetChoice = 0;
            Attack attackChoice = activeMonster.SelectAttack();

            eventDescription.SetText(attackChoice.nameKey);
            yield return(StartCoroutine(activeMonster.PlayStartTurnAnimation()));

            if (activeMonster.monsterAI == "random")
            {
                targetChoice = Random.Range(0, partyMembers.Count);
            }
            else if (activeMonster.monsterAI == "weakHunter")
            {
                int weakest = 0;
                for (int i = 1; i < partyMembers.Count; i++)
                {
                    if (partyMembers[i].CHP < partyMembers[weakest].CHP && !partyMembers[i].CheckDeath())
                    {
                        weakest = i;
                    }
                }
                targetChoice = weakest;
            }

            yield return(StartCoroutine(activeMonster.PlayAttackAnimation()));

            eventDescription.SetPMDamageText(partyMembers[targetChoice], attackChoice.damage);

            if (attackChoice.damage > 0)
            {
                yield return(StartCoroutine(partyMembers[targetChoice].LoseHP(attackChoice.damage)));
            }
            eventDescription.ClearText();
        }
예제 #2
0
        /// <summary>
        /// Updates the current fill amount on all HPBars to show HP being added or lost
        /// </summary>
        /// <param name="isLoss"> Flag for if damaged animation should play </param>
        /// <param name="isHealAnim"> Flag for if there is a healing animation that needs to be yielded to </param>
        /// <param name="isEventDes"> Flag for if there should be yielding at all (otherwise no animations or event description) </param>
        /// <returns> IEnumerator for animations </returns>
        public IEnumerator DisplayHPChange(bool isLoss, bool isHealAnim = false, bool isYield = true)
        {
            isAnimating = true;
            if (statusPanelHPBar != null)
            {
                statusPanelHPBar.SetCurrent(pm.CHP);
            }
            if (statsPanelHPBar != null)
            {
                statsPanelHPBar.SetCurrentDisplayCurrentOverMax(pm.CHP);
            }

            if (isYield == false)    // no event description means no yielding or animations (only if an attack uses hp as a cost)
            {
                if (partyPanel.isOpen == true)
                {
                    partyPanelHPBar.SetCurrent(pm.CHP);
                }
            }
            else if (partyPanel.isOpen == true)
            {
                partyPanelHPBar.SetCurrent(pm.CHP);

                if (isLoss == true && CombatManager.instance.inCombat == true)
                {
                    if (isCrit == true)
                    {
                        eventDescription.SetPMDamageCritText(pm, attackAmount);
                        yield return(StartCoroutine(pmdPartyPanel.PlayCritDamagedAnimation()));

                        isCrit = false;
                    }
                    else
                    {
                        eventDescription.SetPMDamageText(pm, attackAmount);
                        yield return(StartCoroutine(pmdPartyPanel.PlayDamagedAnimation()));
                    }
                    if (pm.CHP == 0)
                    {
                        yield return(new WaitForSeconds(0.5f / GameManager.instance.gsDataCurrent.animationSpeed));
                    }
                }
                else if (isLoss == false && CombatManager.instance.inCombat == true && isHealAnim == true)
                {
                    if (attackAmount < 0)   // heals coming from statusEffects are negative values
                    {
                        attackAmount *= -1;
                    }
                    if (isCrit == true)
                    {
                        eventDescription.SetPMHealCritText(pm, attackAmount);
                        isCrit = false;
                    }
                    else
                    {
                        eventDescription.SetPMHealText(pm, attackAmount);
                    }
                    yield return(new WaitForSeconds(1f / GameManager.instance.gsDataCurrent.animationSpeed));
                }
            }
            else
            {
                if (isLoss == true && CombatManager.instance.inCombat == true)
                {
                    if (isCrit == true)
                    {
                        eventDescription.SetPMDamageCritText(pm, attackAmount);
                        isCrit = false;
                    }
                    else
                    {
                        eventDescription.SetPMDamageText(pm, attackAmount);
                    }
                }
                else if (isLoss == false && CombatManager.instance.inCombat == true && isHealAnim == true)
                {
                    if (attackAmount < 0)   // heals coming from statusEffects are negative values
                    {
                        attackAmount *= -1;
                    }
                    if (isCrit == true)
                    {
                        eventDescription.SetPMHealCritText(pm, attackAmount);
                        isCrit = false;
                    }
                    else
                    {
                        eventDescription.SetPMHealText(pm, attackAmount);
                    }
                }
                yield return(new WaitForSeconds(1f / GameManager.instance.gsDataCurrent.animationSpeed));
            }
            isAnimating = false;
        }