Ejemplo n.º 1
0
        public void OpenGridSettingsPanel_Click()
        {
            Debug.Log("open grid settings click");
            BubbleGrid grid = MBoard.grid;

            ScrollPanelController sRC = GridPanelContainer.ScrollPanel;

            if (sRC) //
            {
                if (sRC)
                {
                    sRC.CloseScrollPanel(true, null);
                }
            }
            else
            {
                CloseOpenedPanels();

                //instantiate ScrollRectController
                sRC = GridPanelContainer.InstantiateScrollPanel();
                sRC.textCaption.text = "Grid panel";

                //create  vert size block
                IncDecInputPanel.Create(sRC.scrollContent, IncDecGridPrefab, "VertSize", grid.Rows.Count.ToString(),
                                        () => { IncVertSize(); },
                                        () => { DecVertSize(); },
                                        (val) => {  },
                                        () => { return(grid.Rows.Count.ToString()); },
                                        null);

                //create hor size block
                IncDecInputPanel.Create(sRC.scrollContent, IncDecGridPrefab, "HorSize", LCSet.HorSize.ToString(),
                                        () => { IncHorSize(); },
                                        () => { DecHorSize(); },
                                        (val) => { },
                                        () => { return(LCSet.HorSize.ToString()); },
                                        null);

                //create background block
                IncDecInputPanel.Create(sRC.scrollContent, IncDecGridPrefab, "BackGrounds", LCSet.backGroundNumber.ToString(),
                                        () => { IncBackGround(); },
                                        () => { DecBackGround(); },
                                        (val) => { },
                                        () => { return(LCSet.backGroundNumber.ToString()); },
                                        null);
                sRC.OpenScrollPanel(null);
            }
        }
        public void OpenMainBrushPanel_Click()
        {
            Debug.Log("open main brush click");
            BubbleGrid        grid = GameBoard.Instance.grid;
            LevelConstructSet lcs  = GameBoard.Instance.gcSet.GetLevelConstructSet(BubblesPlayer.CurrentLevel);

            ScrollPanelController sRC = MainBrushContainer.ScrollPanel;

            if (sRC) //
            {
                sRC.CloseScrollPanel(true, null);
            }
            else
            {
                CloseOpenedPanels();
                //instantiate ScrollRectController
                sRC = MainBrushContainer.InstantiateScrollPanel();
                sRC.textCaption.text = "Main brush panel";

                List <BaseObjectData> mData = new List <BaseObjectData>();
                mData.Add(lcs.Matchset.Empty);
                if (lcs.Matchset.MainObjects != null)
                {
                    foreach (var item in lcs.Matchset.MainObjects)
                    {
                        mData.Add(item);
                    }
                }

                //create main bubbles brushes
                for (int i = 0; i < mData.Count; i++)
                {
                    BaseObjectData mD = mData[i];
                    CreateButton(smallButtonPrefab, sRC.scrollContent, mD.ObjectImage, () =>
                    {
                        Debug.Log("Click on Button <" + mD.ID + "...> ");
                        mainBrush             = (!GameObjectsSet.IsEmptyObject(mD.ID)) ? lcs.Matchset.GetMainObject(mD.ID) : lcs.Matchset.Empty;
                        mainBrushImage.sprite = mainBrush.ObjectImage;
                        SelectMainBrush();
                    });
                }
                sRC.OpenScrollPanel(null);
            }
        }
Ejemplo n.º 3
0
        public ScrollPanelController InstantiateScrollPanel()
        {
            if (!ScrollPanelPrefab)
            {
                return(null);
            }

            if (ScrollPanel)
            {
                DestroyImmediate(ScrollPanel.gameObject);
            }

            RectTransform panel = Instantiate(ScrollPanelPrefab).GetComponent <RectTransform>();

            panel.SetParent(GetComponent <RectTransform>());
            panel.anchoredPosition = new Vector2(0, 0);
            ScrollPanel            = panel.GetComponent <ScrollPanelController>();
            return(ScrollPanel);
        }
Ejemplo n.º 4
0
        public void OpenOverBrushPanel_Click()
        {
            Debug.Log("open over brush click");

            ScrollPanelController sRC = OverBrushContainer.ScrollPanel;

            if (sRC) //
            {
                sRC.CloseScrollPanel(true, null);
            }
            else
            {
                CloseOpenedPanels();
                //instantiate ScrollRectController
                sRC = OverBrushContainer.InstantiateScrollPanel();
                sRC.textCaption.text = "Over brush panel";

                List <BaseObjectData> mData = new List <BaseObjectData>();
                mData.Add(GOSet.Empty);
                if (GOSet.OverlayObjects != null)
                {
                    mData.AddRange(GOSet.OverlayObjects.GetBaseList());
                }

                //create over brushes
                for (int i = 0; i < mData.Count; i++)
                {
                    BaseObjectData mD = mData[i];
                    CreateButton(smallButtonPrefab, sRC.scrollContent, mD.ObjectImage, () =>
                    {
                        Debug.Log("Click on Button <" + mD.ID + "...> ");
                        overBrush             = (!GameObjectsSet.IsEmptyObject(mD.ID)) ? GOSet.GetOverlayObject(mD.ID) : GOSet.Empty;
                        overBrushImage.sprite = overBrush.ObjectImage;
                        SelectOverBrush();
                    });
                }
                sRC.OpenScrollPanel(null);
            }
        }
        //#region gift
        //public void OpenGiftPanel_Click()
        //{
        //    Debug.Log("open click");
        //    ScrollPanelController sRC = GiftPanelContainer.ScrollPanel;
        //    if (sRC) //
        //    {
        //        if (sRC) sRC.CloseScrollPanel(true, null);
        //    }
        //    else
        //    {
        //        //instantiate ScrollRectController
        //        sRC = GiftPanelContainer.InstantiateScrollPanel();
        //        sRC.textCaption.text = "Gift panel";

        //        LevelConstructSet lcSet = GameBoard.Instance.gcSet.GetLevelConstructSet(BubblesPlayer.CurrentLevel);
        //        GameConstructSet gcSet = GameBoard.Instance.gcSet;
        //        GiftConstruct levelGift = gcSet.gift;

        //        //create life gift
        //        IncDecInputPanel.Create(sRC.scrollContent, IncDecPanelPrefab, "Life", levelGift.Life.ToString(),
        //            () => { levelGift.AddLifes(1); },
        //            () => { levelGift.AddLifes(-1); },
        //            (val) => { int res; bool good = int.TryParse(val, out res); if (good) { levelGift.SetLifesCount(res); }},
        //            () => { return levelGift.Life.ToString(); },
        //            null);

        //        //create coins gift
        //        IncDecInputPanel.Create(sRC.scrollContent, IncDecPanelPrefab, "Coins", levelGift.Coins.ToString(),
        //        () => { levelGift.AddCoins(1); },
        //        () => { levelGift.AddCoins(-1); },
        //        (val) => { int res; bool good = int.TryParse(val, out res); if (good) { levelGift.SetCoinsCount(res); } },
        //        () => { return levelGift.Coins.ToString(); },
        //        null);

        //        //create booster gift
        //        GameObjectsSet goSet = lcSet.Matchset;
        //        IList<BoosterObjectData> bDataL = goSet.BoosterObjects;
        //        foreach (var item in bDataL)
        //        {
        //            int id = item.ID;
        //            IncDecInputPanel.Create(sRC.scrollContent, IncDecPanelPrefab, "Booster", levelGift.GetBoosterCount(id).ToString(),
        //            () => { levelGift.AddBooster(id); },
        //            () => { levelGift.RemoveBooster(id); },
        //            (val) => { int res; bool good = int.TryParse(val, out res); if (good) { levelGift.SetBoosterCount(res, id); } },
        //            () => { return levelGift.GetBoosterCount(id).ToString(); },
        //            item.GuiImage);
        //        }

        //        sRC.OpenScrollPanel(null);
        //    }
        //}
        //#endregion gift

        #region mission
        public void OpenMissionPanel_Click()
        {
            Debug.Log("open mission click");
            BubbleGrid grid = GameBoard.Instance.grid;

            ScrollPanelController sRC = MissionPanelContainer.ScrollPanel;

            if (sRC) //
            {
                sRC.CloseScrollPanel(true, null);
            }
            else
            {
                CloseOpenedPanels();
                //instantiate ScrollRectController
                sRC = MissionPanelContainer.InstantiateScrollPanel();
                sRC.textCaption.text = "Mission panel";

                LevelConstructSet lcSet        = GameBoard.Instance.gcSet.GetLevelConstructSet(BubblesPlayer.CurrentLevel);
                MissionConstruct  levelMission = lcSet.levelMission;

                //create mission moves constrain
                IncDecInputPanel.Create(sRC.scrollContent, IncDecPanelPrefab, "Moves", levelMission.MovesConstrain.ToString(),
                                        () => { levelMission.AddMoves(1); },
                                        () => { levelMission.AddMoves(-1); },
                                        (val) => { int res; bool good = int.TryParse(val, out res); if (good)
                                                   {
                                                       levelMission.SetMovesCount(res);
                                                   }
                                        },
                                        () => { return(levelMission.MovesConstrain.ToString()); },
                                        null);

                //create time constrain
                IncDecInputPanel.Create(sRC.scrollContent, IncDecPanelPrefab, "Time", levelMission.TimeConstrain.ToString(),
                                        () => { levelMission.AddTime(1); },
                                        () => { levelMission.AddTime(-1); },
                                        (val) => { int res; bool good = int.TryParse(val, out res); if (good)
                                                   {
                                                       levelMission.SetTime(res);
                                                   }
                                        },
                                        () => { return(levelMission.TimeConstrain.ToString()); },
                                        null);

                //description input field
                IncDecInputPanel.Create(sRC.scrollContent, InputTextPanelMissionPrefab, "Description", levelMission.Description,
                                        null,
                                        null,
                                        (val) => { levelMission.SetDescription(val); },
                                        () => { return(levelMission.Description); },
                                        null);

                // create clean top row check box condition
                IncDecInputPanel.Create(sRC.scrollContent, TogglePanelMissionPrefab, "Clean top row", null,
                                        levelMission.LoopTopRow,
                                        null,
                                        null,
                                        null,
                                        (val) => { levelMission.SetLoopTopRow(val); },
                                        null,
                                        null);

                // create raise anchor check box condition
                IncDecInputPanel.Create(sRC.scrollContent, TogglePanelMissionPrefab, "Raise anchor", null,
                                        levelMission.RaiseAnchor,
                                        null,
                                        null,
                                        null,
                                        (val) => { levelMission.SetRaiseAnchor(val); },
                                        null,
                                        null);


                //create object targets
                GameObjectsSet         goSet  = lcSet.Matchset;
                IList <BaseObjectData> tDataL = goSet.TargetObjects;
                foreach (var item in tDataL)
                {
                    if (item != null)
                    {
                        Debug.Log("target ID: " + item.ID);
                        int id = item.ID;
                        IncDecInputPanel.Create(sRC.scrollContent, IncDecTogglePanelMissionPrefab, "Target", levelMission.GetTargetCount(id).ToString(),
                                                levelMission.GetTargetCount(id) == 10000,
                                                () => { levelMission.AddTarget(id, 1); },
                                                () => { levelMission.RemoveTarget(id, 1); },
                                                (val) => { int res; bool good = int.TryParse(val, out res); if (good)
                                                           {
                                                               levelMission.SetTargetCount(id, res);
                                                           }
                                                },
                                                (val) => { if (val)
                                                           {
                                                               levelMission.SetTargetCount(id, 10000);
                                                           }
                                                           else
                                                           {
                                                               levelMission.SetTargetCount(id, 0);
                                                           } },
                                                () => { return(levelMission.GetTargetCount(id).ToString()); }, // grid.GetObjectsCountByID(id).ToString()); },
                                                item.GuiImage);
                    }
                }

                sRC.OpenScrollPanel(null);
            }
        }
        public void OpenGridSettingsPanel_Click()
        {
            Debug.Log("open grid settings click");
            BubbleGrid grid = GameBoard.Instance.grid;

            ScrollPanelController sRC = GridPanelContainer.ScrollPanel;

            if (sRC) //
            {
                if (sRC)
                {
                    sRC.CloseScrollPanel(true, null);
                }
            }
            else
            {
                CloseOpenedPanels();
                //instantiate ScrollRectController
                sRC = GridPanelContainer.InstantiateScrollPanel();
                sRC.textCaption.text = "Grid panel";

                LevelConstructSet lcSet        = GameBoard.Instance.gcSet.GetLevelConstructSet(BubblesPlayer.CurrentLevel);
                MissionConstruct  levelMission = lcSet.levelMission;

                //create  vert size block
                IncDecInputPanel.Create(sRC.scrollContent, IncDecGridPrefab, "VertSize", grid.Rows.Count.ToString(),
                                        () => { IncVertSize(); },
                                        () => { DecVertSize(); },
                                        (val) => {  },
                                        () => { return(grid.Rows.Count.ToString()); },
                                        null);

                //create hor size block
                IncDecInputPanel.Create(sRC.scrollContent, IncDecGridPrefab, "HorSize", lcSet.HorSize.ToString(),
                                        () => { IncHorSize(); },
                                        () => { DecHorSize(); },
                                        (val) => { },
                                        () => { return(lcSet.HorSize.ToString()); },
                                        null);

                //create background block
                IncDecInputPanel.Create(sRC.scrollContent, IncDecGridPrefab, "BackGrounds", lcSet.backGroundNumber.ToString(),
                                        () => { IncBackGround(); },
                                        () => { DecBackGround(); },
                                        (val) => { },
                                        () => { return(lcSet.backGroundNumber.ToString()); },
                                        null);

                //create game object set block
                GameObjectsSet ms      = lcSet.Matchset;
                int            indexMS = MatchSets.IndexOf(ms);
                IncDecInputPanel.Create(sRC.scrollContent, IncDecGridPrefab, "GameSets", ms.name.ToString(),
                                        () => { if (indexMS < 0 || MatchSets.Count < 1)
                                                {
                                                    return;
                                                }
                                                indexMS = (int)Mathf.Repeat(++indexMS, MatchSets.Count); lcSet.Matchset = MatchSets[indexMS]; ShowLevelData(); },
                                        () => { if (indexMS < 0 || MatchSets.Count < 1)
                                                {
                                                    return;
                                                }
                                                indexMS = (int)Mathf.Repeat(--indexMS, MatchSets.Count); lcSet.Matchset = MatchSets[indexMS]; ShowLevelData(); },
                                        (val) => { },
                                        () => { return(lcSet.Matchset.name.ToString()); },
                                        null);


                sRC.OpenScrollPanel(null);
            }
        }