Beispiel #1
0
        IEnumerator SkillCo()
        {
            ui.LogMessage(instigator._charName + " used " + skill._skillName + "!");

            yield return(new WaitForSeconds(delay));

            foreach (var target in targets)
            {
                int            hp;
                BattlePortrait targetPortrait = battle.GetPortrait(target);

                if (skill._healByAmount)
                {
                    hp = skill._healPower;
                }
                else
                {
                    hp = Mathf.RoundToInt(skill._healProportion * instigator._health._currentStatValue);
                }

                target._health.ChangeCurrentPoints(hp);

                GameObject hpHealNumber = GameObject.Instantiate(ui._floatingTextPrefab,
                                                                 targetPortrait.transform.position + 0.75f * Vector3.one, Quaternion.identity) as GameObject;

                FloatingText hpHealNum = hpHealNumber.GetComponent <FloatingText>();

                hpHealNum.StartCoroutine(hpHealNum.TextFloatCo(hp.ToString(), hpColour, outlineColour));

                ui.UpdateStats(target);
            }

            yield return(new WaitForSeconds(delay));
        }
        IEnumerator SkillAttackCo()
        {
            ui.LogMessage(instigator._charName + " used " + skill._skillName + "!");

            instigator._magic.ChangeCurrentPoints(-skill._mpCost);

            ui.UpdateStats(instigator);

            bool hit = combat.SuccessfulHit(instigator, targets, skill);

            yield return(new WaitForSeconds(normalDelay));

            if (hit)
            {
                foreach (var target in targets)
                {
                    float effectiveness;    // >1 for weak, 0<x<1 for resist, 0 for immune
                    float critical;
                    int   damage;

                    bool dead;

                    BattlePortrait targetPortrait = battle.GetPortrait(target);

                    critical = combat.Critical(instigator);

                    effectiveness = combat.Effectiveness(skill, target);

                    damage = Damage(instigator, target, skill, effectiveness, critical);

                    dead = target.TakeDamage(damage);

                    LogMessageSkill(target, effectiveness, critical, damage);

                    ui.UpdateStats(target);

                    CreateDamageNumber(targetPortrait, effectiveness, damage);

                    yield return(battle.StartCoroutine(targetPortrait.ShakeCo(effectiveness, shakeTime)));

                    if (dead)
                    {
                        if (battle.InActiveEnemies(target))
                        {
                            battle.AddExpEarned(target._expReward);
                            battle.AddMoneyEarned(target._moneyReward);
                        }
                        yield return(battle.StartCoroutine(battle.RemoveBattlerCo(target, smallDelay)));
                    }
                }
            }
            else
            {
                ui.LogMessage("The attack missed!");
            }

            yield return(new WaitForSeconds(normalDelay));
        }
Beispiel #3
0
        IEnumerator ItemCo()
        {
            ui.LogMessage("Used the " + item._itemName + "!");

            yield return(new WaitForSeconds(delay));

            foreach (var target in targets)
            {
                BattlePortrait targetPortrait = battle.GetPortrait(target);

                if (item._recoverHp)
                {
                    int hp = item._recoverAmountHp;
                    target._health.ChangeCurrentPoints(hp);

                    GameObject hpHealNumber = GameObject.Instantiate(ui._floatingTextPrefab,
                                                                     targetPortrait.transform.position + 0.75f * Vector3.one, Quaternion.identity) as GameObject;

                    FloatingText hpHealNum = hpHealNumber.GetComponent <FloatingText>();

                    hpHealNum.StartCoroutine(hpHealNum.TextFloatCo(hp.ToString(), hpColour, outlineColour));
                }

                if (item._recoverMp)
                {
                    int mp = item._recoverAmountMp;
                    target._magic.ChangeCurrentPoints(mp);

                    GameObject mpHealNumber = GameObject.Instantiate(ui._floatingTextPrefab,
                                                                     targetPortrait.transform.position + 0.25f * Vector3.one, Quaternion.identity) as GameObject;

                    FloatingText mpHealNum = mpHealNumber.GetComponent <FloatingText>();

                    mpHealNum.StartCoroutine(mpHealNum.TextFloatCo(mp.ToString(), mpColour, outlineColour));
                }

                ui.UpdateStats(target);
            }

            GameManager.instance._inventory.RemoveItem(item);

            yield return(new WaitForSeconds(delay));
        }
        void CreateDamageNumber(BattlePortrait targetPortrait, float effectiveness, int damage)
        {
            GameObject damageNumberObj = GameObject.Instantiate(ui._floatingTextPrefab,
                                                                targetPortrait.transform.position + 0.5f * Vector3.one, Quaternion.identity) as GameObject;

            FloatingText damageNum = damageNumberObj.GetComponent <FloatingText>();

            string message = "-" + damage;

            if (effectiveness > 1)
            {
                damageNum.StartCoroutine(damageNum.TextFloatCo(message, weakColour, outlineColour));
            }
            else if (effectiveness < 1)
            {
                damageNum.StartCoroutine(damageNum.TextFloatCo(message, resistColour, outlineColour));
            }
            else
            {
                damageNum.StartCoroutine(damageNum.TextFloatCo(message, normalColour, outlineColour));
            }
        }
        IEnumerator ItemAttackCo()
        {
            float  delay;
            TypeID damageType = item._damageType;

            if (battle._autoMode)
            {
                delay = smallDelay;
            }
            else
            {
                delay = normalDelay;
            }

            if (StartsWithVowel(item._itemName))
            {
                ui.LogMessage(instigator._charName + " used an " + item._itemName + "!");
            }
            else
            {
                ui.LogMessage(instigator._charName + " used a " + item._itemName + "!");
            }

            yield return(new WaitForSeconds(2f * smallDelay));

            foreach (var target in targets)
            {
                float effectiveness;
                int   damage;

                bool dead;

                BattlePortrait targetPortrait = battle.GetPortrait(target);

                effectiveness = combat.Effectiveness(item._damageType, target);

                damage = Damage(item, effectiveness);

                dead = target.TakeDamage(damage);

                LogMessageItem(target, effectiveness, damage);

                ui.UpdateStats(target);

                CreateDamageNumber(targetPortrait, effectiveness, damage);

                yield return(battle.StartCoroutine(targetPortrait.ShakeCo(effectiveness, shakeTime)));

                if (dead)
                {
                    if (battle.InActiveEnemies(target))
                    {
                        battle.AddExpEarned(target._expReward);
                        battle.AddMoneyEarned(target._moneyReward);
                    }
                    yield return(battle.StartCoroutine(battle.RemoveBattlerCo(target, delay)));
                }
            }

            game._inventory.RemoveItem(item);

            yield return(new WaitForSeconds(delay));
        }