Пример #1
0
        /// <summary>
        /// Mouse Right Click Handler For Game Round
        /// </summary>
        /// <param name="xMouse"></param>
        /// <param name="yMouse"></param>
        public void GameRoundRightClickHandler(int xMouse, int yMouse)
        {
            // Check the game state
            if (_gameState != GameState.PLAYING)
            {
                return;
            }

            _score.ComboInterrupted();

            _tuple.Clear();

            _sePlayer.Cancel(); // Cancel SE
        }
Пример #2
0
        /// <summary>
        /// Check is there a path with 2 turning points
        /// </summary>
        /// <param name="hStartTuple"></param>
        /// <param name="vStartTuple"></param>
        /// <param name="hEndTuple"></param>
        /// <param name="vEndTuple"></param>
        /// <param name="grid"></param>
        /// <param name="intersections"></param>
        /// <returns></returns>
        private bool _isTuringTwice(
            Tuple hStartTuple,
            Tuple vStartTuple,
            Tuple hEndTuple,
            Tuple vEndTuple,
            Grid grid,
            out Position[] intersections)
        {
            Tuple lineSegment;

            intersections = null;

            // Both horizontal lines - Base: hStartTuple
            Position hStartA = hStartTuple.GetFirst();
            Position hStartB = hStartTuple.GetSecond();
            Position hEndA   = hEndTuple.GetFirst();
            Position hEndB   = hEndTuple.GetSecond();

            // Validation
            if (hStartA.X > hStartB.X)
            {
                throw new Exception();
            }
            if (hEndA.Y > hEndB.Y)
            {
                throw new Exception();
            }
            // Enumerate all possible line segments between lines: hStart and hEnd
            lineSegment = new Tuple(grid);
            for (int i = hStartA.X; i <= hStartB.X; ++i)
            {
                lineSegment.Clear();
                if (i >= hEndA.X && i <= hEndB.X)
                {
                    // Existed that path
                    if (hStartA.Y <= hEndA.Y)
                    {
                        // hStartA is upper line
                        lineSegment.Select(new Position(i, hStartA.Y));
                        lineSegment.Select(new Position(i, hEndA.Y));
                    }
                    else
                    {
                        // hEndA is upper line
                        lineSegment.Select(new Position(i, hEndA.Y));
                        lineSegment.Select(new Position(i, hStartA.Y));
                    }
                    // Check this line segment is a valid path
                    if (_isExistedPath(lineSegment, grid))
                    {
                        intersections    = new Position[2];
                        intersections[0] = lineSegment.GetFirst();
                        intersections[1] = lineSegment.GetSecond();
                        return(true);
                    }
                }
            }

            // Both vertical lines - Base: vStartTuple
            Position vStartA = vStartTuple.GetFirst();
            Position vStartB = vStartTuple.GetSecond();
            Position vEndA   = vEndTuple.GetFirst();
            Position vEndB   = vEndTuple.GetSecond();

            // Validation
            if (vStartA.X > vStartB.X)
            {
                throw new Exception();
            }
            if (vEndA.Y > vEndB.Y)
            {
                throw new Exception();
            }
            // Enumerate all possible line segments between lines: vStart and vEnd
            lineSegment = new Tuple(grid);
            for (int i = vStartA.Y; i <= vStartB.Y; ++i)
            {
                lineSegment.Clear();
                if (i >= vEndA.Y && i <= vEndB.Y)
                {
                    // Existed that path
                    if (vStartA.X <= vEndA.X)
                    {
                        // vStartA is left line
                        lineSegment.Select(new Position(vStartA.X, i));
                        lineSegment.Select(new Position(vEndA.X, i));
                    }
                    else
                    {
                        // vEndA is left line
                        lineSegment.Select(new Position(vEndA.X, i));
                        lineSegment.Select(new Position(vStartA.X, i));
                    }
                    // Check this line segment is a valid path
                    if (_isExistedPath(lineSegment, grid))
                    {
                        intersections    = new Position[2];
                        intersections[0] = lineSegment.GetFirst();
                        intersections[1] = lineSegment.GetSecond();
                        return(true);
                    }
                }
            }

            return(false);
        }