예제 #1
0
 protected override void OnUpdate(GameTime Time)
 {
     if (PC.IsGrounded || PC.VelocityX == 0f)
     {
         if (CPComponent.IsAoE)
         {
             AreaOfEffectComponent.CreateAoEEntity(this.Parent);
         }
         if (!string.IsNullOrEmpty(CPComponent.ProjectileOnHitSound))
         {
             AudioManager.PlaySoundEffect(CPComponent.ProjectileOnHitSound);
         }
         Parent.Dispose();
     }
     base.OnUpdate(Time);
 }
예제 #2
0
        protected override bool OnCollision(Entity Entity, EntityClassification Classification)
        {
            bool colGood = false;
            //Apply normal damage.
            var dc = Entity.GetComponent <DamageComponent>();

            if (dc != null)
            {
                dc.TakeDamage(AttributesComponent);
                colGood = true;
            }

            var mc = Entity.GetComponent <MovementComponent>();

            if (mc != null)
            {
                mc.Knockback(AttributesComponent.TotalKnockback, (PC.VelocityX > 0) ? 1 : -1);
                colGood = true;
            }

            //Apply status effect if it can.
            if (CPComponent.AppliesEffect)
            {
                var sc = Entity.GetComponent <StatusEffectsComponent>();
                if (sc != null)
                {
                    sc.ApplyStatusEffect(SEAComponent.StatusEffectAttributes);
                    colGood = true;
                }
            }
            //Make an aoe appear if there should be one.
            if (CPComponent.IsAoE)
            {
                AreaOfEffectComponent.CreateAoEEntity(this.Parent);
                colGood = true;
            }

            if (!string.IsNullOrEmpty(CPComponent.ProjectileOnHitSound))
            {
                AudioManager.PlaySoundEffect(CPComponent.ProjectileOnHitSound);
            }

            return(colGood);
        }
예제 #3
0
        private void EnemyAttackMelee()
        {
            AudioManager.PlaySoundEffect(CombatPropertiesComponent.AttackSound);
            //Enumerate over each entity that intersected with our attack rectangle, and if they're not us, make them take damage.
            foreach (var attackedEntity in PhysicsSystem.GetEntitiesAtLocation(CreateHitBox()).Reverse())
            {
                //might be a little inefficient because we have to keep searching a list to get the ClassificationComponent.
                var cc = attackedEntity.GetComponent <ClassificationComponent>();
                if (attackedEntity != Parent && cc.Classification == AttackableEntities)
                {
                    var damageComponent = attackedEntity.GetComponent <DamageComponent>();
                    damageComponent.TakeDamage(AttributesComponent);

                    //knockback
                    var mc = attackedEntity.GetComponent <MovementComponent>();
                    mc.Knockback(AttributesComponent.TotalKnockback, CorvusExtensions.GetSign(MovementComponent.CurrentDirection));

                    //When the enemy attacks, apply status effects, if any.
                    if (CombatPropertiesComponent.AppliesEffect)
                    {
                        var seac = Parent.GetComponent <StatusEffectPropertiesComponent>();
                        if (seac == null)
                        {
                            continue;
                        }
                        var enemySEC = attackedEntity.GetComponent <StatusEffectsComponent>();
                        if (enemySEC == null)
                        {
                            continue;
                        }
                        enemySEC.ApplyStatusEffect(seac.StatusEffectAttributes);
                    }
                    if (CombatPropertiesComponent.IsAoE)
                    {
                        AreaOfEffectComponent.CreateAoEEntity(this.Parent);
                    }
                }
            }
        }
예제 #4
0
        private void AttackMelee()
        {
            AudioManager.PlaySoundEffect(CombatPropertiesComponent.AttackSound);
            //Enumerate over each entity that intersected with our attack rectangle, and if they're not us, make them take damage.
            foreach (var attackedEntity in PhysicsSystem.GetEntitiesAtLocation(CreateHitBox()).Reverse())
            {
                //might be a little inefficient because we have to keep searching a list to get the ClassificationComponent.
                var cc = attackedEntity.GetComponent <ClassificationComponent>();
                if (attackedEntity != Parent && cc.Classification == AttackableEntities)
                {
                    //TODO: Find a better way, if it's really needed.
                    //A hack to get the Ai to react before taking damage.
                    var aic = attackedEntity.GetComponent <AIComponent>();
                    aic.Update(GameTime);

                    var damageComponent = attackedEntity.GetComponent <DamageComponent>();
                    damageComponent.TakeDamage(AttributesComponent);

                    //Apply knockback.
                    var   mc  = attackedEntity.GetComponent <MovementComponent>();
                    float myx = attackedEntity.Position.X - Parent.Position.X;
                    mc.Knockback(AttributesComponent.TotalKnockback, (myx > 0) ? 1 : -1);

                    //Applies a status effect to the attacked enemy, if they can be affected.
                    var enemySEC = attackedEntity.GetComponent <StatusEffectsComponent>();
                    if (CombatPropertiesComponent.AppliesEffect && enemySEC != null)
                    {
                        enemySEC.ApplyStatusEffect(EquipmentComponent.CurrentWeapon.Effect);
                    }

                    if (CombatPropertiesComponent.IsAoE)
                    {
                        AreaOfEffectComponent.CreateAoEEntity(this.Parent);
                    }
                }
            }
        }