コード例 #1
0
        public void OnGUI()
        {
            GUILayout.BeginVertical();

            DrawToggleShowButton();

            if (_isShow)
            {
                DrawInputParameters();
                if (GUILayout.Button("Complete all  levels"))
                {
                    for (int i = 1; i < GameObject.Find("Levels").transform.childCount; i++)
                    {
                        // LevelsMap.CompleteLevel(i, _starsCount);
                        SaveLevelStarsCount(i, _starsCount);
                    }
                }

                if (GUILayout.Button("Complete level"))
                {
                    if (LevelsMap.IsStarsEnabled())
                    {
                        LevelsMap.CompleteLevel(_levelNumber, _starsCount);
                    }
                    else
                    {
                        LevelsMap.CompleteLevel(_levelNumber);
                    }
                }

                if (GUILayout.Button("Go to level"))
                {
                    LevelsMap.GoToLevel(_levelNumber);
                }

                if (GUILayout.Button("Is level locked"))
                {
                    bool isLocked = LevelsMap.IsLevelLocked(_levelNumber);
                    Debug.Log(string.Format("Level {0} is {1}",
                                            _levelNumber,
                                            isLocked ? "locked" : "not locked"));
                }

                if (GUILayout.Button("Clear all progress"))
                {
                    LevelsMap.ClearAllProgress();
                }
            }

            GUILayout.EndVertical();
        }
コード例 #2
0
        private void DrawInputParameters()
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label("Level number:");
            string strLevelNumber = GUILayout.TextField(_levelNumber.ToString(), 10, GUILayout.Width(80));

            int.TryParse(strLevelNumber, out _levelNumber);

            if (LevelsMap.IsStarsEnabled())
            {
                GUILayout.Label("Stars count:");
                string strStarsCount = GUILayout.TextField(_starsCount.ToString(), 10, GUILayout.Width(80));
                int.TryParse(strStarsCount, out _starsCount);
            }

            GUILayout.EndHorizontal();
        }