Esempio n. 1
0
 public UnderworldPuzzleSolution(PuzzlePiece first, PuzzlePiece second, PuzzlePiece third, PuzzlePiece fourth)
 {
     First = first;
     Second = second;
     Third = third;
     Fourth = fourth;
 }
Esempio n. 2
0
 private void stopSolvingPuzzlePiece(PuzzlePiece puzzlePiece)
 {
     Debug.Log("stopSolvingPuzzlePiece(): ");
     puzzlePiece.toggleAnim(false);
 }
        private List <PuzzlePiece> GetPuzzlePiecesForLevel22()
        {
            List <PuzzlePiece> pieces = new List <PuzzlePiece>();

            Field[,] puzzlePieceParts = new Field[2, 2];
            puzzlePieceParts[0, 0]    = new Field(FillType.DownRight);
            puzzlePieceParts[0, 1]    = new Field(FillType.DownLeft);
            puzzlePieceParts[1, 0]    = new Field(FillType.UpSmall);
            puzzlePieceParts[1, 1]    = new Field(FillType.UpSmall);
            PuzzlePiece piece = new PuzzlePiece(puzzlePieceParts, Brushes.Green);

            pieces.Add(piece);


            puzzlePieceParts       = new Field[3, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.DownLeft);
            puzzlePieceParts[0, 1] = new Field(FillType.Empty);
            puzzlePieceParts[1, 0] = new Field(FillType.Full);
            puzzlePieceParts[1, 1] = new Field(FillType.DownLeft);
            puzzlePieceParts[2, 0] = new Field(FillType.Full);
            puzzlePieceParts[2, 1] = new Field(FillType.Empty);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DodgerBlue);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 3];
            puzzlePieceParts[0, 0] = new Field(FillType.UpRight);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[0, 2] = new Field(FillType.Full);
            puzzlePieceParts[1, 0] = new Field(FillType.Empty);
            puzzlePieceParts[1, 1] = new Field(FillType.UpRight);
            puzzlePieceParts[1, 2] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Brown);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[3, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Empty);
            puzzlePieceParts[0, 1] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 0] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            puzzlePieceParts[2, 0] = new Field(FillType.Full);
            puzzlePieceParts[2, 1] = new Field(FillType.Empty);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Red);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[3, 3];
            puzzlePieceParts[0, 0] = new Field(FillType.Empty);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[0, 2] = new Field(FillType.Empty);
            puzzlePieceParts[1, 0] = new Field(FillType.Full);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            puzzlePieceParts[1, 2] = new Field(FillType.Full);
            puzzlePieceParts[2, 0] = new Field(FillType.Full);
            puzzlePieceParts[2, 1] = new Field(FillType.Full);
            puzzlePieceParts[2, 2] = new Field(FillType.Empty);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Violet);
            pieces.Add(piece);


            puzzlePieceParts       = new Field[3, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[1, 0] = new Field(FillType.UpRight);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            puzzlePieceParts[2, 0] = new Field(FillType.Empty);
            puzzlePieceParts[2, 1] = new Field(FillType.UpRight);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.BurlyWood);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 3];
            puzzlePieceParts[0, 0] = new Field(FillType.Empty);
            puzzlePieceParts[0, 1] = new Field(FillType.DownLeft);
            puzzlePieceParts[0, 2] = new Field(FillType.Empty);
            puzzlePieceParts[1, 0] = new Field(FillType.Full);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            puzzlePieceParts[1, 2] = new Field(FillType.DownLeft);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DarkOrange);
            pieces.Add(piece);


            return(pieces);
        }
    /**
     *  This function will detect when the user clicks on the left mouse button,
     *  and cast a ray into the 2d plane. It will check if the user has clicked
     *  on a puzzle piece. If true, it will then check if the empty space is
     *  next to piece the user clicked on. If that is true, the piece will swap
     *  with the empty piece.
     */
    private void CheckInput()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray          r   = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(r.origin, r.direction);
            if (hit.collider != null)
            {
                string[] parts    = hit.collider.gameObject.name.Split('-');
                int      rowPart  = int.Parse(parts[1]);
                int      colPart  = int.Parse(parts[2]);
                int      rowFound = -1;
                int      colFound = -1;

                for (int row = 0; row < GameVariables.MaxRows; row++)
                {
                    if (rowFound != -1)
                    {
                        break;
                    }
                    for (int col = 0; col < GameVariables.MaxCols; col++)
                    {
                        if (rowFound != -1)
                        {
                            break;
                        }
                        if (matrix[row, col] == null)
                        {
                            continue;
                        }
                        if (matrix[row, col].OriginalRow == rowPart && matrix[row, col].OriginalCol == colPart)
                        {
                            rowFound = row;
                            colFound = col;
                        }
                    }
                }
                bool pieceFound = false;
                if (rowFound > 0 && matrix[rowFound - 1, colFound] == null)
                {
                    pieceFound   = true;
                    toAnimateRow = rowFound - 1;
                    toAnimateCol = colFound;
                }
                else if (colFound > 0 && matrix[rowFound, colFound - 1] == null)
                {
                    pieceFound   = true;
                    toAnimateRow = rowFound;
                    toAnimateCol = colFound - 1;
                }
                else if (rowFound < GameVariables.MaxRows - 1 && matrix[rowFound + 1, colFound] == null)
                {
                    pieceFound   = true;
                    toAnimateRow = rowFound + 1;
                    toAnimateCol = colFound;
                }
                else if (colFound < GameVariables.MaxCols - 1 && matrix[rowFound, colFound + 1] == null)
                {
                    pieceFound   = true;
                    toAnimateRow = rowFound;
                    toAnimateCol = colFound + 1;
                }

                if (pieceFound)
                {
                    screenPosToAnimate = GetScreenCoordinatesFromViewPort(toAnimateRow, toAnimateCol);
                    PieceToAnimate     = matrix[rowFound, colFound];
                    gameState          = GameState.Animating;
                }
            }
        }
    }
 public void Initialize(SlottedPuzzle puzzle, PuzzlePiece correctPiece)
 {
     this.puzzle       = puzzle;
     this.correctPiece = correctPiece;
 }
Esempio n. 6
0
        private void SplitPiecesDown(ref PuzzlePiece movingPiece, ref PuzzlePiece movingToPiece)
		{
			int movingAmount = GetTotalPieces(movingPiece);
			int moveToAmount = GetTotalPieces(movingToPiece);

            if (movingToPiece == PuzzlePiece.None)
            {
                if ((movingAmount == 2 || movingAmount == 4))
                {
                    switch (movingPiece)
                    {
                        case PuzzlePiece.RedDouble:
                            movingToPiece = PuzzlePiece.BlueSingle;
                            movingPiece = PuzzlePiece.GreenSingle;
                            break;
                        case PuzzlePiece.BlueDouble:
                            movingToPiece = PuzzlePiece.GreenSingle;
                            movingPiece = PuzzlePiece.RedSingle;
                            break;
                        case PuzzlePiece.GreenDouble:
                            movingToPiece = PuzzlePiece.RedSingle;
                            movingPiece = PuzzlePiece.BlueSingle;
                            break;
                        case PuzzlePiece.RedBar:
                            movingToPiece = PuzzlePiece.BlueDouble;
                            movingPiece = PuzzlePiece.GreenDouble;
                            break;
                        case PuzzlePiece.BlueBar:
                            movingToPiece = PuzzlePiece.GreenDouble;
                            movingPiece = PuzzlePiece.RedDouble;
                            break;
                        case PuzzlePiece.GreenBar:
                            movingToPiece = PuzzlePiece.RedDouble;
                            movingPiece = PuzzlePiece.BlueDouble;
                            break;
                    }
                }
                     
                return;
            }

            int t = 0;
            //PuzzlePiece greater = movingPiece;

            if (moveToAmount > movingAmount)
            {
                //greater = movingToPiece;
                t = (int)movingToPiece - movingAmount;
            }
            else if (movingAmount > moveToAmount)
            {
                //greater = movingPiece;
                //t = (int)movingToPiece + (movingAmount - moveToAmount);
                //t -= 1;
                if (movingAmount == 4 && moveToAmount == 3)
                    t = (int)movingToPiece - 2;
                else if (movingAmount == 4 && moveToAmount == 2)
                    t = (int)movingToPiece;
                else if (movingAmount == 4 && moveToAmount == 1)
                    t = (int)movingToPiece + 2;

                else if (movingAmount == 2 && moveToAmount == 1)
                    t = (int)movingToPiece;
                else if (movingAmount == 3 && moveToAmount == 2)
                    t = (int)movingToPiece - 1;
                else if (movingAmount == 3 && moveToAmount == 1)
                    t = (int)movingToPiece + 1;
            }
            else
            {
                movingPiece = PuzzlePiece.None;
                movingToPiece = PuzzlePiece.None;
                return;
            }

            movingToPiece = (PuzzlePiece)t;
            movingPiece = PuzzlePiece.None;
		}
 public void ItemButtonClicked(PuzzlePiece piece)
 {
     Inventory.ChangeSelected(piece, true);
     CloseBigInventory();
 }
Esempio n. 8
0
 public void UpdatePuzzlePiece(PuzzlePiece clientModel)
 {
     // Update the shape model within our broadcaster
     _broadcaster.UpdatePuzzlePiece(clientModel, Context.ConnectionId, Clients.Caller.teamName);
 }
Esempio n. 9
0
 public void Add(PuzzlePiece p)
 {
     list.Add(p);
 }
Esempio n. 10
0
        private void LoadGameButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var LoadFileDialog = new OpenFileDialog();
                LoadFileDialog.Filter     = "Text file (*.txt)| *.txt";
                LoadFileDialog.DefaultExt = "*.txt";

                if (LoadFileDialog.ShowDialog() == true)
                {
                    clearCanvas();
                    var doc = new XmlDocument();
                    doc.Load(LoadFileDialog.FileName);
                    var root = doc.DocumentElement;
                    puzzlePieceList = new List <List <PuzzlePiece> >();

                    TimerTextBox.Text       = root.Attributes["Timer"].Value;
                    OrigTime                = (int)System.TimeSpan.Parse(root.Attributes["Timer"].Value).TotalSeconds;
                    BaseScoreTextBlock.Text = root.Attributes["Score"].Value;
                    BaseScore               = int.Parse(root.Attributes["Score"].Value);

                    imageSource = root.Attributes["ImageSource"].Value;

                    var coreImage = new BitmapImage();
                    //using (Graphics graphics = Graphics.FromImage(coreImage))
                    //{
                    //    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    //    graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                    //    graphics.SmoothingMode = SmoothingMode.HighQuality;
                    //    graphics.DrawImage(coreImage)
                    //}
                    coreImage.BeginInit();
                    coreImage.CacheOption       = BitmapCacheOption.None;
                    coreImage.CreateOptions     = BitmapCreateOptions.IgnoreColorProfile;
                    coreImage.DecodePixelHeight = 420;
                    coreImage.DecodePixelWidth  = 420;
                    coreImage.StreamSource      = new MemoryStream(File.ReadAllBytes(new Uri(imageSource).AbsolutePath));
                    coreImage.EndInit();

                    HintImage.Source = coreImage;

                    var coreImageWidth = 420;
                    croppedImageWidth  = (int)coreImageWidth / 3;
                    croppedImageHeight = (int)(coreImageWidth * coreImage.Height / coreImage.Width) / 3;

                    for (int i = 0; i < 3; i++)
                    {
                        var list = new List <PuzzlePiece>();
                        for (int j = 0; j < 3; j++)
                        {
                            if (i != 2 || j != 2)
                            {
                                var croppedImage = new CroppedBitmap(coreImage, new Int32Rect(
                                                                         (int)(j * coreImage.Width / 3), (int)(i * coreImage.Height / 3),
                                                                         (int)coreImage.Width / 3, (int)coreImage.Height / 3));
                                var imagePiece = new PuzzlePiece()
                                {
                                    image = new Image()
                                    {
                                        Source = croppedImage, Width = croppedImageWidth, Height = croppedImageHeight
                                    }
                                };

                                imagePiece.originalPos_X = j * (croppedImageWidth + croppedImagePadding);
                                imagePiece.originalPos_Y = i * (croppedImageHeight + croppedImagePadding);
                                imagePiece.numTag        = new DogTag();
                                imagePiece.numTag.cord_X = i;
                                imagePiece.numTag.cord_Y = j;
                                list.Add(imagePiece);
                            }
                        }
                        puzzlePieceList.Add(list);
                    }
                    int k = 0;
                    for (int i = 0; i < 3; i++)
                    {
                        for (int j = 0; j < 3; j++)
                        {
                            var tag         = (root.FirstChild.ChildNodes[k].Attributes["Tag"].Value).Split(',');
                            var originalPos = root.FirstChild.ChildNodes[k].Attributes["Original_Position"].Value.Split(',');
                            var newPos      = root.FirstChild.ChildNodes[k].Attributes["New_Position"].Value.Split(',');

                            int tag_X = int.Parse(tag[0]);
                            int tag_Y = int.Parse(tag[1]);
                            if (originalPos[0] == "null")
                            {
                                scrambledList[i][j] = null;
                            }
                            else
                            {
                                scrambledList[i][j] = puzzlePieceList[tag_X][tag_Y];
                                scrambledList[i][j].originalPos_X = int.Parse(originalPos[0]);
                                scrambledList[i][j].originalPos_Y = int.Parse(originalPos[1]);
                                scrambledList[i][j].newPos_X      = int.Parse(newPos[0]);
                                scrambledList[i][j].newPos_Y      = int.Parse(newPos[1]);
                                container.Children.Add(scrambledList[i][j].image);
                                Canvas.SetLeft(scrambledList[i][j].image, scrambledList[i][j].newPos_X);
                                Canvas.SetTop(scrambledList[i][j].image, scrambledList[i][j].newPos_Y);
                            }
                            k++;
                        }
                    }

                    //ENABLE BUTTON
                    if (puzzlePieceList.Count != 0)
                    {
                        StartButton.IsEnabled = true;
                        HintButton.IsEnabled  = true;
                        SaveButton.IsEnabled  = true;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 11
0
 public PuzzleBoard(PuzzlePiece <T>[,] pieces)
 {
     Pieces = pieces;
 }
Esempio n. 12
0
        private void OpenButton_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var screen = new OpenFileDialog();
                screen.Filter     = "Image files (*.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.TIF;*.TIFF;*.PNG) | *.BMP;*.DIB;*.RLE;*.JPG;*.JPEG;*.JPE;*.JFIF;*.GIF;*.TIF;*.TIFF;*.PNG";
                screen.DefaultExt = "*.png";
                if (screen.ShowDialog() == true)
                {
                    imageSource     = screen.FileName;
                    puzzlePieceList = new List <List <PuzzlePiece> >();
                    clearCanvas();

                    var coreImage = new BitmapImage();
                    //Resize Image
                    coreImage.BeginInit();
                    coreImage.CacheOption       = BitmapCacheOption.OnLoad;
                    coreImage.CreateOptions     = BitmapCreateOptions.IgnoreColorProfile;
                    coreImage.DecodePixelHeight = 420;
                    coreImage.DecodePixelWidth  = 420;
                    coreImage.StreamSource      = new MemoryStream(File.ReadAllBytes(new Uri(imageSource).AbsolutePath));
                    coreImage.EndInit();

                    HintImage.Source = coreImage;

                    var coreImageWidth = 420;
                    croppedImageWidth  = (int)coreImageWidth / 3;
                    croppedImageHeight = (int)(coreImageWidth * coreImage.Height / coreImage.Width) / 3;

                    for (int i = 0; i < 3; i++)
                    {
                        var list = new List <PuzzlePiece>();
                        for (int j = 0; j < 3; j++)
                        {
                            if (i != 2 || j != 2)
                            {
                                var croppedImage = new CroppedBitmap(coreImage, new Int32Rect(
                                                                         (int)(j * coreImage.PixelWidth / 3), (int)(i * coreImage.PixelHeight / 3),
                                                                         (int)coreImage.PixelWidth / 3, (int)coreImage.PixelHeight / 3));

                                var imagePiece = new PuzzlePiece()
                                {
                                    image = new Image()
                                    {
                                        Source = croppedImage, Width = croppedImageWidth, Height = croppedImageHeight
                                    }
                                };
                                container.Children.Add(imagePiece.image);
                                imagePiece.originalPos_X = j * (croppedImageWidth + croppedImagePadding);
                                imagePiece.originalPos_Y = i * (croppedImageHeight + croppedImagePadding);
                                imagePiece.numTag        = new DogTag();
                                imagePiece.numTag.cord_X = i;
                                imagePiece.numTag.cord_Y = j;
                                list.Add(imagePiece);
                            }
                        }
                        puzzlePieceList.Add(list);
                    }

                    do
                    {
                        var rng  = new Random();
                        var pool = new List <int> {
                            0, 1, 2, 3, 4, 5, 6, 7
                        };
                        var pooli = new List <int> {
                            0, 0, 0, 1, 1, 1, 2, 2
                        };
                        var poolj = new List <int> {
                            0, 1, 2, 0, 1, 2, 0, 1
                        };

                        for (int i = 0; i < 3; i++)
                        {
                            //var list = new List<PuzzlePiece>();
                            for (int j = 0; j < 3; j++)
                            {
                                if (i != 2 || j != 2)
                                {
                                    // Set vi tri
                                    var k = rng.Next(pool.Count); // Chon ngau nhien mot chi muc trong pool

                                    var imagePiece = puzzlePieceList[i][j];
                                    // Tao giao dien
                                    //container.Children.Add(imagePiece.image);
                                    imagePiece.newPos_X = poolj[k] * (croppedImageWidth + croppedImagePadding);
                                    imagePiece.newPos_Y = pooli[k] * (croppedImageHeight + croppedImagePadding);
                                    scrambledList[pooli[k]].Insert(poolj[k], imagePiece);
                                    scrambledList[pooli[k]].RemoveAt(poolj[k] + 1);

                                    //list.Add(imagePiece);
                                    Canvas.SetLeft(imagePiece.image, imagePiece.newPos_X);
                                    Canvas.SetTop(imagePiece.image, imagePiece.newPos_Y);
                                    pool.RemoveAt(k);
                                    pooli.RemoveAt(k);
                                    poolj.RemoveAt(k);
                                }
                            }
                        }

                        //For solvable check
                        for (int i = 0; i < 3; i++)
                        {
                            for (int j = 0; j < 3; j++)
                            {
                                if (i != 2 || j != 2)
                                {
                                    var temp = scrambledList[i][j].numTag.cord_X * 3 + scrambledList[i][j].numTag.cord_Y + 1;
                                    initList[i][j] = temp;
                                }
                                else
                                {
                                    initList[i][j] = 0;
                                }
                            }
                        }
                    } while (!isSolvablePuzzle(initList));

                    isStart = false;

                    //ENABLE BUTTON
                    StartButton.IsEnabled = true;
                    HintButton.IsEnabled  = true;
                    SaveButton.IsEnabled  = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 13
0
        private void KeyDownHandler(object sender, KeyEventArgs e)
        {
            if (isDragging)
            {
                return;
            }

            if (isStart && isEnded == false)
            {
                int null_X = 0;
                int null_Y = 0;
                GetNullPosition(ref null_X, ref null_Y);

                switch (e.Key)
                {
                case Key.Up:
                    if (null_X == 2)
                    {
                        return;
                    }

                    selectedPiece = scrambledList[null_X + 1][null_Y];
                    scrambledList[null_X][null_Y]     = selectedPiece;
                    scrambledList[null_X + 1][null_Y] = null;
                    selectedPiece.newPos_X            = null_Y * (croppedImageWidth + croppedImagePadding);
                    selectedPiece.newPos_Y            = null_X * (croppedImageHeight + croppedImagePadding);
                    Canvas.SetLeft(selectedPiece.image, selectedPiece.newPos_X);
                    Canvas.SetTop(selectedPiece.image, selectedPiece.newPos_Y);
                    checkWinningState();
                    break;

                case Key.Down:
                    if (null_X == 0)
                    {
                        return;
                    }

                    selectedPiece = scrambledList[null_X - 1][null_Y];
                    scrambledList[null_X][null_Y]     = selectedPiece;
                    scrambledList[null_X - 1][null_Y] = null;
                    selectedPiece.newPos_X            = null_Y * (croppedImageWidth + croppedImagePadding);
                    selectedPiece.newPos_Y            = null_X * (croppedImageHeight + croppedImagePadding);
                    Canvas.SetLeft(selectedPiece.image, selectedPiece.newPos_X);
                    Canvas.SetTop(selectedPiece.image, selectedPiece.newPos_Y);
                    checkWinningState();
                    break;

                case Key.Left:
                    if (null_Y == 2)
                    {
                        return;
                    }

                    selectedPiece = scrambledList[null_X][null_Y + 1];
                    scrambledList[null_X][null_Y]     = selectedPiece;
                    scrambledList[null_X][null_Y + 1] = null;
                    selectedPiece.newPos_X            = null_Y * (croppedImageWidth + croppedImagePadding);
                    selectedPiece.newPos_Y            = null_X * (croppedImageHeight + croppedImagePadding);
                    Canvas.SetLeft(selectedPiece.image, selectedPiece.newPos_X);
                    Canvas.SetTop(selectedPiece.image, selectedPiece.newPos_Y);
                    checkWinningState();
                    break;

                case Key.Right:
                    if (null_Y == 0)
                    {
                        return;
                    }

                    selectedPiece = scrambledList[null_X][null_Y - 1];
                    scrambledList[null_X][null_Y]     = selectedPiece;
                    scrambledList[null_X][null_Y - 1] = null;
                    selectedPiece.newPos_X            = null_Y * (croppedImageWidth + croppedImagePadding);
                    selectedPiece.newPos_Y            = null_X * (croppedImageHeight + croppedImagePadding);
                    Canvas.SetLeft(selectedPiece.image, selectedPiece.newPos_X);
                    Canvas.SetTop(selectedPiece.image, selectedPiece.newPos_Y);
                    checkWinningState();
                    break;

                default: return;
                }
            }
        }
Esempio n. 14
0
    private void PieceSelected(PuzzlePiece piece)
    {
        Debug.Log("this the one pop? " + piece.ID);

        if (stateManager.CurrentState != states[2])
        {
            return;
        }

        audioSource.clip = buttonSound;
        audioSource.Play();

        if (selected == players.Count)
        {
            return;
        }

        selected++;

        PuzzleController currentPuzzle = puzzleMap[piece];

        if (piece.isLeftSide)
        {
            isSpawningLeft = false;
            leftPick       = piece;
            foreach (PuzzleController puz in puzzlesInPlayPool)
            {
                if (puz.IsLeftSide())
                {
                    puz.SetActive(false);
                    puz.SetVisable(false);
                }
            }
        }
        else
        {
            isSpawningRight = false;
            rightPick       = piece;
            foreach (PuzzleController puz in rightPuzzlePool)
            {
                puz.SetActive(false);
                puz.SetVisable(false);
            }
        }

        currentPuzzle.SetVisable(true);
        puzzlesInPlayPool.Remove(currentPuzzle);

        if (selected == players.Count)
        {
            if (leftPick.ID == rightPick.ID)
            {
                winLoseAudio.clip = correctSound;
                winLoseAudio.Play();

                mainScreen.FillHeart(.2f);
                mainScreen.AddTime(0);
            }
            else
            {
                winLoseAudio.clip = wrongSount;
                winLoseAudio.Play();
            }

            foreach (PlayerModel model in playerModels)
            {
                model.HasSelected = false;
            }

            PuzzleController LcurrentPuzzle = puzzleMap[leftPick];
            PuzzleController RcurrentPuzzle = puzzleMap[rightPick];

            LcurrentPuzzle.SetVisable(false);
            RcurrentPuzzle.SetVisable(false);

            leftPick  = null;
            rightPick = null;

            isSpawningRight = true;
            isSpawningLeft  = true;

            DisplaySpawned();

            selected = 0;
        }
    }
Esempio n. 15
0
        public void LoadStartSolution(int index)
        {
            m_Index = index;

            switch (index)
            {
                case 0:
                    First = PuzzlePiece.RedSingle;
                    Second = PuzzlePiece.RedSingle;
                    Third = PuzzlePiece.RedSingle;
                    Fourth = PuzzlePiece.RedSingle;
                    break;
                case 1:
                    First = PuzzlePiece.BlueBar;
                    Second = PuzzlePiece.RedDouble;
                    Third = PuzzlePiece.RedBar;
                    Fourth = PuzzlePiece.BlueSingle;
                    break;
                case 2:
                    First = PuzzlePiece.GreenBar;
                    Second = PuzzlePiece.BlueDouble;
                    Third = PuzzlePiece.RedTriple;
                    Fourth = PuzzlePiece.RedBar;
                    break;
                case 3:
                    First = PuzzlePiece.RedSingle;
                    Second = PuzzlePiece.GreenDouble;
                    Third = PuzzlePiece.BlueTriple;
                    Fourth = PuzzlePiece.RedBar;
                    break;
                case 4:
                    First = PuzzlePiece.GreenSingle;
                    Second = PuzzlePiece.RedBar;
                    Third = PuzzlePiece.RedDouble;
                    Fourth = PuzzlePiece.GreenSingle;
                    break;
                case 5:
                    First = PuzzlePiece.RedBar;
                    Second = PuzzlePiece.GreenBar;
                    Third = PuzzlePiece.RedBar;
                    Fourth = PuzzlePiece.BlueBar;
                    break;
                case 6:
                    First = PuzzlePiece.RedBar;
                    Second = PuzzlePiece.GreenDouble;
                    Third = PuzzlePiece.GreenDouble;
                    Fourth = PuzzlePiece.RedBar;
                    break;
                case 7:
                    First = PuzzlePiece.GreenBar;
                    Second = PuzzlePiece.BlueSingle;
                    Third = PuzzlePiece.BlueTriple;
                    Fourth = PuzzlePiece.RedSingle;
                    break;
                case 8:
                    First = PuzzlePiece.GreenBar;
                    Second = PuzzlePiece.None;
                    Third = PuzzlePiece.GreenTriple;
                    Fourth = PuzzlePiece.GreenSingle;
                    break;
                case 9:
                    First = PuzzlePiece.RedBar;
                    Second = PuzzlePiece.RedBar;
                    Third = PuzzlePiece.RedBar;
                    Fourth = PuzzlePiece.RedBar;
                    break;
                case 10:
                    First = PuzzlePiece.RedSingle;
                    Second = PuzzlePiece.None;
                    Third = PuzzlePiece.BlueDouble;
                    Fourth = PuzzlePiece.RedBar;
                    break;
                case 11:
                    First = PuzzlePiece.RedDouble;
                    Second = PuzzlePiece.GreenDouble;
                    Third = PuzzlePiece.RedDouble;
                    Fourth = PuzzlePiece.BlueDouble;
                    break;
                case 12:
                    First = PuzzlePiece.GreenTriple;
                    Second = PuzzlePiece.BlueBar;
                    Third = PuzzlePiece.GreenTriple;
                    Fourth = PuzzlePiece.RedBar;
                    break;
                case 13:
                    First = PuzzlePiece.RedSingle;
                    Second = PuzzlePiece.GreenBar;
                    Third = PuzzlePiece.GreenBar;
                    Fourth = PuzzlePiece.RedSingle;
                    break;
                case 14:
                    First = PuzzlePiece.GreenTriple;
                    Second = PuzzlePiece.GreenBar;
                    Third = PuzzlePiece.BlueBar;
                    Fourth = PuzzlePiece.GreenSingle;
                    break;
                case 15:
                    First = PuzzlePiece.BlueTriple;
                    Second = PuzzlePiece.GreenDouble;
                    Third = PuzzlePiece.BlueSingle;
                    Fourth = PuzzlePiece.RedDouble;
                    break;
            }
        }
Esempio n. 16
0
 public void Remove(PuzzlePiece p)
 {
     list.Remove(p);
 }
Esempio n. 17
0
        private int GetTotalPieces(PuzzlePiece piece)
		{
			switch(piece)
			{
				default:
                    return 0;
				case PuzzlePiece.RedSingle: case PuzzlePiece.BlueSingle: case PuzzlePiece.GreenSingle: return 1;
				case PuzzlePiece.RedDouble: case PuzzlePiece.BlueDouble: case PuzzlePiece.GreenDouble: return 2;
				case PuzzlePiece.RedTriple: case PuzzlePiece.BlueTriple: case PuzzlePiece.GreenTriple: return 3;
				case PuzzlePiece.RedBar: case PuzzlePiece.BlueBar: case PuzzlePiece.GreenBar: return 4;
			}
		}
Esempio n. 18
0
 private static PuzzlePiece FindSeaMonsters(PuzzlePiece puzzle)
 {
     //                   #
     // #    ##    ##    ###
     //  #  #  #  #  #  #
     var mask = new (int X, int Y)[]
Esempio n. 19
0
 private PuzzleColor GetColor(PuzzlePiece piece)
 {
     switch (piece)
     {
         default:
         case PuzzlePiece.RedSingle:
         case PuzzlePiece.RedDouble:
         case PuzzlePiece.RedTriple:
         case PuzzlePiece.RedBar:
             return PuzzleColor.Red;
         case PuzzlePiece.BlueSingle:
         case PuzzlePiece.BlueDouble:
         case PuzzlePiece.BlueTriple:
         case PuzzlePiece.BlueBar:
             return PuzzleColor.Blue;
         case PuzzlePiece.GreenSingle:
         case PuzzlePiece.GreenDouble:
         case PuzzlePiece.GreenTriple:
         case PuzzlePiece.GreenBar:
             return PuzzleColor.Green;
     }
 }
        private CombinedPuzzlePiece CreateUnionPuzzlePiece(PuzzlePiece p1, PuzzlePiece p2)
        {
            CombinedPuzzlePiece retVal = null;

            int minX, minY, maxX, maxY;

            if (p1.XIndex < p2.XIndex)
            {
                minX = p1.XIndex;
            }
            else
            {
                minX = p2.XIndex;
            }

            if (p1.YIndex < p2.YIndex)
            {
                minY = p1.YIndex;
            }
            else
            {
                minY = p2.YIndex;
            }

            if (p1.XIndex + p1.Width > p2.XIndex + p2.Width)
            {
                maxX = p1.XIndex + p1.Width;
            }
            else
            {
                maxX = p2.XIndex + p2.Width;
            }

            if (p1.YIndex + p1.Height > p2.YIndex + p2.Height)
            {
                maxY = p1.YIndex + p1.Height;
            }
            else
            {
                maxY = p2.YIndex + p2.Height;
            }


            Field[,] newPieceMatrix = StaticHelper.GetEmptyMatrix(maxX - minX, maxY - minY);
            FillType fill1;
            FillType fill2;
            FillType newFill = FillType.Empty;

            for (int y = 0; y < maxY - minY; y++)
            {
                for (int x = 0; x < maxX - minX; x++)
                {
                    fill1 = GetPieceFillInWorld(x + minX, y + minY, p1);
                    fill2 = GetPieceFillInWorld(x + minX, y + minY, p2);

                    if (fill1 == FillType.Full || fill2 == FillType.Full)
                    {
                        newFill = FillType.Full;
                    }
                    else if (fill1 != FillType.Empty && fill2 != FillType.Empty)
                    {
                        newFill = CellStateRules.GetUnion(fill1, fill2);
                    }
                    else if (fill1 == FillType.Empty)
                    {
                        newFill = fill2;
                    }
                    else if (fill2 == FillType.Empty)
                    {
                        newFill = fill1;
                    }

                    newPieceMatrix[y, x].Fill = newFill;
                }
            }

            LinearGradientBrush myBrush = new LinearGradientBrush();

            myBrush.GradientStops.Add(new GradientStop(((SolidColorBrush)p1.Brush).Color, 0.0));
            myBrush.GradientStops.Add(new GradientStop(((SolidColorBrush)p2.Brush).Color, 1.0));

            retVal        = new CombinedPuzzlePiece(newPieceMatrix, myBrush);
            retVal.XIndex = minX;
            retVal.YIndex = minY;
            retVal.Piece1 = p1;
            retVal.Piece2 = p2;


            return(retVal);
        }
Esempio n. 21
0
    //---------------------------------------------------------------------------------------------------------------------------------------------------
    // Main function to process grouping pieces and clamping groups
    public static bool MergeGroupsOrPieces(PuzzlePiece _puzzlePiece1, PuzzlePiece _puzzlePiece2, PuzzleController _puzzleController)
    {
        GameObject object1 = _puzzlePiece1.Transform.gameObject;
        GameObject object2 = _puzzlePiece2.Transform.gameObject;


        //Convert to group if it's not a single piece
        object1 = GetGroupObjectIfPossible(object1);
        object2 = GetGroupObjectIfPossible(object2);

        if (object1 == object2)
        {
            return(false);
        }

        // Get groups
        PuzzlePieceGroup pieceGroup1 = object1.GetComponent <PuzzlePieceGroup>();
        PuzzlePieceGroup pieceGroup2 = object2.GetComponent <PuzzlePieceGroup>();


        //// If both objects non-grouped
        if (pieceGroup1 == null && pieceGroup2 == null)
        {
            bool clamped = TryClampPieces(_puzzlePiece1, _puzzlePiece2, _puzzleController);

            // Create new group
            if (clamped)
            {
                GameObject pieceGroupObject = new GameObject("_PieceGroup".ToString());
                pieceGroupObject.transform.parent = _puzzleController.transform;
                PuzzlePieceGroup pieceGroup = pieceGroupObject.AddComponent <PuzzlePieceGroup>();

                // Include pieces in the group
                pieceGroup.AddNewPiece(_puzzlePiece1);
                pieceGroup.AddNewPiece(_puzzlePiece2);

                pieceGroup.RecalculateCenterAndTransformGroup();
            }

            return(clamped);
        }
        else          //// If both objects are groups
        if (pieceGroup1 != null && pieceGroup2 != null)
        {
            foreach (PuzzlePiece puzzlePiece1 in pieceGroup1.puzzlePieces)
            {
                foreach (PuzzlePiece puzzlePiece2 in pieceGroup2.puzzlePieces)
                {
                    if (TryClampPieces(puzzlePiece1, puzzlePiece2, _puzzleController))
                    {
                        // Move pieces to one group
                        foreach (PuzzlePiece puzzlePiece in pieceGroup2.puzzlePieces)
                        {
                            pieceGroup1.AddNewPiece(puzzlePiece);
                        }

                        pieceGroup1.RecalculateCenterAndTransformGroup();
                        Destroy(pieceGroup2.gameObject);

                        return(true);
                    }
                }
            }
        }
        else                  //// One object is a group and another is non-grouped piece
        {
            PuzzlePieceGroup pieceGroup;
            PuzzlePiece      puzzlePiece;

            // Figure out which object is group/single piece
            if (pieceGroup1 == null)
            {
                pieceGroup  = pieceGroup2;
                puzzlePiece = _puzzlePiece1;
            }
            else
            {
                pieceGroup  = pieceGroup1;
                puzzlePiece = _puzzlePiece2;
            }

            // Try to clamp each piece in group with the single piece
            for (int i = 0; i < pieceGroup.puzzlePieces.Count; ++i)
            {
                if (TryClampPieces(puzzlePiece, pieceGroup.puzzlePieces[i], _puzzleController))
                {
                    pieceGroup.AddNewPiece(puzzlePiece);
                    pieceGroup.RecalculateCenterAndTransformGroup();

                    return(true);
                }
            }
        }


        return(false);
    }
        public override void TryToMovePuzzlePiece(PuzzlePiece piece, int newXIndex, int newYIndex, Point?p)
        {
            int oldX = piece.XIndex;
            int oldY = piece.YIndex;

            RemovePuzzlePieceFromLevelMatrix(piece);
            piece.XIndex = newXIndex;
            piece.YIndex = newYIndex;

            PuzzlePiece overlapedPiece;

            if (IsPieceInsideOfGrid(piece))
            {
                if (!IsPieceOverlapingWithOthers(piece, out overlapedPiece))
                {
                    piece.IsAdded = true;
                    piece.X       = (piece.XIndex + gridWidth) * CellSize;
                    piece.Y       = (piece.YIndex + gridHeight) * CellSize;
                    AddPuzzlePieceTolLevelMatrix(piece);
                    IsLevelSolved();
                    return;
                }
            }
            else if (IsPieceOutsideOfGrid(piece))
            {
                if (IsPieceInsideOfLevel(piece))
                {
                    if (!IsPieceOverlapingWithOthers(piece, out overlapedPiece))
                    {
                        piece.IsAdded = false;
                        piece.X       = (piece.XIndex + gridWidth) * CellSize;
                        piece.Y       = (piece.YIndex + gridHeight) * CellSize;
                        AddPuzzlePieceTolLevelMatrix(piece);
                        return;
                    }
                    else
                    {
                        //element is trying to be placed over another outside of grid
                        if (GetNumberOfOverlapingPieces(piece) <= 1 &&
                            piece.GetType() != typeof(CombinedPuzzlePiece) &&
                            overlapedPiece.GetType() != typeof(CombinedPuzzlePiece))
                        {
                            //create combined piece
                            CombinedPuzzlePiece newPuzzlePiece = CreateUnionPuzzlePiece(piece, overlapedPiece);

                            //remove dragged piece
                            RemovePuzzlePieceFromLevelMatrix(piece);
                            drawings.Remove(piece);
                            puzzlePieces.Remove(piece);

                            //remove overlaped piece
                            RemovePuzzlePieceFromLevelMatrix(overlapedPiece);
                            drawings.Remove(overlapedPiece);
                            puzzlePieces.Remove(overlapedPiece);

                            //add combined puzzle piece to level
                            newPuzzlePiece.PaintShape(this);
                            drawings.Add(newPuzzlePiece);
                            puzzlePieces.Add(newPuzzlePiece);
                            AddPuzzlePieceTolLevelMatrix(newPuzzlePiece);
                            newPuzzlePiece.isInitialised = true;
                            return;
                        }
                    }
                }
            }

            piece.XIndex = oldX;
            piece.YIndex = oldY;
            AddPuzzlePieceTolLevelMatrix(piece);
        }
 /**
  *  This function will move a puzzle piece to the desired transform.position to
  *  the position defined in screenPosToAnimate.
  *
  *  @param {PuzzlePiece} puzzle piece that will be moved
  */
 private void AnimateMovement(PuzzlePiece toMove)
 {
     toMove.GameObject.transform.position = Vector2.MoveTowards(toMove.GameObject.transform.position, screenPosToAnimate, animSpeed * Time.deltaTime);
 }
Esempio n. 24
0
    void Update()
    {
        var mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0));

        if (Input.GetButtonDown("Fire1"))
        {
            Ray          ray       = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit       = Physics2D.GetRayIntersection(ray, Mathf.Infinity, LayerMask.GetMask("PuzzlePiece"));
            var          hitTarget = hit.collider?.gameObject;
            puzzlePiece = hitTarget?.GetComponent <PuzzlePiece>();
            if (puzzlePiece != null)
            {
                if (!puzzlePiece.canMove)
                {
                    var go         = Instantiate(puzzlePiece.selfPrefab);
                    var prevPuzzle = puzzlePiece;
                    var mask       = puzzlePiece.shape.mask;
                    go.transform.position  = puzzlePiece.transform.position;
                    puzzlePiece            = go.GetComponent <PuzzlePiece>();
                    puzzlePiece.shape.mask = mask;
                    puzzlePiece.variations = prevPuzzle.variations;
                    puzzlePiece.selfPrefab = prevPuzzle.selfPrefab;
                    puzzlePiece.canMove    = true;
                    puzzlePiece.selected   = true;
                }
                offset      = puzzlePiece.transform.position - mousePos;
                originalPos = puzzlePiece.transform.position;
                ItemSlots.Instance.DescreaseCount(puzzlePiece.id);
            }
        }

        if (Input.GetButton("Fire1"))
        {
            if (puzzlePiece != null)
            {
                puzzlePiece.transform.position = mousePos + offset;
            }
        }

        if (Input.GetButtonUp("Fire1"))
        {
            if (puzzlePiece != null)
            {
                Ray          ray         = Camera.main.ScreenPointToRay(Input.mousePosition);
                RaycastHit2D hit         = Physics2D.GetRayIntersection(ray, Mathf.Infinity, LayerMask.GetMask("PuzzleBoard"));
                var          hitTarget   = hit.collider?.gameObject;
                var          grid        = hitTarget?.GetComponent <TriGrid>();
                var          puzzleBoard = hitTarget?.GetComponent <PuzzleBoard>();
                if (grid != null && puzzleBoard != null)
                {
                    Vector2 relativePos = new Vector2(puzzlePiece.transform.position.x, puzzlePiece.transform.position.y) - new Vector2(grid.transform.position.x, grid.transform.position.y);
                    Vector2 orthoPos    = CoordsUtils.SlopeToOrtho(relativePos) / grid.cellSize;
                    Debug.Log("puzzle: " + puzzlePiece.transform.position + "; grid: " + grid.transform.position);
                    Vector2Int gridOffset   = new Vector2Int(Mathf.RoundToInt(orthoPos.x), Mathf.RoundToInt(orthoPos.y));
                    bool       canFit       = grid.CanFit(gridOffset.x, gridOffset.y, puzzlePiece.shape);
                    bool       isOutOfBound = grid.IsOutOfBound(gridOffset.x, gridOffset.y);
                    Debug.Log("canFit: " + canFit + ", isOutOfBound: " + isOutOfBound + " gridOffset: " + gridOffset);
                    if (canFit && !isOutOfBound)
                    {
                        puzzleBoard.Attach(gridOffset.x, gridOffset.y, puzzlePiece.shape);
                        ClinicManager.instance.MedicinesCost[puzzlePiece.id] += 1;
                    }
                }
                Destroy(puzzlePiece.gameObject);
            }
        }
    }
Esempio n. 25
0
 private void startSolvingPuzzlePiece(PuzzlePiece puzzlePiece)
 {
     Debug.Log("startSolvingPuzzlePiece(): ");
     puzzlePiece.toggleAnim(true);
     puzzlePiece.registerPuzzleSolvedAction(action_currentPuzzleSolved);
 }
Esempio n. 26
0
    void GeneratePuzzlePieces(Texture2D PuzzleTexture)
    {
        if (Pieces != null)
        {
            Debug.LogWarning("GeneratePuzzlePieces was called after Pieces array was already initialized");
        }
        Pieces = new PuzzlePiece[GridWidth * GridHeight];

        // TODO: choose a different random seed, possibly from user input
        PuzzleRandomizer.InitializeRandomizer(0, GridWidth, GridHeight);

        // Compute the scale and offset, cutting off edges from the texture as needed (rather than letterboxing)
        // Texture UV coords are [0,0] in the lower-left to [1,1] in the upper-right
        float   pieceScaleX;
        float   pieceScaleY;
        Vector2 puzzleRootUV;
        float   wScale = (float)PuzzleTexture.width / (float)GridWidth;
        float   hScale = (float)PuzzleTexture.height / (float)GridHeight;

        if (wScale < hScale)
        {
            pieceScaleX  = 1.0f / (float)GridWidth;
            pieceScaleY  = ((float)PuzzleTexture.width / (float)(PuzzleTexture.height)) * pieceScaleX;
            puzzleRootUV = new Vector2(0.0f, 0.5f * (1.0f - GridHeight * pieceScaleY)); // TODO
        }
        else
        {
            pieceScaleY  = 1.0f / (float)GridHeight;
            pieceScaleX  = ((float)PuzzleTexture.height / (float)(PuzzleTexture.width)) * pieceScaleY;
            puzzleRootUV = new Vector2(0.5f * (1.0f - GridWidth * pieceScaleX), 0.0f); // TODO
        }

        // Spawn and initialize puzzle pieces
        for (uint y = 0; y < GridHeight; ++y)
        {
            for (uint x = 0; x < GridWidth; ++x)
            {
                int        ind      = (int)(y * GridWidth + x);
                Quaternion spawnRot = new Quaternion();
                spawnRot.eulerAngles = new Vector3(270, 0, 0);

                PuzzlePiece piece = Instantiate(PuzzlePiecePrefab, Vector3.zero, spawnRot).GetComponent <PuzzlePiece>();
                PuzzleRandomizer.SetupPiece(ref piece, x, y);
                piece.SetMaterialInfo(PuzzleTexture, pieceScaleX, pieceScaleY, puzzleRootUV.x + x * pieceScaleX, puzzleRootUV.y + y * pieceScaleY);
                piece.SetId(ind);
                Pieces[ind] = piece;
            }
        }

        GlobalJigsawSettings settings = FindObjectOfType <GlobalJigsawSettings>();
        Rect puzzleRegion             = new Rect(
            -0.5f * PuzzleSpaceGridScale * GridWidth,
            -0.5f * PuzzleSpaceGridScale * GridHeight,
            PuzzleSpaceGridScale * GridWidth,
            PuzzleSpaceGridScale * GridHeight);
        float minX       = Mathf.Max(settings.PuzzleBoardBoundsX.x, -SpawnSpaceGridScale * GridWidth);
        float maxX       = Mathf.Min(settings.PuzzleBoardBoundsX.y, SpawnSpaceGridScale * GridWidth);
        float minZ       = Mathf.Max(settings.PuzzleBoardBoundsZ.x, -SpawnSpaceGridScale * GridHeight);
        float maxZ       = Mathf.Min(settings.PuzzleBoardBoundsZ.y, SpawnSpaceGridScale * GridHeight);
        Rect  playRegion = new Rect(minX, minZ, maxX - minX, maxZ - minZ);

        ScatterPiecesRandomly(puzzleRegion, playRegion, Pieces);

        //AlignPiecesNeatly(new Vector3(-0.5f * GridWidth, 0.0f, -0.5f * GridHeight), Pieces);
        foreach (PuzzlePiece piece in Pieces)
        {
            NetworkServer.Spawn(piece.gameObject);
        }
    }
        //private List<PuzzlePiece> GetPuzzlePiecesForLevel1()
        //{
        //	List<PuzzlePiece> pieces = new List<PuzzlePiece>();

        //	Field[,] puzzlePieceParts = new Field[3, 3];
        //	puzzlePieceParts[0, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[0, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[0, 2] = new Field(FillType.Empty);
        //	puzzlePieceParts[1, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 2] = new Field(FillType.Full);
        //	puzzlePieceParts[2, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[2, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[2, 2] = new Field(FillType.Full);
        //	PuzzlePiece piece = new PuzzlePiece(puzzlePieceParts, Brushes.Red);
        //	pieces.Add(piece);

        //	puzzlePieceParts = new Field[3, 3];
        //	puzzlePieceParts[0, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[0, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[0, 2] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 2] = new Field(FillType.Full);
        //	puzzlePieceParts[2, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[2, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[2, 2] = new Field(FillType.Full);
        //	piece = new PuzzlePiece(puzzlePieceParts, Brushes.Green);
        //	pieces.Add(piece);

        //	puzzlePieceParts = new Field[2, 2];
        //	puzzlePieceParts[0, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[0, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 1] = new Field(FillType.Full);
        //	piece = new PuzzlePiece(puzzlePieceParts, Brushes.Blue);
        //	pieces.Add(piece);

        //	puzzlePieceParts = new Field[2, 2];
        //	puzzlePieceParts[0, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[0, 1] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 0] = new Field(FillType.Full);
        //	puzzlePieceParts[1, 1] = new Field(FillType.Full);
        //	piece = new PuzzlePiece(puzzlePieceParts, Brushes.Brown);
        //	pieces.Add(piece);


        //	return pieces;
        //}

        private List <PuzzlePiece> GetPuzzlePiecesForLevel1()
        {
            List <PuzzlePiece> pieces = new List <PuzzlePiece>();

            Field[,] puzzlePieceParts = new Field[6, 1];
            puzzlePieceParts[0, 0]    = new Field(FillType.Full);
            puzzlePieceParts[1, 0]    = new Field(FillType.Full);
            puzzlePieceParts[2, 0]    = new Field(FillType.Full);
            puzzlePieceParts[3, 0]    = new Field(FillType.Full);
            puzzlePieceParts[4, 0]    = new Field(FillType.Full);
            puzzlePieceParts[5, 0]    = new Field(FillType.Full);

            PuzzlePiece piece = new PuzzlePiece(puzzlePieceParts, Brushes.Blue);

            pieces.Add(piece);

            puzzlePieceParts       = new Field[6, 1];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[1, 0] = new Field(FillType.Full);
            puzzlePieceParts[2, 0] = new Field(FillType.Full);
            puzzlePieceParts[3, 0] = new Field(FillType.Full);
            puzzlePieceParts[4, 0] = new Field(FillType.Full);
            puzzlePieceParts[5, 0] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DodgerBlue);
            pieces.Add(piece);

            //-----
            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[0, 1] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 0] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 1] = new Field(FillType.Empty);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DarkGray);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[0, 1] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 0] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 1] = new Field(FillType.Empty);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DarkCyan);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[0, 1] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 0] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 1] = new Field(FillType.Empty);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DarkGreen);
            pieces.Add(piece);
            //--------

            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Empty);
            puzzlePieceParts[0, 1] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 0] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Orange);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Empty);
            puzzlePieceParts[0, 1] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 0] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Red);
            pieces.Add(piece);
            //------

            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[1, 0] = new Field(FillType.Full);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Yellow);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[1, 0] = new Field(FillType.Full);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DarkOrchid);
            pieces.Add(piece);

            //---

            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.UpRight);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[1, 0] = new Field(FillType.Empty);
            puzzlePieceParts[1, 1] = new Field(FillType.UpRight);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Firebrick);
            pieces.Add(piece);


            puzzlePieceParts       = new Field[2, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.DownLeft);
            puzzlePieceParts[0, 1] = new Field(FillType.Empty);
            puzzlePieceParts[1, 0] = new Field(FillType.Full);
            puzzlePieceParts[1, 1] = new Field(FillType.DownLeft);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Gainsboro);
            pieces.Add(piece);


            puzzlePieceParts       = new Field[1, 1];
            puzzlePieceParts[0, 0] = new Field(FillType.DownSmall);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Blue);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[1, 1];
            puzzlePieceParts[0, 0] = new Field(FillType.DownRight);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Chocolate);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[1, 2];
            puzzlePieceParts[0, 0] = new Field(FillType.RightSmall);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.DarkMagenta);
            pieces.Add(piece);



            return(pieces);
        }
Esempio n. 28
0
 public UnderworldPuzzleSolution(PuzzlePiece first, PuzzlePiece second, PuzzlePiece third, PuzzlePiece fourth)
 {
     First  = first;
     Second = second;
     Third  = third;
     Fourth = fourth;
 }
        private List <PuzzlePiece> GetPuzzlePiecesForLevel2()
        {
            List <PuzzlePiece> pieces = new List <PuzzlePiece>();

            Field[,] puzzlePieceParts = new Field[5, 2];
            puzzlePieceParts[0, 0]    = new Field(FillType.DownLeft);
            puzzlePieceParts[0, 1]    = new Field(FillType.Empty);
            puzzlePieceParts[1, 0]    = new Field(FillType.Full);
            puzzlePieceParts[1, 1]    = new Field(FillType.DownLeft);
            puzzlePieceParts[2, 0]    = new Field(FillType.Full);
            puzzlePieceParts[2, 1]    = new Field(FillType.Full);
            puzzlePieceParts[3, 0]    = new Field(FillType.Full);
            puzzlePieceParts[3, 1]    = new Field(FillType.UpLeft);
            puzzlePieceParts[4, 0]    = new Field(FillType.UpLeft);
            puzzlePieceParts[4, 1]    = new Field(FillType.Empty);
            PuzzlePiece piece = new PuzzlePiece(puzzlePieceParts, Brushes.Green);

            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 4];
            puzzlePieceParts[0, 0] = new Field(FillType.UpRight);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[0, 2] = new Field(FillType.DownLeft);
            puzzlePieceParts[0, 3] = new Field(FillType.Empty);
            puzzlePieceParts[1, 0] = new Field(FillType.Empty);
            puzzlePieceParts[1, 1] = new Field(FillType.UpRight);
            puzzlePieceParts[1, 2] = new Field(FillType.Full);
            puzzlePieceParts[1, 3] = new Field(FillType.DownLeft);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Brown);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[3, 3];
            puzzlePieceParts[0, 0] = new Field(FillType.UpRight);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[0, 2] = new Field(FillType.Full);
            puzzlePieceParts[1, 0] = new Field(FillType.Empty);
            puzzlePieceParts[1, 1] = new Field(FillType.UpRight);
            puzzlePieceParts[1, 2] = new Field(FillType.Full);
            puzzlePieceParts[2, 0] = new Field(FillType.Empty);
            puzzlePieceParts[2, 1] = new Field(FillType.Empty);
            puzzlePieceParts[2, 2] = new Field(FillType.UpRight);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Turquoise);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[1, 3];
            puzzlePieceParts[0, 0] = new Field(FillType.Full);
            puzzlePieceParts[0, 1] = new Field(FillType.Full);
            puzzlePieceParts[0, 2] = new Field(FillType.LeftSmall);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Red);
            pieces.Add(piece);


            puzzlePieceParts       = new Field[3, 3];
            puzzlePieceParts[0, 0] = new Field(FillType.Empty);
            puzzlePieceParts[0, 1] = new Field(FillType.Empty);
            puzzlePieceParts[0, 2] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 0] = new Field(FillType.Empty);
            puzzlePieceParts[1, 1] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 2] = new Field(FillType.Full);
            puzzlePieceParts[2, 0] = new Field(FillType.DownRight);
            puzzlePieceParts[2, 1] = new Field(FillType.Full);
            puzzlePieceParts[2, 2] = new Field(FillType.Full);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Purple);
            pieces.Add(piece);

            puzzlePieceParts       = new Field[2, 4];
            puzzlePieceParts[0, 0] = new Field(FillType.Empty);
            puzzlePieceParts[0, 1] = new Field(FillType.DownRight);
            puzzlePieceParts[0, 2] = new Field(FillType.Full);
            puzzlePieceParts[0, 3] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 0] = new Field(FillType.DownRight);
            puzzlePieceParts[1, 1] = new Field(FillType.Full);
            puzzlePieceParts[1, 2] = new Field(FillType.UpLeft);
            puzzlePieceParts[1, 3] = new Field(FillType.Empty);
            piece = new PuzzlePiece(puzzlePieceParts, Brushes.Yellow);
            pieces.Add(piece);


            return(pieces);
        }
Esempio n. 30
0
        public void PickRandom()
        {
            m_Index = Utility.Random(16);
            switch (m_Index)
            {
            case 0:     //Good To Go
                First         = PuzzlePiece.RedSingle;
                Second        = PuzzlePiece.BlueSingle;
                Third         = PuzzlePiece.RedSingle;
                Fourth        = PuzzlePiece.GreenSingle;
                m_MaxAttempts = 6;
                break;

            case 1:     //Good To Go
                First         = PuzzlePiece.GreenDouble;
                Second        = PuzzlePiece.RedBar;
                Third         = PuzzlePiece.None;
                Fourth        = PuzzlePiece.BlueTriple;
                m_MaxAttempts = 6;
                break;

            case 2:     //Good To Go
                First         = PuzzlePiece.None;
                Second        = PuzzlePiece.None;
                Third         = PuzzlePiece.RedBar;
                Fourth        = PuzzlePiece.RedTriple;
                m_MaxAttempts = 4;
                break;

            case 3:     //Good To Go
                First         = PuzzlePiece.BlueDouble;
                Second        = PuzzlePiece.None;
                Third         = PuzzlePiece.GreenDouble;
                Fourth        = PuzzlePiece.GreenDouble;
                m_MaxAttempts = 7;
                break;

            case 4:     //Good To Go
                First         = PuzzlePiece.BlueSingle;
                Second        = PuzzlePiece.GreenSingle;
                Third         = PuzzlePiece.GreenDouble;
                Fourth        = PuzzlePiece.RedBar;
                m_MaxAttempts = 7;
                break;

            case 5:     //Good To Go
                First         = PuzzlePiece.GreenDouble;
                Second        = PuzzlePiece.BlueBar;
                Third         = PuzzlePiece.RedSingle;
                Fourth        = PuzzlePiece.BlueSingle;
                m_MaxAttempts = 8;
                break;

            case 6:     //Good To Go
                First         = PuzzlePiece.GreenSingle;
                Second        = PuzzlePiece.RedSingle;
                Third         = PuzzlePiece.BlueDouble;
                Fourth        = PuzzlePiece.GreenBar;
                m_MaxAttempts = 5;
                break;

            case 7:     //Good To Go
                First         = PuzzlePiece.BlueDouble;
                Second        = PuzzlePiece.None;
                Third         = PuzzlePiece.BlueTriple;
                Fourth        = PuzzlePiece.None;
                m_MaxAttempts = 4;
                break;

            case 8:     //Good To Go
                First         = PuzzlePiece.GreenSingle;
                Second        = PuzzlePiece.GreenBar;
                Third         = PuzzlePiece.RedDouble;
                Fourth        = PuzzlePiece.RedSingle;
                m_MaxAttempts = 7;
                break;

            case 9:     //Good to Go
                First         = PuzzlePiece.BlueSingle;
                Second        = PuzzlePiece.GreenDouble;
                Third         = PuzzlePiece.None;
                Fourth        = PuzzlePiece.GreenTriple;
                m_MaxAttempts = 6;
                break;

            case 10:     //Good To Go
                First         = PuzzlePiece.BlueSingle;
                Second        = PuzzlePiece.RedSingle;
                Third         = PuzzlePiece.RedTriple;
                Fourth        = PuzzlePiece.None;
                m_MaxAttempts = 6;
                break;

            case 11:     //Good To Go
                First         = PuzzlePiece.GreenSingle;
                Second        = PuzzlePiece.None;
                Third         = PuzzlePiece.GreenTriple;
                Fourth        = PuzzlePiece.GreenDouble;
                m_MaxAttempts = 5;
                break;

            case 12:     //Good to Go
                First         = PuzzlePiece.RedTriple;
                Second        = PuzzlePiece.None;
                Third         = PuzzlePiece.None;
                Fourth        = PuzzlePiece.RedTriple;
                m_MaxAttempts = 6;
                break;

            case 13:     //Good To Go
                First         = PuzzlePiece.None;
                Second        = PuzzlePiece.BlueTriple;
                Third         = PuzzlePiece.GreenSingle;
                Fourth        = PuzzlePiece.BlueDouble;
                m_MaxAttempts = 7;
                break;

            case 14:     //Good To Go
                First         = PuzzlePiece.BlueTriple;
                Second        = PuzzlePiece.None;
                Third         = PuzzlePiece.BlueTriple;
                Fourth        = PuzzlePiece.None;
                m_MaxAttempts = 6;
                break;

            case 15:     //Good to Go
                First         = PuzzlePiece.RedSingle;
                Second        = PuzzlePiece.BlueDouble;
                Third         = PuzzlePiece.RedDouble;
                Fourth        = PuzzlePiece.GreenSingle;
                m_MaxAttempts = 6;
                break;
            }
        }
Esempio n. 31
0
 public void PickRandom()
 {
     m_Index = Utility.Random(16);
     switch (m_Index)
     {
         case 0: //Good To Go
             First = PuzzlePiece.RedSingle;
             Second = PuzzlePiece.BlueSingle;
             Third = PuzzlePiece.RedSingle;
             Fourth = PuzzlePiece.GreenSingle;
             m_MaxAttempts = 6;
             break;
         case 1: //Good To Go
             First = PuzzlePiece.GreenDouble;
             Second = PuzzlePiece.RedBar;
             Third = PuzzlePiece.None;
             Fourth = PuzzlePiece.BlueTriple;
             m_MaxAttempts = 6;
             break;
         case 2: //Good To Go
             First = PuzzlePiece.None;
             Second = PuzzlePiece.None;
             Third = PuzzlePiece.RedBar;
             Fourth = PuzzlePiece.RedTriple;
             m_MaxAttempts = 4;
             break;
         case 3: //Good To Go
             First = PuzzlePiece.BlueDouble;
             Second = PuzzlePiece.None;
             Third = PuzzlePiece.GreenDouble;
             Fourth = PuzzlePiece.GreenDouble;
             m_MaxAttempts = 7;
             break;
         case 4: //Good To Go
             First = PuzzlePiece.BlueSingle;
             Second = PuzzlePiece.GreenSingle;
             Third = PuzzlePiece.GreenDouble;
             Fourth = PuzzlePiece.RedBar;
             m_MaxAttempts = 7;
             break;
         case 5: //Good To Go
             First = PuzzlePiece.GreenDouble;
             Second = PuzzlePiece.BlueBar;
             Third = PuzzlePiece.RedSingle;
             Fourth = PuzzlePiece.BlueSingle;
             m_MaxAttempts = 8;
             break;
         case 6: //Good To Go
             First = PuzzlePiece.GreenSingle;
             Second = PuzzlePiece.RedSingle;
             Third = PuzzlePiece.BlueDouble;
             Fourth = PuzzlePiece.GreenBar;
             m_MaxAttempts = 5;
             break;
         case 7: //Good To Go
             First = PuzzlePiece.BlueDouble;
             Second = PuzzlePiece.None;
             Third = PuzzlePiece.BlueTriple;
             Fourth = PuzzlePiece.None;
             m_MaxAttempts = 4;
             break;
         case 8: //Good To Go
             First = PuzzlePiece.GreenSingle;
             Second = PuzzlePiece.GreenBar;
             Third = PuzzlePiece.RedDouble;
             Fourth = PuzzlePiece.RedSingle;
             m_MaxAttempts = 7;
             break;
         case 9: //Good to Go
             First = PuzzlePiece.BlueSingle;
             Second = PuzzlePiece.GreenDouble;
             Third = PuzzlePiece.None;
             Fourth = PuzzlePiece.GreenTriple;
             m_MaxAttempts = 6;
             break;
         case 10: //Good To Go
             First = PuzzlePiece.BlueSingle;
             Second = PuzzlePiece.RedSingle;
             Third = PuzzlePiece.RedTriple;
             Fourth = PuzzlePiece.None;
             m_MaxAttempts = 6;
             break;
         case 11: //Good To Go
             First = PuzzlePiece.GreenSingle;
             Second = PuzzlePiece.None;
             Third = PuzzlePiece.GreenTriple;
             Fourth = PuzzlePiece.GreenDouble;
             m_MaxAttempts = 5;
             break;
         case 12: //Good to Go
             First = PuzzlePiece.RedTriple;
             Second = PuzzlePiece.None;
             Third = PuzzlePiece.None;
             Fourth = PuzzlePiece.RedTriple;
             m_MaxAttempts = 6;
             break;
         case 13: //Good To Go
             First = PuzzlePiece.None;
             Second = PuzzlePiece.BlueTriple;
             Third = PuzzlePiece.GreenSingle;
             Fourth = PuzzlePiece.BlueDouble;
             m_MaxAttempts = 7;
             break;
         case 14: //Good To Go
             First = PuzzlePiece.BlueTriple;
             Second = PuzzlePiece.None;
             Third = PuzzlePiece.BlueTriple;
             Fourth = PuzzlePiece.None;
             m_MaxAttempts = 6;
             break;
         case 15: //Good to Go
             First = PuzzlePiece.RedSingle;
             Second = PuzzlePiece.BlueDouble;
             Third = PuzzlePiece.RedDouble;
             Fourth = PuzzlePiece.GreenSingle;
             m_MaxAttempts = 6;
             break;
     }
 }
Esempio n. 32
0
        public void LoadStartSolution(int index)
        {
            m_Index = index;

            switch (index)
            {
            case 0:
                First  = PuzzlePiece.RedSingle;
                Second = PuzzlePiece.RedSingle;
                Third  = PuzzlePiece.RedSingle;
                Fourth = PuzzlePiece.RedSingle;
                break;

            case 1:
                First  = PuzzlePiece.BlueBar;
                Second = PuzzlePiece.RedDouble;
                Third  = PuzzlePiece.RedBar;
                Fourth = PuzzlePiece.BlueSingle;
                break;

            case 2:
                First  = PuzzlePiece.GreenBar;
                Second = PuzzlePiece.BlueDouble;
                Third  = PuzzlePiece.RedTriple;
                Fourth = PuzzlePiece.RedBar;
                break;

            case 3:
                First  = PuzzlePiece.RedSingle;
                Second = PuzzlePiece.GreenDouble;
                Third  = PuzzlePiece.BlueTriple;
                Fourth = PuzzlePiece.RedBar;
                break;

            case 4:
                First  = PuzzlePiece.GreenSingle;
                Second = PuzzlePiece.RedBar;
                Third  = PuzzlePiece.RedDouble;
                Fourth = PuzzlePiece.GreenSingle;
                break;

            case 5:
                First  = PuzzlePiece.RedBar;
                Second = PuzzlePiece.GreenBar;
                Third  = PuzzlePiece.RedBar;
                Fourth = PuzzlePiece.BlueBar;
                break;

            case 6:
                First  = PuzzlePiece.RedBar;
                Second = PuzzlePiece.GreenDouble;
                Third  = PuzzlePiece.GreenDouble;
                Fourth = PuzzlePiece.RedBar;
                break;

            case 7:
                First  = PuzzlePiece.GreenBar;
                Second = PuzzlePiece.BlueSingle;
                Third  = PuzzlePiece.BlueTriple;
                Fourth = PuzzlePiece.RedSingle;
                break;

            case 8:
                First  = PuzzlePiece.GreenBar;
                Second = PuzzlePiece.None;
                Third  = PuzzlePiece.GreenTriple;
                Fourth = PuzzlePiece.GreenSingle;
                break;

            case 9:
                First  = PuzzlePiece.RedBar;
                Second = PuzzlePiece.RedBar;
                Third  = PuzzlePiece.RedBar;
                Fourth = PuzzlePiece.RedBar;
                break;

            case 10:
                First  = PuzzlePiece.RedSingle;
                Second = PuzzlePiece.None;
                Third  = PuzzlePiece.BlueDouble;
                Fourth = PuzzlePiece.RedBar;
                break;

            case 11:
                First  = PuzzlePiece.RedDouble;
                Second = PuzzlePiece.GreenDouble;
                Third  = PuzzlePiece.RedDouble;
                Fourth = PuzzlePiece.BlueDouble;
                break;

            case 12:
                First  = PuzzlePiece.GreenTriple;
                Second = PuzzlePiece.BlueBar;
                Third  = PuzzlePiece.GreenTriple;
                Fourth = PuzzlePiece.RedBar;
                break;

            case 13:
                First  = PuzzlePiece.RedSingle;
                Second = PuzzlePiece.GreenBar;
                Third  = PuzzlePiece.GreenBar;
                Fourth = PuzzlePiece.RedSingle;
                break;

            case 14:
                First  = PuzzlePiece.GreenTriple;
                Second = PuzzlePiece.GreenBar;
                Third  = PuzzlePiece.BlueBar;
                Fourth = PuzzlePiece.GreenSingle;
                break;

            case 15:
                First  = PuzzlePiece.BlueTriple;
                Second = PuzzlePiece.GreenDouble;
                Third  = PuzzlePiece.BlueSingle;
                Fourth = PuzzlePiece.RedDouble;
                break;
            }
        }
Esempio n. 33
0
        private void AddPiece(int row, bool right, PuzzlePiece piece)
		{
			int id = GetPuzzlePieceID(piece);
            int x = right ? 405 : 215;
            int y = 82 + (35 * row );

			switch(piece)
			{
				case PuzzlePiece.None:
					break;
                case PuzzlePiece.RedSingle:
                case PuzzlePiece.BlueSingle:
                case PuzzlePiece.GreenSingle:
					AddImage(x + 40, y, id);
					break;
                case PuzzlePiece.RedDouble:
                case PuzzlePiece.BlueDouble:
                case PuzzlePiece.GreenDouble:
					AddImage(x, y, id);
					AddImage(x + 80, y, id);
					break;
                case PuzzlePiece.RedTriple:
                case PuzzlePiece.BlueTriple:
                case PuzzlePiece.GreenTriple:
					AddImage(x, y, id);
					AddImage(x + 40, y, id);
					AddImage(x + 80, y, id);
					break;
                case PuzzlePiece.RedBar:
                case PuzzlePiece.BlueBar:
                case PuzzlePiece.GreenBar:
					AddImage(x, y, id);
                    break;
			}
			
		}
Esempio n. 34
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (m_Item.Deleted || info.ButtonID == 0 || !m_From.CheckAlive())
            {
                return;
            }

            if (m_From.AccessLevel == AccessLevel.Player && !m_Item.IsChildOf(m_From.Backpack))
            {
                m_From.LocalOverheadMessage(MessageType.Regular, 0x3B2, 500446); // That is too far away.
                return;
            }

            switch (info.ButtonID)
            {
            case 0: break;

            default:
            {
                m_Row = info.ButtonID - 1;
                break;
            }

            case 5:
            {
                int nextRow = m_Row - 1;
                if (nextRow < 0)
                {
                    nextRow = 3;
                }

                PuzzlePiece movingPiece   = m_CurrentSolution.Rows[m_Row];
                PuzzlePiece movingToPiece = m_CurrentSolution.Rows[nextRow];

                //Can't move empty spaces
                if (movingPiece == PuzzlePiece.None || m_Item.Attempts >= m_Solution.MaxAttempts)
                {
                    break;
                }

                SplitPiecesUp(ref movingPiece, ref movingToPiece);

                if (movingPiece != m_CurrentSolution.Rows[m_Row] || movingToPiece != m_CurrentSolution.Rows[nextRow])
                {
                    m_CurrentSolution.Rows[m_Row]   = movingPiece;
                    m_CurrentSolution.Rows[nextRow] = movingToPiece;

                    m_Item.CurrentSolution = m_CurrentSolution;
                    m_Item.Attempts++;
                }
                break;
            }

            case 6:
            {
                int nextRow = m_Row + 1;
                if (nextRow > 3)
                {
                    nextRow = 0;
                }

                PuzzlePiece movingPiece   = m_CurrentSolution.Rows[m_Row];
                PuzzlePiece movingToPiece = m_CurrentSolution.Rows[nextRow];

                //Can't Move Empty Spaces
                if (movingPiece == PuzzlePiece.None || m_Item.Attempts >= m_Solution.MaxAttempts)
                {
                    break;
                }

                SplitPiecesDown(ref movingPiece, ref movingToPiece);

                if (movingPiece != m_CurrentSolution.Rows[m_Row] || movingToPiece != m_CurrentSolution.Rows[nextRow])
                {
                    m_CurrentSolution.Rows[m_Row]   = movingPiece;
                    m_CurrentSolution.Rows[nextRow] = movingToPiece;

                    m_Item.Attempts++;

                    m_Item.CurrentSolution = m_CurrentSolution;
                }
                break;
            }

            case 7:
            {
                if (m_Item.SubmitSolution(m_From, m_CurrentSolution))
                {
                    return;
                }
                break;
            }

            case 8:
            {
                int index = m_Item.Solution.Index;
                m_Item.CurrentSolution = new UnderworldPuzzleSolution(index);
                m_Item.Attempts        = 0;
                break;
            }
            }

            m_From.SendGump(new UnderworldPuzzleGump(m_From, m_Item, m_Row));
        }
Esempio n. 35
0
        private void SplitPiecesUp(ref PuzzlePiece movingPiece, ref PuzzlePiece movingToPiece)
		{
			int movingAmount = GetTotalPieces(movingPiece);
			int moveToAmount = GetTotalPieces(movingToPiece);

            if (movingToPiece == PuzzlePiece.None)
            {
                if ((movingAmount == 2 || movingAmount == 4))
                {
                    switch (movingPiece)
                    {
                        case PuzzlePiece.RedDouble:
                            movingToPiece = PuzzlePiece.BlueSingle;
                            movingPiece = PuzzlePiece.GreenSingle;
                            break;
                        case PuzzlePiece.BlueDouble:
                            movingToPiece = PuzzlePiece.GreenSingle;
                            movingPiece = PuzzlePiece.RedSingle;
                            break;
                        case PuzzlePiece.GreenDouble:
                            movingToPiece = PuzzlePiece.RedSingle;
                            movingPiece = PuzzlePiece.BlueSingle;
                            break;
                        case PuzzlePiece.RedBar:
                            movingToPiece = PuzzlePiece.BlueDouble;
                            movingPiece = PuzzlePiece.GreenDouble;
                            break;
                        case PuzzlePiece.BlueBar:
                            movingToPiece = PuzzlePiece.GreenDouble;
                            movingPiece = PuzzlePiece.RedDouble;
                            break;
                        case PuzzlePiece.GreenBar:
                            movingToPiece = PuzzlePiece.RedDouble;
                            movingPiece = PuzzlePiece.BlueDouble;
                            break;
                    }
                }

                return;
            }
			
			if(movingAmount + moveToAmount > 4)
			{
				PuzzlePiece movingTemp = movingPiece;
				PuzzlePiece movingToTemp = movingToPiece;
				
				movingPiece = movingToTemp;
				movingToPiece = movingTemp;
				
				return;
			}
			
            movingToPiece = CombinePieces(movingPiece, movingToPiece);
            movingPiece = PuzzlePiece.None;
		}
Esempio n. 36
0
        private void SplitPiecesDown(ref PuzzlePiece movingPiece, ref PuzzlePiece movingToPiece)
        {
            int movingAmount = GetTotalPieces(movingPiece);
            int moveToAmount = GetTotalPieces(movingToPiece);

            if (movingToPiece == PuzzlePiece.None)
            {
                if ((movingAmount == 2 || movingAmount == 4))
                {
                    switch (movingPiece)
                    {
                    case PuzzlePiece.RedDouble:
                        movingToPiece = PuzzlePiece.BlueSingle;
                        movingPiece   = PuzzlePiece.GreenSingle;
                        break;

                    case PuzzlePiece.BlueDouble:
                        movingToPiece = PuzzlePiece.GreenSingle;
                        movingPiece   = PuzzlePiece.RedSingle;
                        break;

                    case PuzzlePiece.GreenDouble:
                        movingToPiece = PuzzlePiece.RedSingle;
                        movingPiece   = PuzzlePiece.BlueSingle;
                        break;

                    case PuzzlePiece.RedBar:
                        movingToPiece = PuzzlePiece.BlueDouble;
                        movingPiece   = PuzzlePiece.GreenDouble;
                        break;

                    case PuzzlePiece.BlueBar:
                        movingToPiece = PuzzlePiece.GreenDouble;
                        movingPiece   = PuzzlePiece.RedDouble;
                        break;

                    case PuzzlePiece.GreenBar:
                        movingToPiece = PuzzlePiece.RedDouble;
                        movingPiece   = PuzzlePiece.BlueDouble;
                        break;
                    }
                }

                return;
            }

            int t = 0;

            //PuzzlePiece greater = movingPiece;

            if (moveToAmount > movingAmount)
            {
                //greater = movingToPiece;
                t = (int)movingToPiece - movingAmount;
            }
            else if (movingAmount > moveToAmount)
            {
                //greater = movingPiece;
                //t = (int)movingToPiece + (movingAmount - moveToAmount);
                //t -= 1;
                if (movingAmount == 4 && moveToAmount == 3)
                {
                    t = (int)movingToPiece - 2;
                }
                else if (movingAmount == 4 && moveToAmount == 2)
                {
                    t = (int)movingToPiece;
                }
                else if (movingAmount == 4 && moveToAmount == 1)
                {
                    t = (int)movingToPiece + 2;
                }

                else if (movingAmount == 2 && moveToAmount == 1)
                {
                    t = (int)movingToPiece;
                }
                else if (movingAmount == 3 && moveToAmount == 2)
                {
                    t = (int)movingToPiece - 1;
                }
                else if (movingAmount == 3 && moveToAmount == 1)
                {
                    t = (int)movingToPiece + 1;
                }
            }
            else
            {
                movingPiece   = PuzzlePiece.None;
                movingToPiece = PuzzlePiece.None;
                return;
            }

            movingToPiece = (PuzzlePiece)t;
            movingPiece   = PuzzlePiece.None;
        }
Esempio n. 37
0
        private PuzzlePiece CombinePieces(PuzzlePiece moving, PuzzlePiece movingInto)
        {
            int movingAmount = GetTotalPieces(moving);
            int moveToAmount = GetTotalPieces(movingInto);
            int combined = movingAmount + moveToAmount;

            if (movingAmount != moveToAmount)
            {
                int t = (int)movingInto + movingAmount; //combined + (int)moving;
                return (PuzzlePiece)t;
            }

            combined--;

            PuzzleColor movingCol = GetColor(moving);
            PuzzleColor movingIntoCol = GetColor(movingInto);

            switch (movingCol)
            {
                case PuzzleColor.Red:
                    switch (movingIntoCol)
                    {
                        case PuzzleColor.Red:
                            return PuzzlePiece.RedSingle + combined;
                        case PuzzleColor.Blue:
                            return PuzzlePiece.GreenSingle + combined;
                        case PuzzleColor.Green:
                            return PuzzlePiece.BlueSingle + combined;
                    }
                    break;
                case PuzzleColor.Blue:
                    switch (movingIntoCol)
                    {
                        case PuzzleColor.Red:
                            return PuzzlePiece.GreenSingle + combined;
                        case PuzzleColor.Blue:
                            return PuzzlePiece.BlueSingle + combined;
                        case PuzzleColor.Green:
                            return PuzzlePiece.RedSingle + combined;
                    }
                    break;
                case PuzzleColor.Green:
                    switch (movingIntoCol)
                    {
                        case PuzzleColor.Red:
                            return PuzzlePiece.BlueSingle + combined;
                        case PuzzleColor.Blue:
                            return PuzzlePiece.RedSingle + combined;
                        case PuzzleColor.Green:
                            return PuzzlePiece.GreenSingle + combined;
                    }
                    break;
            }

            return moving;
        }
Esempio n. 38
0
        private PuzzlePiece CombinePieces(PuzzlePiece moving, PuzzlePiece movingInto)
        {
            int movingAmount = GetTotalPieces(moving);
            int moveToAmount = GetTotalPieces(movingInto);
            int combined     = movingAmount + moveToAmount;

            if (movingAmount != moveToAmount)
            {
                int t = (int)movingInto + movingAmount; //combined + (int)moving;
                return((PuzzlePiece)t);
            }

            combined--;

            PuzzleColor movingCol     = GetColor(moving);
            PuzzleColor movingIntoCol = GetColor(movingInto);

            switch (movingCol)
            {
            case PuzzleColor.Red:
                switch (movingIntoCol)
                {
                case PuzzleColor.Red:
                    return(PuzzlePiece.RedSingle + combined);

                case PuzzleColor.Blue:
                    return(PuzzlePiece.GreenSingle + combined);

                case PuzzleColor.Green:
                    return(PuzzlePiece.BlueSingle + combined);
                }
                break;

            case PuzzleColor.Blue:
                switch (movingIntoCol)
                {
                case PuzzleColor.Red:
                    return(PuzzlePiece.GreenSingle + combined);

                case PuzzleColor.Blue:
                    return(PuzzlePiece.BlueSingle + combined);

                case PuzzleColor.Green:
                    return(PuzzlePiece.RedSingle + combined);
                }
                break;

            case PuzzleColor.Green:
                switch (movingIntoCol)
                {
                case PuzzleColor.Red:
                    return(PuzzlePiece.BlueSingle + combined);

                case PuzzleColor.Blue:
                    return(PuzzlePiece.RedSingle + combined);

                case PuzzleColor.Green:
                    return(PuzzlePiece.GreenSingle + combined);
                }
                break;
            }

            return(moving);
        }
Esempio n. 39
0
 private int GetPuzzlePieceID(PuzzlePiece piece)
 {
     switch (piece)
     {
         default:
         case PuzzlePiece.None: return 0x0;
         case PuzzlePiece.RedSingle:
         case PuzzlePiece.RedDouble:
         case PuzzlePiece.RedTriple: return 0x2A62;
         case PuzzlePiece.BlueSingle:
         case PuzzlePiece.BlueDouble:
         case PuzzlePiece.BlueTriple: return 0x2A3A;
         case PuzzlePiece.GreenSingle:
         case PuzzlePiece.GreenDouble:
         case PuzzlePiece.GreenTriple: return 0x2A4E;
         case PuzzlePiece.RedBar: return 0x2A58;
         case PuzzlePiece.BlueBar: return 0x2A30;
         case PuzzlePiece.GreenBar: return 0x2A44;
     }
 }
Esempio n. 40
0
 private void SetRandomPosition(PuzzlePiece piece)
 {
     piece.XIndex = random.Next(-gridWidth, gridWidth * 2 - piece.Width);
     piece.YIndex = random.Next(-gridHeight, gridHeight * 2 - piece.Height);
 }