Example #1
0
        public void Test_ToString()
        {
            var pointString = new Point(1, 2, 3).ToString();

            Assert.IsTrue(pointString.Contains("1"));
            Assert.IsTrue(pointString.Contains("2"));
            Assert.IsTrue(pointString.Contains("3"));
        }
        public long GetRoadTime(Point[] points)
        {
            DBC.Assert(points.Length == 2, "Can only get the distance between 2 points.");

            if (points.Contains(PointMother.ChannelSt) && points.Contains(PointMother.EthelSt))
                return 840;

            if (points.Contains(PointMother.EthelSt) && points.Contains(PointMother.BurchellSt))
                return 1800;

            if (points.Contains(PointMother.ChannelSt) && points.Contains(PointMother.BurchellSt))
                return 2280;

            throw new Exception("Unknown points");
        }
        public long GetRoadTime(Point[] points)
        {
            DBC.Assert(points.Length == 2, "Can only get the distance between 2 points.");

            if (points.Contains(PointMother.ChannelSt) && points.Contains(PointMother.DelanceySt))
                return 480;

            if (points.Contains(PointMother.ChannelSt) && points.Contains(PointMother.BeckwithSt))
                return 660;

            if (points.Contains(PointMother.ChannelSt) && points.Contains(PointMother.ThornlandsRd))
                return 600;

            if (points.Contains(PointMother.BeckwithSt) && points.Contains(PointMother.DelanceySt))
                return 300;

            if (points.Contains(PointMother.BeckwithSt) && points.Contains(PointMother.ThornlandsRd))
                return 1020;

            if (points.Contains(PointMother.DelanceySt) && points.Contains(PointMother.ThornlandsRd))
                return 820;

            throw new Exception("Unknown points");
        }
Example #4
0
 //static public List<Point> FindPlaceRadius(Point point, int movementPoints)
 //{
 //    return FindMovementRadius(new Point[] { point }, movementPoints, FieldToPlaceMap());
 //}
 //static public List<Point> FindPlaceRadius(Point[] points, int movementPoints)
 //{
 //    return FindMovementRadius(points, movementPoints, FieldToPlaceMap());
 //}
 public static List<Point> FindPath(Point[] from, Point to, int[,] map)
 {
     List<Point> path = new List<Point>();
     path.Add(to);
     foreach (Point p in from)
         if (Math.Abs(p.Y - to.Y) + Math.Abs(p.X - to.X) == 1)
         {
             return path;
         }
     while (!from.Contains(to))
     {
         if (to.Y - 1 >= 0 && map[to.Y - 1, to.X] == map[to.Y, to.X] - 1)
         {
             to = new Point(to.X, to.Y - 1);
             path.Add(to);
         }
         else if (to.X + 1 < GameLogic.Field.Width && map[to.Y, to.X + 1] == map[to.Y, to.X] - 1)
         {
             to = new Point(to.X + 1, to.Y);
             path.Add(to);
         }
         else if (to.Y + 1 < GameLogic.Field.Height && map[to.Y + 1, to.X] == map[to.Y, to.X] - 1)
         {
             to = new Point(to.X, to.Y + 1);
             path.Add(to);
         }
         else if (to.X - 1 >= 0 && map[to.Y, to.X - 1] == map[to.Y, to.X] - 1)
         {
             to = new Point(to.X - 1, to.Y);
             path.Add(to);
         }
         else break;
     }
     return path;
 }
Example #5
0
        //檢查一群組所有的格網點是否連續(上下左右視為連續,對角與間隔視為不連續))
        public static bool IsContinuous(List<Point> pl)
        {
            if(pl.Count == 0)
            {
                return false;
            }

            Point[] workQueue = new Point[pl.Count];
            workQueue[0] = pl[0];
            for (int i = 1; i < workQueue.Length; ++i)
            {
                workQueue[i].X = -1;
                workQueue[i].Y = -1;
            }
            int ptr = 1;
            for (int i = 0; i < workQueue.Length; ++i)
            {
                Point p0 = workQueue[i];
                if (-1 == p0.X)
                {
                    break;
                }

                Point p1 = new Point(p0.X, p0.Y - 1);
                Point p2 = new Point(p0.X, p0.Y + 1);
                Point p3 = new Point(p0.X - 1, p0.Y);
                Point p4 = new Point(p0.X + 1, p0.Y);

                foreach (Point p in pl)
                {
                    if (p1 == p)
                    {
                        if (!workQueue.Contains(p1))
                        {
                            workQueue[ptr++] = p1;
                        }
                    }
                    if (p2 == p)
                    {
                        if (!workQueue.Contains(p2))
                        {
                            workQueue[ptr++] = p2;
                        }
                    }
                    if (p3 == p)
                    {
                        if (!workQueue.Contains(p3))
                        {
                            workQueue[ptr++] = p3;
                        }
                    }
                    if (p4 == p)
                    {
                        if (!workQueue.Contains(p4))
                        {
                            workQueue[ptr++] = p4;
                        }
                    }
                }
            }
            return (ptr == pl.Count);
        }
Example #6
0
        public int CountNumberOfOpenNeighbors(Point[] cells)
        {
            var open = 0;

            foreach (var cell in cells)
            {
                foreach (var neighbor in GetNeighboringPoints(cell))
                {
                    if (neighbor.X >= 0 && neighbor.X < BoardState.Width && neighbor.Y >= 0 &&
                        neighbor.Y < BoardState.Height &&
                        !BoardState.Cells[neighbor.X, neighbor.Y] && !cells.Contains(neighbor))
                        open++;
                }
            }

            return open;
        }
Example #7
0
        public int CheckRemovedLines(Point[] cells, int minHeight, int maxHeight)
        {
            var removedLines = 0;
            for (var i = minHeight; i <= maxHeight; i++)
            {
                var removed = true;
                for (var j = 0; j < BoardState.Width; j++)
                {
                    if (!BoardState.Cells[j, i] && !cells.Contains(new Point(j, i)))
                    {
                        removed = false;
                        break;
                    }
                }

                if (removed)
                    removedLines++;
            }

            return removedLines;
        }
        public long GetRoadTime(Point[] points)
        {
            DBC.Assert(points.Length == 2, "Can only get the distance between 2 points.");

            if (points.Contains(PointMother.USAPoints.LocustSt) && points.Contains(PointMother.USAPoints.AshworthRd))
                return 660;

            if (points.Contains(PointMother.USAPoints.LocustSt) && points.Contains(PointMother.USAPoints.UniversityAve))
                return 180;

            if (points.Contains(PointMother.USAPoints.LocustSt) && points.Contains(PointMother.USAPoints.RaccoonSt))
                return 480;

            if (points.Contains(PointMother.USAPoints.LocustSt) && points.Contains(PointMother.USAPoints.ShawSt))
                return 360;

            if (points.Contains(PointMother.USAPoints.AshworthRd) && points.Contains(PointMother.USAPoints.UniversityAve))
                return 600;

            if (points.Contains(PointMother.USAPoints.AshworthRd) && points.Contains(PointMother.USAPoints.RaccoonSt))
                return 840;

            if (points.Contains(PointMother.USAPoints.AshworthRd) && points.Contains(PointMother.USAPoints.ShawSt))
                return 780;

            if (points.Contains(PointMother.USAPoints.UniversityAve) && points.Contains(PointMother.USAPoints.RaccoonSt))
                return 480;

            if (points.Contains(PointMother.USAPoints.UniversityAve) && points.Contains(PointMother.USAPoints.ShawSt))
                return 420;

            if (points.Contains(PointMother.USAPoints.RaccoonSt) && points.Contains(PointMother.USAPoints.ShawSt))
                return 120;

            throw new Exception("Unknown points");
        }
Example #9
0
        private Point CheckAround(Point toCheck, Point[] lastPoints)
        {
            //Check in a square around the last point for new pixels
            for (int i = 0; i <= 7; i++)
            {
                //Get which point to check next
                Point delta = Delta(i);
                Point check = new Point(toCheck.X + delta.X, toCheck.Y + delta.Y);

                //Check if the vinyl contains the point
                if (!VinylContains(check))
                    continue;

                //Check if the point should not be ignored and isn't in the last points
                if (!IgnoreColor(GetColor(check)) && !lastPoints.Contains(check))
                    return check;
            }

            return Point.Empty;
        }