示例#1
0
        private MapLibrary.Point IsArrived(Point gridPoint)
        {
            if (!((CaveCard)field.GetCard(ConvertLocationToCoords(gridPoint))).getIsConnected())
            {
                return(null);
            }

            MapLibrary.Point coords = ConvertLocationToCoords(gridPoint);
            int[]            dir    = { 0, -1, 0, 1, 0 };

            for (int i = 0; i < dir.Length - 1; i++)
            {
                int r = coords.R + dir[i], c = coords.C + dir[i + 1];

                if (field.GetCard(r, c) is DestCard)
                {
                    if (field.CanBeConntectedSurrounding(coords, (CaveCard)field.GetCard(r, c)))
                    {
                        return(new MapLibrary.Point(r, c));
                    }
                }
            }

            return(null);
        }
示例#2
0
        private void SetPredictionRect(int X, int Y)
        {
            if (this.selectedCard == null)
            {
                return;
            }

            Point?gridPoint = GetGridPoint(X, Y);

            if (gridPoint.HasValue)
            {
                Point point = (Point)gridPoint;
                if (rectPrev.X != point.X || rectPrev.Y != point.Y)
                {
                    EraseGraphics();
                    ShowGrid();

                    MapLibrary.Point coords = ConvertLocationToCoords(point);

                    rectPrev.X = point.X; rectPrev.Y = point.Y;
                    Rectangle rect = new Rectangle(point.X, point.Y, cardWidth, cardHeight);

                    Brush brush = new SolidBrush(Grid_Impossible);

                    if (field.IsValidPosition(coords, (CaveCard)this.selectedCard))
                    {
                        brush = new SolidBrush(Grid_Possible);
                    }

                    g.FillRectangle(brush, rect);
                }
            }
        }
示例#3
0
        // Release on Grid
        private bool ProcessGrid(Point gridPoint)
        {
            // is CaveCard
            if (this.selectedCard is CaveCard)
            {
                MapLibrary.Point coords;
                Attach(gridPoint, (CaveCard)this.selectedCard);
                RemoveFromHands();

                coords = IsArrived(gridPoint);

                // if arrived at destcard
                if (coords != null)
                {
                    field.GetCard(coords).face = CardFace.FRONT;
                }
            }

            // is RockDownCard
            else if (this.selectedCard is RockDownCard)
            {
                MapLibrary.Point coords = ConvertLocationToCoords(gridPoint);
                if (field.isValidated(coords) || field.GetCard(coords) is StartCard || field.GetCard(coords) is DestCard)
                {
                    MoveToStartPosition(this.selectedPic);
                    return(false);
                }
                else if (field.GetCard(coords) is CaveCard)
                {
                    if (((CaveCard)field.GetCard(coords)).getDir() != Dir.NONE)
                    {
                        field.RockDown(coords);
                        this.selectedCard.face = CardFace.FRONT;
                        this.usedCard.Push(this.selectedCard);
                        DeleteImage(coords.R, coords.C);
                        DeleteImage(this.selectedPic);
                        RemoveFromHands();
                    }
                    else
                    {
                        MoveToStartPosition(selectedPic);
                        return(false);
                    }
                }
            }

            // is MapCard
            else if (this.selectedCard is MapCard)
            {
                MapLibrary.Point coords = ConvertLocationToCoords(gridPoint);
                CaveCard         card   = field.GetCard(coords);
                if (card is DestCard)
                {
                    //string message = ((DestCard)card).getIsGoldCave() ? "금 카드입니다!" : "금 카드가 아닙니다!";
                    var image = ((DestCard)card).getIsGoldCave() ? Properties.Resources.goal_gold : Properties.Resources.goal_stone_down_left;
                    // MessageBox.Show(message);
                    var map = new MapForm(image);
                    map.ShowDialog();
                    this.selectedCard.face = CardFace.FRONT;
                    this.usedCard.Push(this.selectedCard);
                    DeleteImage(this.selectedPic);
                    RemoveFromHands();
                }
                else
                {
                    MoveToStartPosition(this.selectedPic);
                    return(false);
                }
            }

            return(true);
        }