public static DeckAsset CreateDeck(string name) { DeckAsset asset = ScriptableObject.CreateInstance <DeckAsset>(); AssetDatabase.CreateAsset(asset, AssetDatabase.GenerateUniqueAssetPath("Assets/Resources/Decks/" + name + ".asset")); AssetDatabase.SaveAssets(); return(asset); }
void OpenDeck() { string absPath = EditorUtility.OpenFilePanel("Select Deck Asset", "", ""); if (absPath.StartsWith(Application.dataPath)) { string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length); DeckAsset deckAsset = AssetDatabase.LoadAssetAtPath(relPath, typeof(DeckAsset)) as DeckAsset; viewIndex = deckAssetList.IndexOf(deckAsset) + 1; } }
void CreateNewDeck() { viewIndex = 1; DeckAsset newDeckAsset = CreateCardAssets.CreateDeck("NewDeck"); if (newDeckAsset) { newDeckAsset.cardList = new List <CardAsset>(); newDeckAsset.quantityList = new List <int>(); deckAssetList.Add(newDeckAsset); viewIndex = deckAssetList.Count; } }
public void Initialize(DeckAsset refAsset) { asset = refAsset; deck.Clear(); for (int i = 0; i < refAsset.cardList.Count; i++) { string code = refAsset.cardList[i].code; if (!cardAssetMap.ContainsKey(code)) { cardAssetMap[code] = refAsset.cardList[i]; quantityMap[code] = refAsset.quantityList[i]; for (int j = 0; j < quantityMap[code]; j++) { deck.Add(code); } } } Shuffle(); //Debug.Log("Cards total: " + (deck.Count).ToString()); }