コード例 #1
0
 public ColorWaypointDrawer(Color startColor, Color endColor, WaypointMap map, Point scale)
 {
     myScale = scale;
     StartColor = startColor;
     EndColor = endColor;
     Map = map;
 }
コード例 #2
0
 public AStarNode(int movementCost, int heuristicCost, AStarNode parent, Point coord)
 {
     TotalCost = movementCost + heuristicCost;
     MovementCost = movementCost;
     HeuristicCost = heuristicCost;
     Parent = parent;
     Coordinate = coord;
 }
コード例 #3
0
 public WaypointMap(Color startColor, Color endColor, Waypoint[] points, Point scale)
 {
     myScale = scale;
     Waypoints = new List<Waypoint>();
     for (int index = 0; index < points.Length; index++) {
         Add(points[index]);
     }
     Drawer = new ColorWaypointDrawer(startColor, endColor, this, scale);
 }
コード例 #4
0
        public IEnumerable<Point> Travel(int stepsTotal, Point scale, bool reverse)
        {
            DoublePoint cur = new DoublePoint(0, 0);
            DoublePoint dist = new DoublePoint(0, 0);

            double stp = ( (double) stepsTotal / ( (double) Waypoints.Count - 1 ) );

            if (reverse) {
                for (int index = Waypoints.Count - 1; index >= 1; index--) {
                    var waypoint = Waypoints[index];
                    var nextWaypoint = Waypoints[index - 1];

                    cur.X = waypoint.X * scale.X;
                    cur.Y = waypoint.Y * scale.Y;

                    dist.X = ( (double) nextWaypoint.X - waypoint.X ) / stp;
                    dist.Y = ( (double) nextWaypoint.Y - waypoint.Y ) / stp;

                    for (int i = 0; i < stp; i++) {
                        cur.X += dist.X * scale.X;
                        cur.Y += dist.Y * scale.Y;
                        yield return new Point((int) cur.X, (int) cur.Y);
                    }
                }
            } else {
                for (int index = 0; index < Waypoints.Count - 1; index++) {
                    var waypoint = Waypoints[index];
                    var nextWaypoint = Waypoints[index + 1];

                    cur.X = waypoint.X * scale.X;
                    cur.Y = waypoint.Y * scale.Y;

                    dist.X = ( (double) nextWaypoint.X - waypoint.X ) / stp;
                    dist.Y = ( (double) nextWaypoint.Y - waypoint.Y ) / stp;

                    for (int i = 0; i < stp; i++) {
                        cur.X += dist.X * scale.X;
                        cur.Y += dist.Y * scale.Y;
                        yield return new Point((int) cur.X, (int) cur.Y);
                    }
                }
            }
        }
コード例 #5
0
ファイル: GameDrawer.cs プロジェクト: noobouse/ShufflySharp
        private void newDrawArea(GameCardGame mainArea)
        {
            //jQuery.Select("#dvGame").Children().Remove();

            var scale = new Point(Document.DocumentElement.ClientWidth / mainArea.Size.Width * .9, ( Document.DocumentElement.ClientHeight - 250 ) / mainArea.Size.Height * .9);
            //ExtensionMethods.debugger(null);
            var sl = mainArea.Spaces.Count;
            /*
                        for (int spaceIndex = 0; spaceIndex < sl; spaceIndex++)
                        {
                            var space = mainArea.Spaces[spaceIndex];
                            var jf = findSpace(space).OuterElement;

                            for (int i = 0; i < resetStyles.Length; i++)
                            {
                                jf.Style[resetStyles[i]] = null;
                            }

                            l = space.Pile.Cards.Count;
                            for (int index = 0; index < l; index++)
                            {
                                var card = space.Pile.Cards[index];
                                var m = findCard(space, card);

                                for (int i = 0; i < resetStyles.Length; i++)
                                {
                                    m.OuterElement.Style[resetStyles[i]] = null;
                                    m.Image.Style[resetStyles[i]] = null;
                                }
                            }
                        }
            */

            for (int index = 0; index < sl; index++) {
                var space = mainArea.Spaces[index];
                var vertical = space.Vertical;

                var spaceDiv = findSpace(space);
                // var spaceDivJ = jQuery.FromElement(spaceDiv);

                //ExtensionMethods.debugger();
                var cl = space.Appearance.Effects.Count;
                for (int i = 0; i < cl; i++) {
                    var effect = space.Appearance.Effects[i];
                    effect.Build(spaceDiv);
                }

                spaceDiv.OuterElementStyle.Width = ( space.Width * scale.X ).px();
                spaceDiv.OuterElementStyle.Height = ( space.Height * scale.Y ).px();

                //   gameboard.Context.FillRect(space.X * scale.X, space.Y * scale.Y, space.Width * scale.X, space.Height * scale.Y);

                var spaceScale = new Point(space.Width / space.Pile.Cards.Count, space.Height / space.Pile.Cards.Count);

                var j = 0;
                var numOfCards = space.Pile.Cards.Count;
                for (int i = 0; i < numOfCards; i++) {
                    var card = space.Pile.Cards[i];
                    var xx = 0.0;
                    var yy = 0.0;

                    switch (space.ResizeType) {
                        case TableSpaceResizeType.Static:
                            if (vertical)
                                yy = card.Value * scale.Y / 2;
                            else
                                xx = card.Value * scale.X / 2;

                            break;

                        case TableSpaceResizeType.Grow:
                            xx = ( !vertical ? ( j * spaceScale.X * scale.X ) : 0 );
                            yy = ( vertical ? ( j * spaceScale.Y * scale.Y ) : 0 );
                            break;
                        default:
                            xx = ( !vertical ? ( j * spaceScale.X * scale.X ) : 0 );
                            yy = ( vertical ? ( j * spaceScale.Y * scale.Y ) : 0 );

                            break;
                    }

                    var cardDiv = findCard(space, card);
                    xx -= cardDiv.OuterElementStyle.Width.nopx() / 2;
                    yy -= cardDiv.OuterElementStyle.Height.nopx() / 2;
                    cardDiv.OuterElementStyle.BorderRadius = "5px";
                    cardDiv.OuterElementStyle.BoxShadow = "3px 3px 2px #2c2c2c";

                    styleAppearanceFromSpace(cardDiv, j, space);
                    styleAppearance(cardDiv, card.Appearance);

                    spaceDiv.OuterElementStyle.Left = ( ( space.X ) * scale.X ).px();
                    spaceDiv.OuterElementStyle.Top = ( ( space.Y ) * scale.Y ).px();

                    //cardDiv.OuterElement.Style["transform"] = 0.0.TransformRotate();
                    cardDiv.OuterElementStyle.Left = ( xx + ( vertical ? space.Width * scale.X / 2 : 0 ) ).px();
                    cardDiv.OuterElementStyle.Top = ( yy + ( !vertical ? space.Height * scale.Y / 2 : 0 ) ).px();
                    cardDiv.OuterElementStyle.Transform = space.Appearance.InnerStyle.Rotate.TransformRotate();

                    cardDiv.OuterElementStyle.SetStyle(cardDiv.OuterElement);

                    FixBrowserPrefixes(cardDiv.OuterElement.Style);
                    //                    spaceDiv.AppendChild(cardDiv);

                    j++;

                    //effects
                }

                var el = space.Appearance.Effects.Count;
                for (int i = 0; i < el; i++) {
                    var effect = space.Appearance.Effects[i];
                    effect.TearDown(spaceDiv);
                }
            }

            foreach (var space in mainArea.Spaces) {
                findSpace(space).OuterElementStyle.SetStyle(findSpace(space).OuterElement);

                foreach (var card in space.Pile.Cards) {
                    //                    var m = findCard(space, card);
                    findSpace(space).OuterElementStyle.SetStyle(findSpace(space).OuterElement);

                    /*
                                        m.ImageStyle = new MyStyle();
                                        m.OuterElementStyle = new MyStyle();
                    */
                }
            }

            /*

            foreach (var ta in mainArea.TextAreas)
            {
                gameboard.Context.FillStyle = "rgba(200, 0, 200, 0.5)";
                gameboard.Context.FillText(ta.Text, ta.X * scale.X, ta.Y * scale.Y);
            }*/
        }
コード例 #6
0
 public List<Point> Travel(int steps, Point scale)
 {
     return new List<Point>(Map.Travel(steps, scale, Map.Last() == this));
 }
コード例 #7
0
 public bool MouseUp(Pointer e)
 {
     foreach (var j in points) {
         j.Editing = false;
     }
     Editing = false;
     Dragging = false;
     StartDragging = null;
     dragg = null;
     return false;
 }
コード例 #8
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;
        }
コード例 #9
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;
        }
コード例 #10
0
 public bool Intersects(Point p)
 {
     return X < p.X && X + Width > p.X && Y < p.Y && Y + Height > p.Y;
 }
コード例 #11
0
 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;
 }