예제 #1
0
        public bool IsCollidedWithHitbox(Hitbox b)
        {
            if (!Enabled || !b.Enabled)
            {
                return(false);
            }
            PointF[] apoints = new PointF[this.Points.Length];
            for (int i = 0; i < apoints.Length; i++)
            {
                apoints[i] = Game.GameToScreenCoordinates(this.Points[i] + this.Owner.Position + this.Offset, 0, 0);
            }
            PointF[] bpoints = new PointF[b.Points.Length];
            for (int i = 0; i < bpoints.Length; i++)
            {
                bpoints[i] = Game.GameToScreenCoordinates(b.Points[i] + b.Owner.Position + b.Offset, 0, 0);
            }

            foreach (var axis in this.Normals().Concat(b.Normals()))
            {
                float mina = 0;
                float maxa = 0;
                float minb = 0;
                float maxb = 0;
                Project(axis, apoints, ref mina, ref maxa);
                Project(axis, bpoints, ref minb, ref maxb);

                if (minb > maxa || mina > maxb)
                {
                    DrawColor = Color.LimeGreen;
                    return(false);
                }
            }
            DrawColor = Color.HotPink;
            return(true);
        }
예제 #2
0
        public void Draw(Graphics G)
        {
            if (Model != null)
            {
                PointF ScreenPosition      = Game.GameToScreenCoordinates(new PointF(Owner.Position.X + this.OffsetX, Owner.Position.Y + this.OffsetY), Width, Height);
                PointF OwnerScreenPosition = Game.GameToScreenCoordinates(Owner.Position, 0, 0);

                var prev_state = G.Save();
                if (RotateAboutOwner)
                {
                    G.TranslateTransform(OwnerScreenPosition.X, OwnerScreenPosition.Y);
                    G.RotateTransform(-Rotation);
                    G.TranslateTransform(-OwnerScreenPosition.X, -OwnerScreenPosition.Y); //Apply Rotation
                }
                else
                {
                    G.TranslateTransform(ScreenPosition.X + Width / 2, ScreenPosition.Y + Height / 2);
                    G.RotateTransform(-Rotation);
                    G.TranslateTransform(-ScreenPosition.X - Width / 2, -ScreenPosition.Y - Height / 2); //Apply Rotation
                }

                G.DrawImage(Model, ScreenPosition);
                G.Restore(prev_state);
            }
        }
예제 #3
0
 public void Draw(Graphics G)
 {
     for (int i = 0; i < Points.Length; i++)
     {
         PointF p1 = Game.GameToScreenCoordinates(Owner.Position + Points[i] + Offset, 0, 0);
         PointF p2 = Game.GameToScreenCoordinates(Owner.Position + Points[(i + 1) % Points.Length] + Offset, 0, 0);
         G.DrawLine(new Pen(DrawColor, 1), p1, p2);
     }
 }
예제 #4
0
        public void Draw(Graphics g)
        {
            for (int i = 0; i < Particles.Count; i++)
            {
                Particle p              = Particles[i];
                PointF   Position       = p.Position;
                PointF   ScreenPosition = Game.GameToScreenCoordinates(Position, 0, 0);

                Brush b = new SolidBrush(
                    Color.FromArgb((int)(255 * p.SecondsLeft / ParticleDuration),
                                   c));
                g.FillEllipse(b, ScreenPosition.X, ScreenPosition.Y, ParticleSize, ParticleSize);
            }
        }
예제 #5
0
        public override void Draw(Graphics g, PointF Dimensions)
        {
            base.Draw(g, Dimensions);

            int ToGen = r.Next(0, Intensity);

            for (int i = 0; i < ToGen; i++)
            {
                if (Particles.Count <= Intensity && r.Next(0, 101) <= 1)
                {
                    Particle p = new Particle();
                    p.Position = new PointF(this.Position.X, this.Position.Y);
                    float Distance = (float)r.NextDouble() * Radius;
                    float Angle    = (float)(r.NextDouble() * 2 * Math.PI);
                    p.Position.X += Distance * (float)Math.Cos(Angle);
                    p.Position.Y += Distance * (float)Math.Sin(Angle);
                    p.FramesLeft  = p.TotalLifetime = ParticleDuration;
                    Particles.Add(p);
                }
            }
            for (int i = 0; i < Particles.Count; i++)
            {
                Particle p              = Particles[i];
                PointF   Position       = p.Position;
                PointF   ScreenPosition = Game.GameToScreenCoordinates(Position, Dimensions, 0, 0);

                Brush b = new SolidBrush(
                    Color.FromArgb((int)(255 * (float)p.FramesLeft / (float)p.TotalLifetime),
                                   c));
                g.FillEllipse(b, ScreenPosition.X, ScreenPosition.Y, ParticleSize, ParticleSize);
                p.FramesLeft -= 1;

                if (p.FramesLeft == 0)
                {
                    Particles.RemoveAt(i--);
                }
            }
        }
예제 #6
0
 public override void Draw(Graphics g, PointF Dimensions)
 {
     base.Draw(g, Dimensions);
     g.DrawString(this.Text, F, new SolidBrush(C), Game.GameToScreenCoordinates(this.Position, Dimensions, size * Text.Length, size));
 }