private MoveLocation[,] ParseIntMoves(int[,] m)
        {
            MoveLocation[,] temp = new MoveLocation[m.GetLength(0), m.GetLength(1)];
            for (int i = 0; i < temp.GetLength(0); i++)
            {
                for (int j = 0; j < temp.GetLength(1); j++)
                {
                    if (m[i, j] == -999)
                        temp[i, j] = null;
                    else
                    {
                        int tempX = -1;
                        int tempY = -1;
                        int locX = 0;
                        int locY = 0;
                        int dist = int.MaxValue;
                        int tempDist = 0;
                        int midX = temp.GetLength(0) / 2;
                        int midY = temp.GetLength(1) / 2;

                        temp[i, j] = new MoveLocation(m[i, j]);
                        for (int k = 0; k < 9; k++)
                        {
                            locX = (k % 3) - 1;
                            locY = (int)(k / 3) - 1;
                            if ((locX + i >= 0 && locX + i < temp.GetLength(0)) && (locY + j >= 0 && locY + j < temp.GetLength(1)) && (m[locX + i, locY + j] != -999))
                            {
                                tempDist = (((locX + i) - midX) * ((locX + i) - midX)) + (((locY + j) - midY) * ((locY + j) -midY));
                                if (tempDist < dist)
                                {
                                    tempX = locX + i;
                                    tempY = locY + j;
                                    dist = tempDist;
                                }
                            }
                        }
                        numberOfMoves++;

                        if (tempX != -1 && tempY != -1)
                        {
                            temp[i, j].x = tempX;
                            temp[i, j].y = tempY;
                        }
                    }
                }
            }
            return temp;
        }
Beispiel #2
0
 public bool TestRecursiveCardMovement(CardClass card, Vector2 cardLoc, MoveLocation currentLoc, MoveLocation[,] map, int transX, int transY)
 {
     return RecursiveCardMovement(card, cardLoc, currentLoc, map, transX, transY, 0, false);
 }
Beispiel #3
0
        private bool RecursiveCardMovement(CardClass card, Vector2 cardLoc, MoveLocation currentLoc, MoveLocation[,] map, int transX, int transY, uint ID, bool place)
        {
            if (transX == 2 && transY == 2)
            {
                return true;
            }

            bool placed = false;

            Stack<MoveLocation> order = new Stack<MoveLocation>(2);
            while (currentLoc.x >= 0 && currentLoc.y >= 0 && !(currentLoc.x == 2 && currentLoc.y == 2))
            {
                order.Push(currentLoc);
                currentLoc = map[currentLoc.x, currentLoc.y];
            }
            order.Push(currentLoc);

            MoveLocation next;
            while (order.Count > 1)
            {
                currentLoc = order.Pop();
                next = order.Peek();
                if (place)
                {
                    placed = PlaceCard(card, (int)cardLoc.X + next.y - 2, (int)cardLoc.Y + next.x - 2, next.y, next.x, ID, place) || placed;
                }
                else
                {
                    placed = PlaceCard(card, (int)cardLoc.X + next.y - 2, (int)cardLoc.Y + next.x - 2, next.y, next.x, ID, place);
                }
                if (!placed)
                    return placed;
            }

            //if (currentLoc.x >= 0 && currentLoc.y >= 0 && !(currentLoc.x == 2 && currentLoc.y == 2))
            //{
            //    if (!RecursiveCardMovement(card, cardLoc, map[currentLoc.x, currentLoc.y], map, currentLoc.y, currentLoc.x))
            //        return recurse;
            //}
            ////PlaceCard(selectedCard, (int)mapLoc.X, (int)mapLoc.Y, moveOption[transY, transX].modifier)

            if (place)
            {
                placed = PlaceCard(card, (int)cardLoc.X + transX - 2, (int)cardLoc.Y + transY - 2, transX, transY, ID, place) || placed;
            }
            else
            {
                placed = PlaceCard(card, (int)cardLoc.X + transX - 2, (int)cardLoc.Y + transY - 2, transX, transY, ID, place);
            }

            return placed;
        }
Beispiel #4
0
 public bool RecursiveCardMovement(CardClass card, Vector2 cardLoc, MoveLocation currentLoc, MoveLocation[,] map, int transX, int transY, uint ID)
 {
     return RecursiveCardMovement(card, cardLoc, currentLoc, map, transX, transY, ID, true);
 }