public static bool IntersectRect(Rectangle r1, Rectangle r2)
 {
     return !( r2.X > r1.X + r1.Width ||
               r2.X + 0 < r1.X ||
               r2.Y > r1.Y + r1.Height ||
               r2.Y + 0 < r1.Y );
 }
Ejemplo n.º 2
0
 public GameManager(Action<string, Action<UserModel, ChannelMessage>> receiveChannelMessage, Action<ChannelMessage> sendChannelMessage)
 {
     ReceiveChannelMessage = receiveChannelMessage;
     SendChannelMessage = sendChannelMessage;
     //  game = new TowerD.Client.Game();
     game = new Game();
     game.ReceiveChannelMessage = ReceiveChannelMessage;
     game.SendChannelMessage = SendChannelMessage;
     // game = new ZakGame.Client.Game();
     Screen = new Rectangle(0, 0, 0, 0);
 }
Ejemplo n.º 3
0
        public bool MouseOver(Pointer e)
        {
            var x = 0;
            var y = 0;
            var w = Element.Width;
            var h = Element.Height;

            Document.Body.Style.Cursor = "move";
            if (Dragging) {
            /*
                if (this.Element.ChildrenAreEditing())
                {
                    return false;
                }
            */
                var jx = e.X - dragg.X;
                var jy = e.Y - dragg.Y;
                Element.X += jx;
                Element.Y += jy;

                /*   window.DEBUGLABELS[0] = "E: " + e.X + " " + e.Y;
                   window.DEBUGLABELS[1] = "Dragg: " + this.dragg.X + " " + this.dragg.Y;
                   window.DEBUGLABELS[2] = "Element: " + this.Element.X + " " + this.Element.Y;
                   window.DEBUGLABELS[3] = "Offset: " + jx + " " + jy;*/
                //this.dragg.x += jx;
                //this.dragg.y += jy;

                return false;
            }
            foreach (var j in points) {
                var sz = j.Size * 5;

                if (j.Editing) {
                    Document.Body.Style.Cursor = j.Cursor;
                    var dv = new Point(StartDragging.X - e.X, StartDragging.Y - e.Y);

                    j.Click(dv);
                    StartDragging = new Point(e.X + dv.X, e.Y + dv.Y);
                    return true;
                }

                var rect = new Rectangle(x + ( w * j.X / 100 ) - sz / 2, y + ( h * j.Y / 100 ) - sz / 2, sz, sz);

                if (e.X > rect.X && e.X < rect.X + rect.Width && e.Y > rect.Y && e.Y < rect.Y + rect.Height) {
                    Document.Body.Style.Cursor = j.Cursor;

                    if (j.Editing) {
                        var dv = new Point(StartDragging.X - e.X, StartDragging.Y - e.Y);

                        j.Click(dv);
                        StartDragging = new Point(e.X + dv.X, e.Y + dv.Y);
                    }
                    return true;
                }
            }

            StartDragging = new Point(e.X, e.Y);
            return Editing;
        }
Ejemplo n.º 4
0
        public bool Click(Pointer e)
        {
            var x = 0;
            var y = 0;
            var w = Element.Width;
            var h = Element.Height;

            //uiManager.propertyList.populate(this.Element);

            foreach (var j in points) {
                j.Editing = false;
            }

            foreach (var j in points) {
                var sz = j.Size * 5;

                var rect = new Rectangle(x + ( w * j.X / 100 ) - sz / 2, y + ( h * j.Y / 100 ) - sz / 2, sz, sz);

                if (e.X > rect.X && e.X < rect.X + rect.Width && e.Y > rect.Y && e.Y < rect.Y + rect.Height) {
                    Document.Body.Style.Cursor = j.Cursor;
                    StartDragging = new Point(e.X, e.Y);
                    Editing = true;
                    j.Editing = true;
                    return true;
                }
            }

            if (e.X > x && e.X < x + w && e.Y > y && e.Y < y + h) {
                dragg = new Point(e.X, e.Y);
                Document.Body.Style.Cursor = "move";
                Dragging = true;
                return false;
            } else
                Document.Body.Style.Cursor = "default";
            return false;
        }
 public static bool IntersectsRect(Rectangle r, Point p)
 {
     return r.X < p.X && r.X + r.Width > p.X && r.Y < p.Y && r.Y + r.Height > p.Y;
 }