Beispiel #1
0
        /// <summary>
        /// Create gameboard and move to bottom visible row
        /// </summary>
        /// <param name="move"></param>
        internal void CreateGameBoard(bool move)
        {
            Debug.Log("level set: " + LcSet.name);
            Debug.Log("curr level: " + BubblesPlayer.CurrentLevel);
            BackGround = GoSet.BackGround(LcSet.BackGround);
            int vertSize = (LcSet.VertSize > 0) ? LcSet.VertSize : 10;
            int horSize  = (LcSet.HorSize > 0) ? LcSet.HorSize : 10;

            List <CellData> mainObjectsData = LcSet.featuredCells;
            List <CellData> overObjectsData = LcSet.overlays;

            float scale = LcSet.Scale;

            if (gMode == GameMode.Play)
            {
                if (grid != null)
                {
                    grid.DestroyGrid();
                }
                grid = new BubbleGrid(LcSet, GoSet, GridContainer, SortingOrder.Base, gMode);
                grid.AddEmptyRow();
            }
            else
            {
                if (grid != null)
                {
                    grid.Rebuild(LcSet, GoSet, SortingOrder.Base, gMode);
                }
                else
                {
                    grid = new BubbleGrid(LcSet, GoSet, GridContainer, SortingOrder.Base, gMode);
                }
#if UNITY_EDITOR
                // set cells delegates for constructor
                for (int i = 0; i < grid.Cells.Count; i++)
                {
                    grid.Cells[i].PointerDownEvent = (c) =>
                    {
                        if (c.Row < LcSet.VertSize) // don't using reserved rows
                        {
                            gConstructor.GetComponent <GameConstructor>().Cell_Click(c);
                        }
                    };

                    grid.Cells[i].DragEnterEvent = (c) =>
                    {
                        if (c.Row < LcSet.VertSize) // don't using reserved rows
                        {
                            gConstructor.GetComponent <GameConstructor>().Cell_Click(c);
                        }
                    };
                }
#endif
            }
            if (move)
            {
                grid.MoveToVisible(() =>
                {
                    if (gMode == GameMode.Play)
                    {
                        if (anchor)
                        {
                            if (WController.GameLevelType == LevelType.AnchorLevel)
                            {
                                anchor.gameObject.SetActive(true);
                                anchor.InitStart(grid, grid.GetBottomRow()[5]);
                            }
                            else
                            {
                                anchor.gameObject.SetActive(false);
                            }
                        }
                        if (WController.GameLevelType == LevelType.TimeLevel)
                        {
                            WController.Timer.Start();
                        }
                    }
                });
            }
        }
Beispiel #2
0
        private void Shooting()
        {
            // BubblesShooter.Instance.ShowSwapPath();

            if (TouchManager.IsTouched && BubblesShooter.Instance.TouchInRange())
            {
                BubblesShooter.Instance.ShowShootLine();
            }
            else if (TouchManager.IsTouched && !BubblesShooter.Instance.TouchInRange())
            {
                BubblesShooter.Instance.HideShootLine();
                BubblesShooter.Instance.CleanTargets();
            }
            else if (!TouchManager.IsTouched)
            {
                BubblesShooter.Instance.HideShootLine(); //Debug.Log("Can Shoot " + BubblesShooter.CanShoot);

                if (BubblesShooter.CanShoot)             // shoot
                {
                    GoToDTMode();                        // diasable touch
                    mainSeq = new TweenSeq();
                    mainSeq.Add((callBack) =>            // move bubble to free target, hit target, and check result
                    {
                        BubblesShooter.Instance.Shoot(callBack);
                    });

                    mainSeq.Add((callBack) => // collect all bubbles in shootarea
                    {
                        BubblesShooter.Instance.ShootCollect(callBack);
                    });

                    mainSeq.Add((callBack) => //  collect all fall down objects
                    {
                        BubblesShooter.Instance.CleanTargets();
                        detCells = new CellsGroup();
                        detCells.AddRange(grid.GetDetacheCells());
                        detCells.FallDownCollect(BubblesShooter.Instance.BubbleScore, null);
                        WController.CheckResult(false, false);// check shoot result
                        grid.AddEmptyRow();

                        callBack();
                    });

                    if (WController.GameLevelType == LevelType.AnchorLevel) // update anchor path
                    {
                        mainSeq.Add((callBack) =>
                        {
                            if (anchor && anchor.gameObject.activeSelf)
                            {
                                anchor.UpdatePath();
                            }
                            WController.CheckResult(false, false);// check shoot result
                            callBack();
                        });
                    }

                    mainSeq.Add((callBack) =>
                    {
                        grid.MoveToVisible(() =>
                        {
                            if (WController.GameResult == GameResult.Win)
                            {
                                detCells = new CellsGroup();
                                detCells.AddRange(grid.GetNotEmptyCells());
                                detCells.FallDownCollect(BubblesShooter.Instance.BubbleScore, null);
                            }
                            WController.CheckResult(false, false);// check shoot result after falldown
                            GoToShootMode();
                            callBack();
                        });
                    });

                    mainSeq.Start();
                }
            }
        }