Exemple #1
0
        /// <summary>
        /// Called whenever the creature takes damage.
        /// </summary>
        public override float Damage(float amount, DamageType type = DamageType.Normal)
        {
            IsCloaked = false;
            float damage = base.Damage(amount, type);

            string prefix = damage > 0 ? "-" : "+";
            Color  color  = damage > 0 ? GameSettings.Default.Colors.GetColor("Negative", Color.Red) : GameSettings.Default.Colors.GetColor("Positive", Color.Green);

            if (AI != null)
            {
                IndicatorManager.DrawIndicator(prefix + (int)amount + " HP",
                                               AI.Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 0.5f, color);
                NoiseMaker.MakeNoise("Hurt", AI.Position);
                Sprite.Blink(0.5f);
                AddThought("I got hurt recently.", new TimeSpan(2, 0, 0, 0), -5.0f);

                var deathParticleTriggers = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs");

                foreach (var trigger in deathParticleTriggers)
                {
                    Manager.World.ParticleManager.Trigger(trigger.EmitterName, AI.Position, Color.White, 2);
                }
                DrawLifeTimer.Reset();
            }

            return(damage);
        }
Exemple #2
0
        /// <summary>
        /// Called whenever the creature takes damage.
        /// </summary>
        public override float Damage(float amount, DamageType type = DamageType.Normal)
        {
            float damage = base.Damage(amount, type);

            string prefix = damage > 0 ? "-" : "+";
            Color  color  = damage > 0 ? Color.Red : Color.Green;

            IndicatorManager.DrawIndicator(prefix + (int)amount + " HP",
                                           AI.Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 0.5f, color);

            if (damage > 0)
            {
                NoiseMaker.MakeNoise("Hurt", AI.Position);
                Sprite.Blink(0.5f);
                AI.AddThought(Thought.ThoughtType.TookDamage);

                var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs").FirstOrDefault();

                if (deathParticleTrigger != null)
                {
                    Manager.World.ParticleManager.Trigger(deathParticleTrigger.EmitterName, AI.Position, Color.White, 2);
                }
                DrawLifeTimer.Reset();
            }


            return(damage);
        }
Exemple #3
0
        /// <summary>
        /// Called when the creature receives an event message from another source.
        /// This somewhat janky messaging system is rarely used anymore and should
        /// probably be removed for clarity.
        /// </summary>
        public override void ReceiveMessageRecursive(Message messageToReceive)
        {
            switch (messageToReceive.Type)
            {
            case Message.MessageType.OnChunkModified:
                break;

            case Message.MessageType.OnHurt:
                NoiseMaker.MakeNoise("Hurt", AI.Position);
                Sprite.Blink(0.5f);
                AI.AddThought(Thought.ThoughtType.TookDamage);
                PlayState.ParticleManager.Trigger(DeathParticleTrigger.EmitterName, AI.Position, Color.White, 2);
                break;
            }


            base.ReceiveMessageRecursive(messageToReceive);
        }
Exemple #4
0
        /// <summary>
        /// Called when the creature receives an event message from another source.
        /// This somewhat janky messaging system is rarely used anymore and should
        /// probably be removed for clarity.
        /// </summary>
        public override void ReceiveMessageRecursive(Message messageToReceive)
        {
            switch (messageToReceive.Type)
            {
            case Message.MessageType.OnHurt:
                NoiseMaker.MakeNoise("Hurt", AI.Position);
                Sprite.Blink(0.5f);
                AddThought("I got hurt recently.", new TimeSpan(2, 0, 0, 0), -5.0f);

                var deathParticleTriggers = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs");

                foreach (var trigger in deathParticleTriggers)
                {
                    Manager.World.ParticleManager.Trigger(trigger.EmitterName, AI.Position, Color.White, 2);
                }
                break;
            }


            base.ReceiveMessageRecursive(messageToReceive);
        }
Exemple #5
0
        /// <summary>
        /// Called whenever the creature takes damage.
        /// </summary>
        public override float Damage(float amount, DamageType type = DamageType.Normal)
        {
            float damage = base.Damage(amount, type);

            string prefix = damage > 0 ? "-" : "+";
            Color  color  = damage > 0 ? Color.Red : Color.Green;

            IndicatorManager.DrawIndicator(prefix + (int)amount + " HP",
                                           AI.Position + Vector3.Up + MathFunctions.RandVector3Cube() * 0.5f, 0.5f, color,
                                           Indicator.IndicatorMode.Indicator3D);

            if (damage > 0)
            {
                NoiseMaker.MakeNoise("Hurt", AI.Position);
                Sprite.Blink(0.5f);
                AI.AddThought(Thought.ThoughtType.TookDamage);
                PlayState.ParticleManager.Trigger(DeathParticleTrigger.EmitterName, AI.Position, Color.White, 2);
            }

            return(damage);
        }
Exemple #6
0
        /// <summary>
        /// Called when the creature receives an event message from another source.
        /// This somewhat janky messaging system is rarely used anymore and should
        /// probably be removed for clarity.
        /// </summary>
        public override void ReceiveMessageRecursive(Message messageToReceive)
        {
            switch (messageToReceive.Type)
            {
            case Message.MessageType.OnChunkModified:
                break;

            case Message.MessageType.OnHurt:
                NoiseMaker.MakeNoise("Hurt", AI.Position);
                Sprite.Blink(0.5f);
                AI.AddThought(Thought.ThoughtType.TookDamage);

                var deathParticleTrigger = Parent.EnumerateAll().OfType <ParticleTrigger>().Where(p => p.Name == "Death Gibs").FirstOrDefault();

                if (deathParticleTrigger != null)
                {
                    Manager.World.ParticleManager.Trigger(deathParticleTrigger.EmitterName, AI.Position, Color.White, 2);
                }
                break;
            }


            base.ReceiveMessageRecursive(messageToReceive);
        }