private void OnDestroy()
 {
     BubblesPlayer.Destroy();
     if (mainSeq != null)
     {
         mainSeq.Break();
     }
 }
Exemple #2
0
 private void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
 void Awake()
 {
     if (Instance)
     {
         Destroy(gameObject);
     }
     else
     {
         Instance = this;
     }
     BubblesPlayer.Destroy(); // need to reload player data
     if (gcSet && LcSet && GameObjSet)
     {
         BubblesPlayer.Instance.CreateBoosterHolder(GameObjSet);                               // create boosters for current  bevore start all objects -
     }
 }
        private BubblesPlayer()
        {
            instance       = this;
            TopPassedLevel = -1; // none passed

            Coins = defCoinsCount;
            Life  = defLifesCount;

            levelsStars = new List <int>();
            levelScores = new List <int>();

            // load saved data
            if (SaveData)
            {
                string key = saveCoinsKey;
                if (PlayerPrefs.HasKey(key))
                {
                    Coins = PlayerPrefs.GetInt(key);
                }

                key = saveLifeKey;
                if (PlayerPrefs.HasKey(key))
                {
                    Life = PlayerPrefs.GetInt(key);
                }

                key = saveTopPassedLevelKey;
                if (PlayerPrefs.HasKey(key))
                {
                    TopPassedLevel = PlayerPrefs.GetInt(key);
                }

                levelScores = GetPassedLevelsScores();
                levelsStars = GetPassedLevelsStars();
            }
            //  CurrentLevel = Mathf.Max(0, TopPassedLevel);
            Debug.Log("CurrentLevel: " + CurrentLevel);
        }
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            #region test
            if (EditorApplication.isPlaying)
            {
                if (test = EditorGUILayout.Foldout(test, "Test"))
                {
                    BubblesPlayer t = (BubblesPlayer)target;

                    #region coins
                    EditorGUILayout.BeginHorizontal("box");
                    if (GUILayout.Button("Add 500 coins"))
                    {
                        t?.AddCoins(500);
                    }

                    if (GUILayout.Button("Clear coins"))
                    {
                        t?.SetCoinsCount(0);
                    }

                    if (GUILayout.Button("Add coins -500"))
                    {
                        t.AddCoins(-500);
                    }
                    EditorGUILayout.EndHorizontal();
                    #endregion coins

                    #region scenes
                    EditorGUILayout.BeginHorizontal("box");
                    if (GUILayout.Button("Scene 0"))
                    {
                        SceneLoader.Instance?.LoadScene(0);
                    }
                    if (GUILayout.Button("Scene 1"))
                    {
                        SceneLoader.Instance?.LoadScene(1);
                    }
                    EditorGUILayout.EndHorizontal();
                    #endregion scenes

                    #region stars
                    EditorGUILayout.BeginHorizontal("box");
                    if (GUILayout.Button("Inc stars"))
                    {
                        t?.AddStars(1);
                    }

                    if (GUILayout.Button("Dec stars"))
                    {
                        t?.AddStars(-1);
                    }
                    EditorGUILayout.EndHorizontal();
                    #endregion stars

                    #region life
                    EditorGUILayout.BeginHorizontal("box");
                    if (GUILayout.Button("Inc life"))
                    {
                        t.AddLifes(1);
                    }

                    if (GUILayout.Button("Dec life"))
                    {
                        t.AddLifes(-1);
                    }

                    if (GUILayout.Button("Clean infinite life"))
                    {
                        t.CleanInfiniteLife();
                    }
                    EditorGUILayout.EndHorizontal();
                    #endregion life

                    #region score
                    EditorGUILayout.BeginHorizontal("box");

                    if (GUILayout.Button("Add score 200"))
                    {
                        t.AddScore(200);
                    }

                    EditorGUILayout.EndHorizontal();
                    #endregion score

                    if (GUILayout.Button("Reset to default"))
                    {
                        t.SetDefaultData();
                    }
                }
            }
            else
            {
                EditorGUILayout.LabelField("Goto play mode for test");
            }
            #endregion test
        }
 internal static void Destroy()
 {
     instance = null;
     GC.Collect();
 }