Beispiel #1
0
        /// <summary>
        /// Apply damage to the entity. Potentially killing it
        /// </summary>
        /// <param name="resultSet">Result</param>
        /// <param name="amount">Amount of damage to apply</param>
        public void TakeDamage(ResultSet resultSet, int amount)
        {
            hp -= amount;

            if (hp <= 0)
            {
                hp = 0;
                resultSet.AddDead(owner);
                resultSet.AddXp(xp);
            }

            if (owner.e.ai == null)
            {
                // If this is a player taking damage then play monster hit sound
                SoundBank.Instance.SoundPlayDelayed(C.SOUND_MONSTER_ATTACK, 0.5f, RandomUtils.RandomPitch(0.1f), UnityEngine.Random.Range(1, 5));

                EffectManager.Instance.AddEffect(new EffectSwoosh(owner));
            }
            else
            {
                // Otherwise play monster hit sound
                SoundBank.Instance.SoundPlayDelayed(C.SOUND_PLAYER_ATTACK, 0.5f, RandomUtils.RandomPitch(0.1f), UnityEngine.Random.Range(1, 5));

                EffectManager.Instance.AddEffect(new EffectSwoosh(owner));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Apply damage to the entity. Potentially killing it
        /// </summary>
        /// <param name="resultSet">Result</param>
        /// <param name="amount">Amount of damage to apply</param>
        public void TakeDamage(ResultSet resultSet, int amount)
        {
            var game = (RetroDungeoneerGame)RB.Game;

            hp -= amount;

            if (hp <= 0)
            {
                hp = 0;
                resultSet.AddDead(owner);
                resultSet.AddXp(xp);
            }

            if (owner.e.ai == null)
            {
                // If this is a player taking damage then play monster hit sound
                SoundBank.Instance.SoundPlayDelayed(game.assets.soundMonsterAttack, 0.5f, RandomUtils.RandomPitch(0.1f), UnityEngine.Random.Range(1, 5));

                EffectManager.Instance.AddEffect(new EffectSwoosh(owner));
            }
            else
            {
                // Otherwise play monster hit sound
                SoundBank.Instance.SoundPlayDelayed(game.assets.soundPlayerAttack, 0.5f, RandomUtils.RandomPitch(0.1f), UnityEngine.Random.Range(1, 5));

                EffectManager.Instance.AddEffect(new EffectSwoosh(owner));
            }
        }