Example #1
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));
            }
        }