Beispiel #1
0
    void OnLevelWasLoaded()
    {
        if (IsCanUse)
        {
            if (Application.loadedLevelName != defaultLevel)
            {
                trackChunkManager           = TrackChunkManager.GetInstance();
                currentLevelConfiguration   = LevelConfiguration.Instance;
                PrefabInitializationManager = FindObjectOfType <PrefabInitializationManager>();



                if (PrefabInitializationManager != null)
                {
                    foreach (PrefabItem prefabItem in PrefabInitializationManager.PrefabItems)
                    {
                        if (prefabItem.prefab.GetComponent <AbstractPoolableObject>() != null)
                        {
                            Pool.InstantiateAndAdd(
                                prefabItem.prefab.GetComponent <AbstractPoolableObject>(),
                                prefabItem.count);
                        }
                    }
                }


                if (Controller.GetInstance() != null)
                {
                    TrackAbstract.GetInstance().CalculateTrackState(currentLevelConfiguration.DefaultPosition);
                    Controller.GetInstance().MoveToPosition(currentLevelConfiguration.DefaultPosition);
                    trackChunkManager.Initialize(currentLevelConfiguration.DefaultPosition);


                    CollectionInitializedEvent(info.bonuses);
                }
            }
            else
            {
                Pool = new Pool <AbstractPoolableObject>();
                trackChunkManager           = null;
                currentLevelConfiguration   = null;
                PrefabInitializationManager = null;
            }
        }
    }
Beispiel #2
0
    void OnGUI()
    {
        scroll = GUILayout.BeginScrollView(scroll);

        GUILayout.BeginHorizontal();
        GUILayout.Toggle(IsSerialized, "Level is saved");

        if (IsSerialized)
        {
            EditorGUILayout.BeginVertical();
            if (GUILayout.Button("Restore level"))
            {
                IsSerialized = false;
                TrackChunkManager.GetInstance().DeserializeFromChunks();
                TrackChunkManager.GetInstance().PutAllPoolablesToBlocks();
                if (GameManager.Instance.PrefabInitializationManager)
                {
                    GameManager.Instance.PrefabInitializationManager.Reset();
                }
                LevelConfiguration.Instance.IsSerializedLevel = false;
            }

            EditorGUILayout.EndVertical();
        }
        else
        {
            if (GUILayout.Button("Save level"))
            {
                IsSerialized = true;
                TrackChunkManager.GetInstance().GenerateChunks();
                TrackChunkManager.GetInstance().DestroyAllBlocks();
                PrefabInitializationManager prefabManager = FindObjectOfType <PrefabInitializationManager>();
                if (prefabManager)
                {
                    prefabManager.Caluculate(TrackChunkManager.GetInstance());
                }
                LevelConfiguration.Instance.IsSerializedLevel = true;
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.EndScrollView();
    }
 public void CalculateForContextMenu()
 {
     Caluculate(TrackChunkManager.GetInstance());
 }