Exemple #1
0
        public override void Draw(SpriteBatch batch)
        {
            Color color = (Creator == null) ? Color.White : Color.Lerp(Creator.Color, Color.White, 0.5f);
            float gSize = Fmath.Sqrt(Size) + 0.1f;

            Drawing.DrawTriangle(batch, Position, new Vector2(15, 5) * gSize, Angle, color);
            float tSize = gSize * Velocity.Length() / 6f;

            Drawing.DrawBullet(batch, Position - Fmath.CosSin(Angle, (12f + tSize) / 2f * gSize), new Vector2(tSize, 6) * gSize, Angle, color);
        }
Exemple #2
0
        public override void OnCollide(Physical phys)
        {
            IsDestroyed = true;

            float sqrtSize = Fmath.Sqrt(Size);
            float aoe      = ExplosiveArea * sqrtSize;

            foreach (Physical p in Context.GetEntitiesWithin(Position, aoe))
            {
                Vector2 deltaPos = p.Position - Position;
                float   alpha    = 1f - (deltaPos.Length() / (aoe * 1.2f));
                if (alpha > 0)
                {
                    deltaPos.Normalize();
                    p.Push(deltaPos * alpha * ExplosiveForce * Size);
                    p.Hitpoints -= alpha * ExplosiveDamage * Size;
                }
            }

            Context.AddEvent(new Explosion(Position, 50f * sqrtSize, 1.5f * sqrtSize, Creator.Color));
        }