Exemplo n.º 1
0
        /// <summary>
        /// 새 퍼즐을 만듦.
        /// </summary>
        /// <returns></returns>
        private async UniTask CreateNewPuzzle()
        {
            Debug.Log($"{nameof (CreateNewPuzzle)}ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ");

            AllLineModels.Where(x => x.Value.IsCreateLine).Foreach(lineModel =>
            {
                var position = new PositionModel(lineModel.Key, lineModel.Value.CreatePuzzleRow());
                var puzzle   = GetContainPuzzleModel(position);
                if (puzzle != null && !puzzle.IsChecked)
                {
                    return;
                }

                var removedPuzzle = AllPuzzleModels.FirstOrDefault(x => x.IsChecked);
                if (removedPuzzle == null)
                {
                    return;
                }

                var puzzleColor =
                    (PuzzleColorTypes)Random.Range((int)PuzzleColorTypes.None + 1, (int)PuzzleColorTypes.Max);
                Debug.LogWarning($"create {puzzleColor} at {position}");
                removedPuzzle.ResetPuzzle(puzzleColor, position);
                _alignedPuzzles.Add(removedPuzzle);
            });

            await UniTask.Delay(TimeSpan.FromSeconds(GameConstants.FlowCheckTime), cancellationToken : _cancellationTokenSource.Token);
        }
Exemplo n.º 2
0
 /// <summary>
 /// generate lands.
 /// </summary>
 private void InitializeGame()
 {
     AllLineModels.Clear();
     AllPuzzleModels.Clear();
     _predicatedFlowSidePositionDict.Clear();
     _predicatedFlowDownPositions.Clear();
     _alignedPuzzles.Clear();
 }
Exemplo n.º 3
0
        /// <summary>
        /// 해당 방향에 있는 바로 옆 퍼즐의 키 값을 리턴.
        /// </summary>
        public PositionModel GetKeyByAngle(PositionModel positionModel, float angle)
        {
            if (!AllLineModels.ContainsKey(positionModel.Column))
            {
                return(PositionModel.EmptyPositionModel);
            }

            // To upper direction.
            if (Enumerable.Range(150, 60).Contains((int)angle))
            {
                return(new PositionModel(positionModel.Column, positionModel.Row + 1));
            }

            // To upper right direction.
            if (Enumerable.Range(210, 60).Contains((int)angle))
            {
                return(GetPuzzlePosition(false));
            }

            // To lower right direction.
            if (Enumerable.Range(270, 60).Contains((int)angle))
            {
                return(GetPuzzlePosition(false, false));
            }

            // To upper left direction.
            if (Enumerable.Range(90, 60).Contains((int)angle))
            {
                return(GetPuzzlePosition());
            }

            // To lower left direction.
            if (Enumerable.Range(30, 60).Contains((int)angle))
            {
                return(GetPuzzlePosition(toUpper: false));
            }

            // To lower direction.
            return(new PositionModel(positionModel.Column, positionModel.Row - 1));

            PositionModel GetPuzzlePosition(bool toLeft = true, bool toUpper = true)
            {
                var checkColumn = positionModel.Column + (toLeft ? -1 : 1);

                if (!AllLineModels.ContainsKey(checkColumn))
                {
                    return(PositionModel.EmptyPositionModel);
                }

                var anEvenNumberColumn = positionModel.Column % 2 == 0;
                var posCoeff           = anEvenNumberColumn && toUpper ? 0 : anEvenNumberColumn ? -1 : toUpper ? 1 : 0;

                return(new PositionModel(checkColumn, positionModel.Row + posCoeff));
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 배열 세팅.
 /// </summary>
 private void CreateLines()
 {
     AllLineModels.Clear();
     AllLineModels.Add(0, new LineModel
     {
         LandDatas = new List <LandModel>
         {
             new LandModel(0, LandTypes.Hide),
             new LandModel(1, LandTypes.Hide),
             new LandModel(2, LandTypes.Show),
             new LandModel(3, LandTypes.Show),
             new LandModel(4, LandTypes.Show),
             new LandModel(5, LandTypes.Hide),
         },
         IsCreateLine = false,
     });
     AllLineModels.Add(1, new LineModel
     {
         LandDatas = new List <LandModel>
         {
             new LandModel(0, LandTypes.Hide),
             new LandModel(1, LandTypes.Show),
             new LandModel(2, LandTypes.Show),
             new LandModel(3, LandTypes.Show),
             new LandModel(4, LandTypes.Show),
             new LandModel(5, LandTypes.Hide),
         },
         IsCreateLine = true,
     });
     AllLineModels.Add(2, new LineModel
     {
         LandDatas = new List <LandModel>
         {
             new LandModel(0, LandTypes.Hide),
             new LandModel(1, LandTypes.Show),
             new LandModel(2, LandTypes.Show),
             new LandModel(3, LandTypes.Show),
             new LandModel(4, LandTypes.Show),
             new LandModel(5, LandTypes.Show),
         },
         IsCreateLine = true,
     });
     AllLineModels.Add(3, new LineModel
     {
         LandDatas = new List <LandModel>
         {
             new LandModel(0, LandTypes.Show),
             new LandModel(1, LandTypes.Show),
             new LandModel(2, LandTypes.Show),
             new LandModel(3, LandTypes.Show),
             new LandModel(4, LandTypes.Show),
             new LandModel(5, LandTypes.Show),
         },
         IsCreateLine = true,
     });
     AllLineModels.Add(4, new LineModel
     {
         LandDatas = new List <LandModel>
         {
             new LandModel(0, LandTypes.Hide),
             new LandModel(1, LandTypes.Show),
             new LandModel(2, LandTypes.Show),
             new LandModel(3, LandTypes.Show),
             new LandModel(4, LandTypes.Show),
             new LandModel(5, LandTypes.Show),
         },
         IsCreateLine = true,
     });
     AllLineModels.Add(5, new LineModel
     {
         LandDatas = new List <LandModel>
         {
             new LandModel(0, LandTypes.Hide),
             new LandModel(1, LandTypes.Show),
             new LandModel(2, LandTypes.Show),
             new LandModel(3, LandTypes.Show),
             new LandModel(4, LandTypes.Show),
             new LandModel(5, LandTypes.Hide),
         },
         IsCreateLine = true,
     });
     AllLineModels.Add(6, new LineModel
     {
         LandDatas = new List <LandModel>
         {
             new LandModel(0, LandTypes.Hide),
             new LandModel(1, LandTypes.Hide),
             new LandModel(2, LandTypes.Show),
             new LandModel(3, LandTypes.Show),
             new LandModel(4, LandTypes.Show),
             new LandModel(5, LandTypes.Hide),
         },
         IsCreateLine = false,
     });
 }
Exemplo n.º 5
0
 public bool ContainLineModel(PositionModel positionModel)
 {
     return(AllLineModels.ContainsKey(positionModel.Column) &&
            AllLineModels[positionModel.Column].ContainRow(positionModel.Row));
 }