Example #1
0
    public void SuggestionAds()
    {
        StagesAsset datas = DataManager.StagesAsset;

        //Suggestion unlock by Star
        nextButton.onClick.RemoveAllListeners();

        var nextStage = datas.GetNext(UnlockType.Star, datas.Current.index, userData.totalStar);

        if (nextStage != null)
        {
            nextStage.isUnlocked = true;
            nextStage.unlockBy   = UnlockType.Star;
            DataManager.Save();

            nextButton.gameObject.SetActive(true);
            nextButton.onClick.AddListener(() => {
                DataManager.CurrentStage = nextStage;
                GameStateManager.Next(null);
                Hide(() =>
                {
                });
            });
        }
    }
    public override void OnInspectorGUI()
    {
        StagesAsset myScript = (StagesAsset)target;

        if (GUILayout.Button("Order by Index"))
        {
            myScript.OderByIndex();
        }
        if (GUILayout.Button("Add 100 Levels"))
        {
            myScript.AddLevel(100);
        }

        if (GUILayout.Button("Update Index"))
        {
            myScript.UpdateIndex();
        }

        if (GUILayout.Button("Update Cost"))
        {
            myScript.UpdateIndex();
            myScript.OderByIndex();

            for (int i = 0; i < myScript.list.Count; i++)
            {
                //if (i < 3)
                myScript.list[i].unlockType = UnlockType.Star;
                //else if (i % 3 == 2)
                //    myScript.list[i].unlockType = UnlockType.Star;
                //else if (i % 3 == 1)
                //    myScript.list[i].unlockType = UnlockType.Ads;
                //else
                //    myScript.list[i].unlockType = UnlockType.Gold;
                myScript.list[i].unlockBy = UnlockType.None;
            }

            myScript.UpdateCost();
            AssetDatabase.SaveAssets();
        }


        DrawDefaultInspector();

        if (GUILayout.Button("Update Id by Name"))
        {
            if (EditorUtility.DisplayDialog(
                    "Update Id by Name",
                    "Do you want update id by name!?",
                    "Update",
                    "Cancel"))
            {
                myScript.UpdateIdByName();
            }
        }

        if (GUILayout.Button("Reset Data"))
        {
            myScript.ResetData();
            AssetDatabase.SaveAssets();
        }
    }