示例#1
0
 private void DrawBullet(GraphicsContext graphicsContext, Entity entity, CBullet bullet)
 {
     TextureDefinition texture = this.GetTexture(bullet.Weapon.Type);
     if (bullet.Weapon.Type == WeaponType.RocketLauncher)
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, Color.White, entity.Transform.Rotation, 2);
     }
     else if (bullet.Weapon.Type == WeaponType.Bouncer)
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(160, 160, 160), entity.Transform.Rotation, 1);
     }
     else if (bullet.Weapon.Type == WeaponType.Flamethrower)
     {
         CLifeTime lifeTime = entity.Get<CLifeTime>();
         Color color = Color.Lerp(Color.LightGoldenrodYellow, Color.OrangeRed, 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
         graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
     }
     else if (bullet.Weapon.Type == WeaponType.Waterblaster)
     {
         CLifeTime lifeTime = entity.Get<CLifeTime>();
         Color color = Color.Lerp(Color.AliceBlue, new Color(0, 69, 255), 1 - lifeTime.NormalizedTimeRemaining) * 0.75f;
         graphicsContext.SpriteBatch.DrawCentered(graphicsContext.BlankTexture, entity.Transform.Position, color * lifeTime.NormalizedTimeRemaining, 0, FlaiMath.Scale(lifeTime.NormalizedTimeRemaining, 1, 0, 8, 32));
     }
     else
     {
         graphicsContext.SpriteBatch.DrawCentered(texture, entity.Transform.Position, new Color(255, 255, 128) * 0.625f, entity.Transform.Rotation, 4);
     }
 }
示例#2
0
        public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
        {
            EntityWorld entityWorld = bullet.Entity.EntityWorld;
            IZombieSpatialMap zombieSpatialMap = entityWorld.Services.Get<IZombieSpatialMap>();

            // if the message has not listeners, then there's no point in doing in broadcasting it.
            RocketExplodedMessage explodedMessage = entityWorld.HasListeners<RocketExplodedMessage>() ? entityWorld.FetchMessage<RocketExplodedMessage>() : null; // AAWFFUUULL!!
            foreach (Entity zombie in zombieSpatialMap.GetAllIntersecting(bullet.Entity.Transform, RocketLauncher.ExplosionRange))
            {
                if (zombie.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(zombie, 25, Vector2.Zero))
                {
                    // if the message has not listeners, then there's no point in doing in broadcasting it.
                    if (explodedMessage != null)
                    {
                        explodedMessage.Add(zombie);
                    }
                }
            }

            // if the message has not listeners, then there's no point in doing in broadcasting it.
            if (explodedMessage != null)
            {
                entityWorld.BroadcastMessage(explodedMessage);
            }

            IParticleEngine particleEngine = entityWorld.Services.Get<IParticleEngine>();
            particleEngine[ParticleEffectID.RocketExplosion].Trigger(bullet.Entity.Transform);

            bullet.Entity.Delete();
            return true;
        }
示例#3
0
        public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
        {
            if (entityHit.Get<CHealth>().IsAlive && ZombieHelper.TakeDamage(entityHit, updateContext.DeltaSeconds * 10f, null))
            {
                ZombieHelper.TriggerBloodExplosion(entityHit.Transform, Vector2.Zero);
            }

            return false;
        }
示例#4
0
        public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
        {
            CBouncerBullet bouncerBullet = bullet.Entity.Get<CBouncerBullet>();
            if (bouncerBullet.HasHit(entityHit))
            {
                return false;
            }

            CVelocity2D velocity = bullet.Entity.Get<CVelocity2D>();
            if (bouncerBullet.OnHit(entityHit))
            {
                ZombieHelper.TakeDamage(entityHit, 20, velocity.Velocity / 3f);
                velocity.Direction = velocity.Direction.Rotate(Global.Random.NextFloat(-1f, 1f)); // change the direction to random
                return false;
            }

            bullet.Entity.Delete();
            return true;
        }
示例#5
0
 public virtual bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
 {
     return false;
 }
示例#6
0
 public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
 {
     ZombieHelper.TakeDamage(entityHit, 10, bullet.Transform.RotationVector * NormalBulletPrefab.DefaultSpeed / 3.5f);
     bullet.Entity.Delete();
     return true;
 }
示例#7
0
 public override bool OnBulletHitCallback(UpdateContext updateContext, CBullet bullet, Entity entityHit)
 {
     ZombieHelper.TakeDamage(entityHit, 10, bullet.Entity.Get<CVelocity2D>().Velocity / 3f);
     bullet.Entity.Delete();
     return false; // okay this shouldn't return always false. but rather like "allow 2 first hits to go through, and the stop"
 }