public void saveDeck() { string[] cardClassNames = new string[listOfCards.Count]; BasicCardAttributes[] cardsAttributes= new BasicCardAttributes[listOfCards.Count]; Card c; int index = 0; foreach(CardDisplayController item in listOfCards) { c = item.getCardRepresented(); cardClassNames[index] = c.GetType().Name; //WARNING for now all enemy cards stay in decks when used if(!playerDeck) { c.basicAttrabutes.removeOnDraw = false; } cardsAttributes[index++] = c.basicAttrabutes; } JsonDeck deckSave = new JsonDeck(cardClassNames, cardsAttributes); SaveAndLoadJson.saveStruct(getDeckPath() + deckName.text, deckSave); }
private void saveSoundLevels() { SoundLevelsDiskSave savingFile = new SoundLevelsDiskSave(musicVolume, sfxVolume); SaveAndLoadJson.saveStruct(soundFilePath(), savingFile); }
void OnGUI() { card = (MonoScript)EditorGUILayout.ObjectField("card script", card, typeof(MonoScript), false); cardFilePath = GUILayout.TextField(cardFilePath); if (!cardFilePath.EndsWith("/")) { cardFilePath += "/"; } if (GUILayout.Button("set prefab location based on cardClass")) { cardFilePath = card.GetClass().Name + "/"; //default names cardAttrabutes.cardIconPath = cardFilePath + "icon"; cardAttrabutes.cardArtPath = cardFilePath + "card art"; cardAttrabutes.cardDescriptionPath = cardFilePath + "description"; cardAttrabutes.cardName = card.GetClass().Name; } //load existing card attributes TextAsset tempChangeCheck = existingCardAttr; existingCardAttr = (TextAsset)EditorGUILayout.ObjectField("CardAttr", existingCardAttr, typeof(TextAsset), false); if (GUILayout.Button("update Existing CardAttr") || tempChangeCheck != existingCardAttr) { if (existingCardAttr != null) { SaveAndLoadJson.loadStructFromString(out cardAttrabutes, existingCardAttr.text); string[] filePath = AssetDatabase.GetAssetPath(existingCardAttr).Split(new char[] { '/' }); int index = 0; while (index < filePath.Length) { if (filePath[index++] == "Resources") { break; } } cardFilePath = ""; for (int i = index; i < filePath.Length - 1; i++) { cardFilePath += filePath[i] + "/"; } } //default names cardAttrabutes.cardIconPath = cardFilePath + "icon"; cardAttrabutes.cardArtPath = cardFilePath + "card art"; cardAttrabutes.cardDescriptionPath = cardFilePath + "description"; } cardAttrabutes.cardName = EditorGUILayout.TextField("card displayed name", cardAttrabutes.cardName); cardAttrabutes.cardResorceCost = EditorGUILayout.FloatField("cost", cardAttrabutes.cardResorceCost); cardAttrabutes.cardReloadTime_seconds = EditorGUILayout.FloatField("slot reload time", cardAttrabutes.cardReloadTime_seconds); cardAttrabutes.removeOnDraw = EditorGUILayout.Toggle("removedOnDraw", cardAttrabutes.removeOnDraw); cardAttrabutes.probabilityOfDraw = EditorGUILayout.FloatField("draw probability", cardAttrabutes.probabilityOfDraw); cardAttrabutes.numberOfCardAllowedInDeck = EditorGUILayout.IntField("Numb Allowed In Deck", cardAttrabutes.numberOfCardAllowedInDeck); cardAttrabutes.cardElements = (DamageTypes)EditorGUILayout.EnumMaskPopup("setCardElements", cardAttrabutes.cardElements); cardAttrabutes.cardType = (CardLocation)EditorGUILayout.EnumMaskPopup("setCardType(s)", cardAttrabutes.cardType); GUILayout.Label("icon,card art, and card description (.txt)\nmust be added to the created folder"); GUIStyle colorset = new GUIStyle(GUI.skin.button); if (timeLeftOnScreen_sec > 0) { colorset.normal.textColor = new Color(0f, 0.4f, 0f); timeLeftOnScreen_sec -= Time.deltaTime; } else { colorset.normal.textColor = Color.black; } if (GUILayout.Button("create card information", colorset) && cardFilePath != "/") { if (!Directory.Exists(SaveAndLoadJson.getResourcePath(cardFilePath))) { Directory.CreateDirectory(SaveAndLoadJson.getResourcePath(cardFilePath)); } //string printer = ""; //SaveAndLoadJson.saveStructToString(cardAttrabutes,out printer); if (SaveAndLoadJson.saveStruct(SaveAndLoadJson.getResourcePath(cardFilePath + "CardAttr"), cardAttrabutes)) { timeLeftOnScreen_sec = timeOnScreenMax_sec; } AssetDatabase.Refresh(); } }