Exemplo 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);
            }
        }
        //#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);
            }
        }
Exemplo n.º 4
0
        public static IncDecInputPanel Create(RectTransform parent, IncDecInputPanel prefab, string text, string inputFielText, bool toggleOn, UnityAction incDelegate, UnityAction decDelegate, UnityAction <string> inputChangedDelegate, UnityAction <bool> toogleChange, Func <string> refreshDelegate, Sprite image)
        {
            if (!prefab)
            {
                return(null);
            }
            IncDecInputPanel panel = Instantiate(prefab).GetComponent <IncDecInputPanel>();

            if (!panel)
            {
                return(null);
            }
            if (parent)
            {
                panel.GetComponent <RectTransform>().SetParent(parent);
            }
            if (panel.textField)
            {
                panel.textField.text = text;
            }

            if (panel.inputField)
            {
                panel.inputField.text = inputFielText;
                panel.inputField.onValueChanged.AddListener(inputChangedDelegate);
                panel.inputField.onValueChanged.AddListener((val) => { if (refreshDelegate != null)
                                                                       {
                                                                           panel.inputField.text = refreshDelegate();
                                                                       }
                                                            });
            }

            if (panel.incButton)
            {
                if (incDelegate != null)
                {
                    panel.incButton.onClick.RemoveAllListeners();
                    panel.incButton.onClick.AddListener(incDelegate);
                    panel.incButton.onClick.AddListener(() => { if (refreshDelegate != null)
                                                                {
                                                                    panel.inputField.text = refreshDelegate();
                                                                }
                                                        });
                }
                else
                {
                    panel.incButton.gameObject.SetActive(false);
                }
            }

            if (panel.decButton)
            {
                if (decDelegate != null)
                {
                    panel.decButton.onClick.RemoveAllListeners();
                    panel.decButton.onClick.AddListener(decDelegate);
                    panel.decButton.onClick.AddListener(() => { if (refreshDelegate != null)
                                                                {
                                                                    panel.inputField.text = refreshDelegate();
                                                                }
                                                        });
                }
                else
                {
                    panel.decButton.gameObject.SetActive(false);
                }
            }

            if (panel.image)
            {
                panel.image.enabled = image;
                panel.image.sprite  = image;
            }
            if (panel.toggle)
            {
                panel.toggle.isOn = toggleOn;
                if (toogleChange != null)
                {
                    panel.toggle.onValueChanged.RemoveAllListeners();
                    panel.toggle.onValueChanged.AddListener(toogleChange);
                    panel.toggle.onValueChanged.AddListener((val) => { if (refreshDelegate != null)
                                                                       {
                                                                           panel.inputField.text = refreshDelegate();
                                                                       }
                                                            });
                }
                else
                {
                    panel.toggle.gameObject.SetActive(false);
                }
            }
            return(panel);
        }
Exemplo n.º 5
0
 public static IncDecInputPanel Create(RectTransform parent, IncDecInputPanel prefab, string text, string inputFielText, UnityAction <string> inputChangedDelegate, Func <string> refreshDelegate, Sprite image)
 {
     return(Create(parent, prefab, text, inputFielText, null, null, inputChangedDelegate, refreshDelegate, image));
 }