Beispiel #1
0
        public bool IntersectsBuilding(System.Drawing.Rectangle rect)
        {
            foreach (var bld in Buildings)
                {
                            if (rect.IntersectsWith(bld.PositionRect)) return true;

                }
            if (rect.X + rect.Width > Width || rect.Y + rect.Height > Height)
                return true;
            else
                return false;
        }
        private bool ProcessPlayerCollisions(float dt, System.Drawing.RectangleF newPosition)
        {
            bool hit = false;
            bool enemyHit = false;

            // check to see if the player has colided with any of the walls, or other objects
            foreach (gameObjects.BaseGameObject b in this.gv.obstacles)
            {

                if (newPosition.IntersectsWith(b.Position) )
                {

                    // temporary until more logic is added.
                    hit = true;

                }
            }

            // check to see if the player has collided with any of the enemies
            foreach (gameObjects.BaseGameObject b in this.gv.enemies)
            {
                if (gv.ship.Intersect(b))
                {
                    b.IsAlive = false;
                    gv.effects.Add(new gameObjects.Explosion(b.Position.X, b.Position.Y));

                    if (this.gv.safeTimer < 0.0f)
                    {
                        gv.effects.Add(new gameObjects.Explosion(gv.ship.Position.X, gv.ship.Position.Y));
                        enemyHit = true;

                    }

                    break;
                }
            }

            //could also do a check to see if the player has collided with any explosions...

            // check to see if the player has run into any projectiles
            foreach (gameObjects.BaseGameObject b in this.gv.projectiles)
            {
                if (this.gv.ship.Intersect(b))
                {
                    if (this.gv.safeTimer < 0.0f)
                    {
                        gv.effects.Add(new gameObjects.Explosion(gv.ship.Position.X, gv.ship.Position.Y));
                        enemyHit = true;

                    }
                    break;
                }
            }

            // if the player has been hit at all, by something other than a wall, take off a life
            // and subtract a credit.
            if (enemyHit)
            {
                this.gv.playerCredits -= 1;
                this.StartRound();
            }
            return hit;
        }
        public override void Paint(Gdk.Drawable wnd, System.Drawing.Rectangle rect)
        {
            HighlightColor lineNumberPainterColor = textArea.Document.HighlightingStrategy.GetColorFor("LineNumbers");

            Gdk.Color rect_fg = TextArea.Style.White;
            Gdk.Color text_fg = new Gdk.Color (lineNumberPainterColor.Color);
            Gdk.Color text_bg = new Gdk.Color (lineNumberPainterColor.BackgroundColor);

            using (Gdk.GC gc = new Gdk.GC(wnd)) {
            for (int y = 0; y < (DrawingPosition.Height + textArea.TextView.VisibleLineDrawingRemainder) / textArea.TextView.FontHeight + 1; ++y) {

                gc.RgbFgColor = rect_fg;
                System.Drawing.Rectangle markerRectangle = new System.Drawing.Rectangle(DrawingPosition.X, DrawingPosition.Top + y * textArea.TextView.FontHeight - textArea.TextView.VisibleLineDrawingRemainder, DrawingPosition.Width, textArea.TextView.FontHeight);

                if (rect.IntersectsWith(markerRectangle)) {
                    wnd.DrawRectangle (gc, true, new System.Drawing.Rectangle (markerRectangle.X + 1, markerRectangle.Y, markerRectangle.Width - 1, markerRectangle.Height));

                    int currentLine = textArea.TextView.FirstVisibleLine + y;
                    PaintFoldMarker(wnd, currentLine, markerRectangle);
                } //Using
            }
            }
        }
        public override void Paint(Gdk.Drawable g, System.Drawing.Rectangle rect)
        {
            using (Gdk.GC backgroundGC = new Gdk.GC(g)) {
            using (Gdk.GC gc = new Gdk.GC(g)) {

            int horizontalDelta = (int)(textArea.VirtualTop.X * GetWidth(g, ' '));
            if (horizontalDelta > 0) {
                Gdk.Rectangle r = new Gdk.Rectangle(this.DrawingPosition.X, this.DrawingPosition.Y, this.DrawingPosition.Width, this.DrawingPosition.Height);
                gc.ClipRectangle = r;
                backgroundGC.ClipRectangle = r;
            }

            for (int y = 0; y < (DrawingPosition.Height + VisibleLineDrawingRemainder) / fontHeight + 1; ++y) {
                System.Drawing.Rectangle lineRectangle = new System.Drawing.Rectangle(DrawingPosition.X - horizontalDelta,
                                                        DrawingPosition.Top + y * fontHeight - VisibleLineDrawingRemainder,
                                                        DrawingPosition.Width + horizontalDelta,
                                                        fontHeight);
                if (rect.IntersectsWith(lineRectangle)) {
                    int currentLine = FirstVisibleLine + y;
                    PaintDocumentLine(g, gc, backgroundGC, currentLine, lineRectangle);
                }
            }
            }} // using
        }