Esempio n. 1
0
        /// <summary>
        /// 使用於 如果已經計算好公式了!
        /// </summary>
        /// <param name="attacker"> Attacker </param>
        /// <param name="damages"> sequence of damage </param>
        /// <param name="pos"> damage text position </param>
        /// <param name="criticalChance"> chance of spawning red text </param>
        public void ApplyDamageText(
            Transform attacker,
            int[] damages,
            Vector2 pos,
            int criticalChance,
            AudioClip hitSound = null)
        {
            // set the last attack in the safe way.
            SetLastAttacker(attacker);

            // Damage text version
            if (mDamageTextEffect)
            {
                JCS_MixDamageTextPool mixTP = JCS_UtilitiesManager.instance.GetMixDamageTextPool();
                if (mixTP == null)
                {
                    JCS_Debug.LogError(
                        "There is no Mix Damage Text Pool in the scene. Consider to grab one?");
                    return;
                }

                // spawn the damage text
                mixTP.DamageTextSpawnerSimple(
                    damages,
                    pos,
                    criticalChance,
                    IsPlayer,
                    hitSound);
            }
            // Do damage without damage text.
            else
            {
                // no need to do anything cuz is
                // pre-calculate already.
            }

            ReceiveDamage(damages, attacker);
        }
Esempio n. 2
0
        /// <summary>
        /// Apply Damage text by the chosen effect and
        /// algorithm. Lastly, apply it to Health Point.
        /// </summary>
        /// <param name="attacker"> Attacker </param>
        /// <param name="minDamage"> minimum damage could be </param>
        /// <param name="maxDamage"> maximum damage could be </param>
        /// <param name="pos"> position, usually this transform's position </param>
        /// <param name="hit"> how many hit in this sequence, could be one. </param>
        /// <param name="criticalChance"> critical chance could be? </param>
        public void ApplyDamageText(
            Transform attacker,
            int minDamage, int maxDamage,
            Vector2 pos,
            int hit            = 1,
            int criticalChance = 0,
            AudioClip hitSound = null)
        {
            int[] damages = null;

            // set the last attack in the safe way.
            SetLastAttacker(attacker);

            int defenseValue = 0;

            // get the defense value.
            if (mAbilityFormat != null)
            {
                defenseValue = mAbilityFormat.GetDefenseValue();
            }
            else
            {
                JCS_Debug.LogReminder(
                    "No Ability Format attached.");
            }

            // Damage text version
            if (mDamageTextEffect)
            {
                JCS_MixDamageTextPool mixTP = JCS_UtilitiesManager.instance.GetMixDamageTextPool();
                if (mixTP == null)
                {
#if (UNITY_EDITOR)
                    if (JCS_GameSettings.instance.DEBUG_MODE)
                    {
                        JCS_Debug.LogError(
                            "There is no Mix Damage Text Pool in the scene. Consider to grab one?");
                    }
#endif
                    return;
                }


                // spawn the damage text
                damages = mixTP.DamageTextSpawnerSimple(
                    minDamage, maxDamage,
                    pos,
                    hit,
                    criticalChance,
                    defenseValue,        // defense value
                    IsPlayer,
                    hitSound);
            }
            // Do damage without damage text.
            else
            {
                // since is not pre-calculate.
                // we have to calculate the damage before
                // actually apply the damage to
                // this live object.
                for (int index = 0;
                     index < hit;
                     ++index)
                {
                    int dm = Random.Range(minDamage, maxDamage);

                    // 受到的傷害 = 傷害 - 防禦力
                    damages[index] = dm - defenseValue;
                }
            }

            ReceiveDamage(damages, attacker);
        }
Esempio n. 3
0
        /* Setter & Getter */

        public void SetMixDamageTextPool(JCS_MixDamageTextPool tp)
        {
            this.mMixDamageTextPool = tp;
        }