Ejemplo n.º 1
0
        public Explosion(Vector2 position)
        {
            Position = position;

            image = new Image(TestProject.Assets.GetTexture("ExplosionTexture"), false);
            image.CenterOrigin();
            image.Scale *= 2;
            Add(image);

            Collider = new CircleMask(image.Width / 2);
            Tag(TAG);

            Tween.Add(this, 15, Ease.SineIn, FadeOut).OnComplete = Destroy;
            Alarm.Add(this, SetNoCollidable, 2);
        }
Ejemplo n.º 2
0
 public abstract bool Collide(CircleMask mask, float dx = 0, float dy = 0);
Ejemplo n.º 3
0
 public override bool Collide(CircleMask mask, float dx = 0, float dy = 0)
 {
     return Calc.DistanceSquared(AbsoluteX + dx, AbsoluteY + dy, mask.AbsoluteX, mask.AbsoluteY)
         <= (Radius + mask.Radius) * (Radius + mask.Radius);
 }
Ejemplo n.º 4
0
        public override bool Collide(CircleMask mask, float dx = 0, float dy = 0)
        {
            Rectangle range = mask.Bounds;
            range.Offset((int)(-AbsoluteLeft - dx), (int)(-AbsoluteTop - dy));

            int xStart = (int)(range.X / CellWidth);
            int yStart = (int)(range.Y / CellHeight);
            int xEnd = (int)((range.X + range.Width - 1) / CellWidth);
            int yEnd = (int)((range.Y + range.Height - 1) / CellHeight);

            Rectangle box = new Rectangle(0, 0, (int)CellWidth, (int)CellHeight);
            Vector2 shiftedPosition;

            for(int x = xStart; x <= xEnd; ++x)
                for (int y = yStart; y <= yEnd; ++y)
                {
                    if (this[x, y])
                    {
                        box.X = (int)(x * CellWidth + AbsoluteLeft + dx);
                        box.Y = (int)(y * CellHeight + AbsoluteTop + dy);
                        shiftedPosition = box.Closest(mask.AbsolutePosition);
                        if (shiftedPosition.LengthSquared(mask.AbsolutePosition) <= (mask.Radius * mask.Radius))
                            return true;
                    }
                }

            return false;
        }
Ejemplo n.º 5
0
        public override bool Collide(CircleMask mask, float dx = 0, float dy = 0)
        {
            if (Collide(mask.AbsolutePosition, dx, dy))
                return true;

            Vector2 checkPosition = Bounds.Closest(mask.AbsolutePosition);
            if (mask.Collide(checkPosition, -dx, -dy))
                return true;

            return false;
        }