Ejemplo n.º 1
0
 protected virtual void OnHealthChanged(EntityHealthChangeEventArgs e)
 {
     if (HealthChanged != null)
     {
         HealthChanged(this, e);
     }
 }
Ejemplo n.º 2
0
 private void CharacterOnHealthChanged(object sender, EntityHealthChangeEventArgs e)
 {
     if (e.SourceEntity != null)
     {
         if (!Npc.DangerousEntities.Contains(e.SourceEntity))
         {
             Npc.DangerousEntities.Add(e.SourceEntity);
         }
     }
 }
Ejemplo n.º 3
0
        private void entity_HealthChanged(object sender, EntityHealthChangeEventArgs e)
        {
            //Play "Hurt" sound only if not local player, for local player it will be handled by the playercharachter class
            if (e.Change < -2 && !IsLocalPlayer(e.ImpactedEntity.DynamicId))
            {
                _soundEngine.StartPlay3D("Hurt", 1.0f, e.ImpactedEntity.Position.AsVector3());
            }

            //Start Bleeding if needed !
            if (e.Change < 2)
            {
                //Damage received !
                _utopiaParticuleEngine.AddDynamicEntityParticules(e.HealthChangeHitLocation, e.HealthChangeHitLocationNormal, UtopiaParticuleEngine.DynamicEntityParticuleType.Blood);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Damage handling
        /// </summary>
        /// <param name="change">Use negative value to do the damage, and positive to heal</param>
        /// <param name="sourceEntity">Entity that hits us (or heal)</param>
        /// <returns></returns>
        public IToolImpact HealthImpact(float change, IDynamicEntity sourceEntity = null)
        {
            var impact = new EntityToolImpact();

            if (HealthState == DynamicEntityHealthState.Dead)
            {
                impact.Message = "The player is dead, cannot be subject to health change";
                return(impact);
            }

            Health.CurrentValue += change;

            //If change > some Trigger ==> Risk of Afflication change like Stunt !

            if (Health.CurrentValue <= 0 && HealthState != DynamicEntityHealthState.Dead)
            {
                impact = ActivateDead();
            }

            //Raise trigger here : CharacterEntityHealthChange (Health energy + Contact point + Normal vector for the damage)
            //Will be subscribed by client to play Hurt sound, show animation on hit point, ...
            var e = new EntityHealthChangeEventArgs
            {
                Change                        = change,
                Health                        = Health,
                ImpactedEntity                = this,
                SourceEntity                  = sourceEntity,
                HealthChangeHitLocation       = sourceEntity == null ? default(Vector3) : sourceEntity.EntityState.PickPoint,
                HealthChangeHitLocationNormal = sourceEntity == null ? default(Vector3I) : sourceEntity.EntityState.PickPointNormal
            };

            OnHealthChanged(e);
            impact.Success = true;


            return(impact);
        }