예제 #1
0
 /// <summary>
 /// 퍼즐 컨트롤 모델 변경.
 /// </summary>
 public void ChangeControlMode(bool isPlayerControl, PuzzleCheckTypes puzzleCheckTypes,
                               IEnumerable <PuzzleModel> controledPuzzles)
 {
     _playerControlModel.IsPlayerControl        = isPlayerControl;
     _playerControlModel.PlayerControlDirection = puzzleCheckTypes;
     _playerControlModel.AddControledPuzzles(controledPuzzles);
 }
예제 #2
0
        private (CheckDirectionTypes, CheckDirectionTypes) GetCheckDirectionTypesByPuzzleCheckType(
            PuzzleCheckTypes puzzleCheckTypes)
        {
            switch (puzzleCheckTypes)
            {
            case PuzzleCheckTypes.ToVertical:
                return(CheckDirectionTypes.ToUpward, CheckDirectionTypes.ToDownward);

            case PuzzleCheckTypes.ToUpLeftDownRight:
                return(CheckDirectionTypes.ToUpLeft, CheckDirectionTypes.ToDownRight);

            case PuzzleCheckTypes.ToUpRightDownLeft:
                return(CheckDirectionTypes.ToUpRight, CheckDirectionTypes.ToDownLeft);

            default:
                throw new ArgumentOutOfRangeException(nameof(puzzleCheckTypes), puzzleCheckTypes, null);
            }
        }
예제 #3
0
        /// <summary>
        /// 체크 영역의 퍼즐들을 체크함.
        /// </summary>
        private int FindPuzzleCheckDirectionArea(PositionModel positionModel, PuzzleColorTypes colorTypes,
                                                 PuzzleCheckTypes puzzleCheckTypes, UnityAction <PuzzleModel> action = null)
        {
            var continuoslyCount = 0;

            var(checkDir, otherCheckDir) = GetCheckDirectionTypesByPuzzleCheckType(puzzleCheckTypes);
            var positionModels = GetPositionKeysByAngle(positionModel, checkDir, otherCheckDir);

            positionModels.List
            .Select((position, index) => (GetContainPuzzleModel(position), index))
            .Where(valueTuple => valueTuple.Item1 != null)
            .Foreach(valueTuple =>
            {
                var(foundPuzzle, index) = valueTuple;
                if (foundPuzzle.PuzzleColorTypes == PuzzleColorTypes.None)
                {
                    return;
                }

                if (foundPuzzle.PositionModel.Equals(positionModel))
                {
                    Check();
                    return;
                }

                // 체크하려는 포지션에 있는 퍼즐이 대상의 색상과 같지 않음.
                if (!foundPuzzle.PuzzleColorTypes.Equals(colorTypes))
                {
                    return;
                }

                if (IndexCheck(index))
                {
                    Check();
                }

                void Check()
                {
                    continuoslyCount++;
                    action?.Invoke(foundPuzzle);
                }
            });

            // 체크하려는 포지션에서 대상의 퍼즐 포지션 안쪽에 있는 퍼즐과 체크를 함.
            // ex) 0, 1, 2, 3, 4의 포지션이 있을 경우. 0, 4의 포지션은 각각 1, 3의 포지션의 퍼즐을 체크 함.
            bool IndexCheck(int index)
            {
                if (index != 0 && index != 4)
                {
                    return(true);
                }

                var insidePosition = index == 0 ? positionModels.Previous : positionModels.Next;

                if (insidePosition == null)
                {
                    return(false);
                }

                var insidePuzzleColorTypes = GetContainPuzzleColorTypes(insidePosition.Value);

                return(insidePuzzleColorTypes.Equals(colorTypes));
            }

            return(continuoslyCount < (int)PuzzleMatchingTypes.ThreeMatching ? 0 : continuoslyCount);
        }