/// <summary> /// Activates the back button bringing the user back to the menu position /// prior to their current one. /// Removes the new position from the stack as well. /// </summary> void ActivateBackButton() { var tempLastMenuPos = backButtonStorage.Peek(); backButtonStorage.Pop(); currentMenuPos = (MenuPositions)tempLastMenuPos; }
//Creates a new level (prefab) in a pre-existing level list. //It needs to grab the directory of the desired level list. (foreach item in the level_list_folder_directory, load them buttons. One will need to be selected in order to continue) //Grab the proper levelist scriptable object //Incrememnt the size of the array. //Store the new level in the newly added index. void ShowLevelLists(string labelMessage) { var levelListPathArray = Directory.GetFiles(LEVEL_LIST_FOLDER_DIRECTORY_OUTSIDE, "*.asset"); GUIStyle myStyle = new GUIStyle(); myStyle.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField(labelMessage, myStyle); // "item" refers to the path of the object grabbed from the levelListPathArray. foreach (var item in levelListPathArray) { // This section is used to parse the path stored in "item" for thr actual level list name. string listName = item; listName = ParseString(listName); // After parsing the path for the level list name, buttons // are then created for each level list. if (GUILayout.Button(listName)) { // Store the path of the selected level list. pathOfSelectedLevelList = item; // Store the actual name of the selected list. nameOfSelectedList = listName; backButtonStorage.Push(currentMenuPos); if (currentMenuPos == MenuPositions.selectingListForNewLevel) { // If the user is creating a new level list, then the next step from // there is to actually create the level. Move to thatmenu position. currentMenuPos = MenuPositions.creatingNewLevel; } else { // The only other route that the user can take that requires // showing the level lists is "Edit a Pre-existing Level". // If the user isn't creating a new level, then they must be tring to // edit one, so move to that menu position. currentMenuPos = MenuPositions.selectingLevelToEdit; } } } }
/// <summary> /// Shows the start menu options. /// </summary> void ShowStartMenuOptions() { if (GUILayout.Button("Create New Level List")) { backButtonStorage.Push(currentMenuPos); currentMenuPos = MenuPositions.creatingNewLevelList; } if (GUILayout.Button("Create New Level")) { backButtonStorage.Push(currentMenuPos); currentMenuPos = MenuPositions.selectingListForNewLevel; } if (GUILayout.Button("Edit a Pre-existing Level")) { backButtonStorage.Push(currentMenuPos); currentMenuPos = MenuPositions.selectingListToEdit; } }
//Creates a new level (prefab) in a pre-existing level list. //It needs to grab the directory of the desired level list. (foreach item in the level_list_folder_directory, load them buttons. One will need to be selected in order to continue) //Grab the proper levelist scriptable object //Incrememnt the size of the array. //Store the new level in the newly added index. void ShowLevels(string labelMessage) { // Reference to the new level list. // Used to store a reference to the List we will be adding to. LevelList selectedList = AssetDatabase.LoadAssetAtPath(pathOfSelectedLevelList, typeof(LevelList)) as LevelList; // Grab a reference the the list of levels stored in the selected level list. List <LevelData> levelList = selectedList.Levels; GUIStyle myStyle = new GUIStyle(); myStyle.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField(labelMessage, myStyle); foreach (LevelData level in levelList) { if (GUILayout.Button(level.name)) { CheckForLevelController(); currentLevelBeingEdited = level; currentPrefabBeingEdited = currentLevelBeingEdited.Prefab; controller.GetComponent <LevelController> ().CurrentLevel = currentLevelBeingEdited; if (EditorUtility.DisplayDialog("Current Level Swapped", string.Format("The Level Controller's Current Level has been changed to \"{0}\"!", level.name), "Ok")) { var previousLevelFabs = GameObject.FindGameObjectsWithTag(LEVEL_FAB_TAG); foreach (GameObject fab in previousLevelFabs) { DestroyImmediate(fab, false); } // Allows for the creation of an instance of the curent l prefab assigned to the level. levelPrefabInstance = PrefabUtility.InstantiatePrefab(level.Prefab) as GameObject; currentMenuPos = MenuPositions.editingLevel; break; } } } }
/// <summary> /// Returns the user to the start menu. /// </summary> void ActivateHomeButton() { currentMenuPos = MenuPositions.start; backButtonStorage.Clear(); }
public void ChangeToAcornsFromShop() { positions = MenuPositions.ShopMenu; }
public void ChangeToStartFromShop() { positions = MenuPositions.StartMenu; }
public void ChangeToShopFromAcorns() { positions = MenuPositions.AcornsMenu; }
public void ChangeToShopFromStartmenu() { positions = MenuPositions.ShopMenu; }
// Use this for initialization void Start() { positions = MenuPositions.StartMenu; }