Example #1
0
        public static void ShapeDropTriggered()
        {
            if (SelectedShape.State == Shape.ShapeState.TransitionIn || SelectedShape.State == Shape.ShapeState.TransitionOut)
            {
                return;
            }

            if (IsSelectedShapeOverPuzzle && SelectedShape.IsSnapped)
            {
                // enter shape into shapelayer
                if (CurrentPuzzle.CanAddShape(CursorTilePosition, SelectedShape))
                {
                    CurrentPuzzle.AddShape(CursorTilePosition, SelectedShape);
                    SelectedShape.State   = Shape.ShapeState.Dropped;
                    Cursor.ScreenPosition = SelectedShape.ScreenPosition;
                    SelectedShapeKey      = 0;
                    Cursor.CursorMode     = CursorState.Free;
                    AudioManager.PlayCue("dropSnapped");
                    checkForSolved = true;
                }
                else
                {
                    AudioManager.PlayCue("error");
                }
            }
            else
            {
                SelectedShape.State   = Shape.ShapeState.Dropped;
                Cursor.ScreenPosition = SelectedShape.ScreenPosition;
                SelectedShapeKey      = 0;
                Cursor.CursorMode     = CursorState.Free;
                AudioManager.PlayCue("drop");
            }
        }
Example #2
0
        public static void ResetCurrentPuzzleShapes(bool invalidOnly, bool isHardReset)
        {
            bool playCue = false;

            Cursor.CursorMode = CursorState.Reset;

            if (SelectedShape != null)
            {
                resetSelectedShape();
                playCue = true;
            }

            foreach (Shape shape in CurrentPuzzleSet.ShapesDict.Values)
            {
                if (shape.State != Shape.ShapeState.Waiting)
                {
                    if (invalidOnly)
                    {
                        if (!shape.IsValid)
                        {
                            CurrentPuzzle.RemoveShape(shape);
                            if (isHardReset)
                            {
                                shape.Reset();
                                //                                shape.State = Shape.ShapeState.Resetting;
                            }
                            else
                            {
                                playCue     = true;
                                shape.State = Shape.ShapeState.TransitionOut;
                            }
                        }
                    }
                    else
                    {
                        CurrentPuzzle.RemoveShape(shape);
                        if (isHardReset)
                        {
                            shape.Reset();
                        }
                        else
                        {
                            playCue     = true;
                            shape.State = Shape.ShapeState.TransitionOut;
                        }
                    }
                }
            }

            if (playCue)
            {
                AudioManager.PlayCue("replaceShape");
            }

            Cursor.CursorMode = CursorState.Free;
        }
Example #3
0
 public void LetterGuessed(string letter)
 {
     if (!string.IsNullOrEmpty(letter))
     {
         lock (this)
         {
             if (CurrentPuzzle == null)
             {
                 CurrentPuzzle = new Puzzle(Words);
             }
             CurrentPuzzle.LetterGuessed(letter);
         }
     }
 }
Example #4
0
        public static void ShapeFlipTriggered(bool isHorizontal)
        {
            AudioManager.PlayCue("flip");

            if (isHorizontal)
            {
                CurrentPuzzle.CountHorizontalFlip();
                SelectedShape.StartFlipHorizontal();
            }
            else
            {
                CurrentPuzzle.CountVerticalFlip();
                SelectedShape.StartFlipVertical();
            }
        }
Example #5
0
        private static void puzzleCleared(int shapesUsed)
        {
            mainScreen.HelpPanel.Off(true);

            ResetCurrentPuzzleShapes(true, false);
            CurrentPuzzle.IsCleared = true;
            CurrentPuzzleSet.UnlockNextPuzzle();

            // update statistics & build solution
            PlayerSolution solution = new PlayerSolution();

            solution.PuzzleKey      = CurrentPuzzle.Key;
            solution.SolutionShapes = new List <PlayerSolutionShape>();

            foreach (Shape shape in CurrentPuzzleSet.ShapesDict.Values)
            {
                if (shape.IsValid)
                {
                    Vector2 position = new Vector2(shape.DestRect.X, shape.DestRect.Y);

                    PlayerSolutionShape userShape = new PlayerSolutionShape();
                    userShape.ShapeKey            = shape.Key;
                    userShape.OriginPoint         = PuzzleEngine.GetPuzzleTilePosition(new Vector2(shape.DestRect.X, shape.DestRect.Y));
                    userShape.IsFlippedHorizontal = shape.IsFlippedHorizontal;
                    userShape.IsFlippedVertical   = shape.IsFlippedVertical;
                    userShape.RotationIdx         = shape.CurrentRotationIdx;

                    solution.SolutionShapes.Add(userShape);

                    CurrentPuzzle.Statistics.ShapesUsedKeys.Add(shape.Key);
                }
            }

            CurrentPuzzle.PlayerSolution = solution;
            CurrentPuzzle.SetCompletedStats(shapesUsed, PuzzleTimer);
            CurrentPuzzleSet.Statistics      += CurrentPuzzle.Statistics;
            Cursor.CursorMode                 = CursorState.Hidden;
            CurrentPuzzle.IsRenderPortrait    = true;
            SelectedPickerEntry.IsRenderEntry = true;
            IsCheckRender = true;
            MainScreen.PuzzlePanel.ResetPuzzleName();
            MainScreen.PuzzlePanel.InitSolutionDict(solution.SolutionShapes);
            MainScreen.PuzzlePanel.PanelState   = PuzzlePanel.PuzzlePanelState.Cleared;
            MainScreen.PuzzlePanel.ClearedState = PuzzlePanel.PuzzleClearedState.Prepare;
        }
Example #6
0
        public static void ShapeRotateTriggered(bool isCW)
        {
            AudioManager.PlayCue("rotate");

            if (isCW)
            {
                CurrentPuzzle.CountCWRotation();
                SelectedShape.StartRotationCW();
            }
            else
            {
                CurrentPuzzle.CountCCWRotation();
                SelectedShape.StartRotationCCW();
            }

            SelectedShape.ShapeOrigin = new Vector2(SelectedShape.ShapeOrigin.Y, SelectedShape.ShapeOrigin.X);
            Cursor.ScreenPosition     = SelectedShape.Shape00Position;
        }
Example #7
0
        public static void ShapeGrabTriggered()
        {
            if (MainScreen.PuzzlePanel.SelectedShapeKey == 0)
            {
                return;
            }

            Shape selectedShape = CurrentPuzzleSet.ShapesDict[MainScreen.PuzzlePanel.SelectedShapeKey];

            switch (selectedShape.State)
            {
            case Shape.ShapeState.Dropped:
                Cursor.CursorMode   = CursorState.Grab;
                SelectedShapeKey    = selectedShape.Key;
                SelectedShape.State = Shape.ShapeState.Selected;
                SelectedShape.CursorReturnOffset = Cursor.ScreenPosition - SelectedShape.Shape00Position;

                Cursor.ScreenPosition = SelectedShape.Shape00Position;
                CurrentPuzzle.RemoveShape(SelectedShape);

                if (SelectedShape.IsSnapped)
                {
                    AudioManager.PlayCue("grabSnapped");
                }
                else
                {
                    AudioManager.PlayCue("grab");
                }
//                    return;
                break;

            case Shape.ShapeState.Waiting:
                Cursor.CursorMode   = CursorState.Grab;
                SelectedShapeKey    = selectedShape.Key;
                SelectedShape.State = Shape.ShapeState.TransitionIn;
                SelectedShape.CursorReturnOffset = SelectedShape.ShapeOrigin;

                Cursor.ScreenPosition = SelectedShape.Shape00Position;

                AudioManager.PlayCue("selectShape");
//                    return;
                break;
            }
        }
Example #8
0
        /// Update the tile engine.
        public static void UpdatePuzzle(GameTime gameTime)
        {
            if (!isTimerDisabled)
            {
                PuzzleEngine.PuzzleTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
            }

            cursor.Update(gameTime);
            CurrentPuzzleSet.Update(gameTime);
            hintManager.Update(gameTime);

            // checkSolved will be set by shapeDropped handleInput action because any dropped shape can trigger a solution
            if (checkForSolved)
            {
                int solution = CurrentPuzzle.CheckSolved(CurrentPuzzleSet.ShapesDict);
                if (solution != 0)
                {
                    puzzleCleared(solution);
                }
                checkForSolved = false;
            }
        }