Example #1
0
        public string levelName;  //this is assigned by scroll list which creates the level buttons


        void Awake()
        {
            if (instance == null)
            {
                instance = this;
            }
        }
Example #2
0
        void ShapeTracking()
        {
            //we check how many skins are unlocked before loading all the buttons
            for (int i = 0; i < GameManager.instance.skinUnlocked.Length; i++)
            {
                skins[i].unLock = GameManager.instance.skinUnlocked[i];
            }

            //handle the requirement for each shapes
            foreach (Shapes i in skins)
            {

                GameObject btn = Instantiate(refButton);//here we get ref to the instanciated button

                SampleButton samBtn = btn.GetComponent<SampleButton>();//ref to the script of button

                samBtn.shapeButton = true;
                samBtn.skinIndex = i.skinIndex;     //here we set index to keep track which skin is selected
                samBtn.cost = i.skinCost;      //here we set the cost of skin
                samBtn.shapeSkin.sprite = i.skinSprite;       //here we set the skin image of button
                //if skin is unlocked we do following
                if (i.unLock == true)
                {
                    //deactivate the lock image
                    samBtn.lockImg.SetActive(false);
                }
                //if not we do following
                else
                {
                    //activate the lock image
                    samBtn.lockImg.SetActive(true);
                }

                if (i.skinIndex == GameManager.instance.selectedSkin)
                {
                    samBtn.unselectImg.SetActive(false);
                }
                else
                {
                    samBtn.unselectImg.SetActive(true);
                }

                samBtn.button.onClick = i.thingToDo;
                samBtn.button.interactable = true;
                btn.transform.SetParent(shapeScrollPanel);
                //we set the scale of button fo by default they dot become too large or too small
                btn.transform.localScale = new Vector3(1f, 1f, 1f);

            }
        }
Example #3
0
        // Use this for initialization
        void Start()
        {
            //to hide banner ads in the level select scene
            //bannerView.Hide()

            LevelSolved();

            //the methode called when we click home button
            homeBtn.GetComponent<Button>().onClick.AddListener(() => { HomeButton(); });

            /// <summary>
            /// we check how many levels are unlocked and how many stars are achieved
            /// before loading all the buttons
            /// </summary>
            for (int i = 0; i < GameManager.instance.levels.Length; i++)
            {
                levels[i].unLock = GameManager.instance.levels[i];
                levels[i].starAchieved = GameManager.instance.starAchieved[i];
            }

            //handle the requirement for each level as per the list
            foreach (LevelItems i in levels)
            {

                GameObject btn = Instantiate(refButton);//here we get ref to the instanciated button

                SampleButton samBtn = btn.GetComponent<SampleButton>();//ref to the script of button

                samBtn.levelIndex = i.levelIndex; //here we set index to keep track whihc level is on
                samBtn.levelNum.text = i.levelNum;//here we set the number of level button
                samBtn.levelName = i.levelName; //here we set the name os scene which to be loaded

                //if level is unlocked we do following
                if (i.unLock == true)
                {
                    samBtn.lockObj.gameObject.SetActive(false);
                    samBtn.levelNum.color = Color.black;
                    for (int j = 0; j < i.starAchieved; j++)
                    {
                        samBtn.stars[j].color = new Color32(255, 211, 43, 255);
                    }

                    samBtn.button.interactable = true;
                }
                //if not we do following
                else
                {
                    samBtn.lockObj.gameObject.SetActive(true);

                    samBtn.button.interactable = false;
                }


                samBtn.button.onClick = i.thingToDo;

                btn.transform.SetParent(scrollPanel);
                //we set the scale of button fo by default they dot become too large or too small
                btn.transform.localScale = new Vector3(1f, 1f, 1f);

            }

        }