/// <summary> /// add multiple cards to the deck (faster than adding each individually) /// </summary> /// <param name="cardType"></param> public void addCardsToDeck(System.Type[] cardType) { BasicCardAttributes[] baseAttributes = new BasicCardAttributes[cardType.Length]; for (int i = 0; i < cardType.Length; i++) { if (!CardAttributeLoader.LoadBasicCardAttributesFromJsonInResorceFolder(cardType[i].Name, out baseAttributes[i])) { //load the error handling card Debug.LogWarning("no card attribute file found for " + cardType[i].Name); CardAttributeLoader.LoadBasicCardAttributesFromJsonInResorceFolder("_Basic", out baseAttributes[i]); } } addCardsToDeck(cardType, baseAttributes); }
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); }
public CardtypesAndProbabilities(System.Type cardType, BasicCardAttributes atr) { this.cardType = cardType; cardAttributes = atr; }
//TODO change this to use assent bundles at some point /// <summary> /// load the text Assent CardAttr /// </summary> /// <param name="cardName"></param> /// <param name="cardAttr"></param> /// <returns></returns> public static bool LoadBasicCardAttributesFromJsonInResorceFolder(string cardName, out BasicCardAttributes cardAttr) { cardAttr = default(BasicCardAttributes); TextAsset cardAttrJson = PrefabResorceLoader.Instance.loadTextAsset(cardName + "/CardAttr"); //Note: resorce.load does not need file extension bool loaded = false; if (cardAttrJson != null) { loaded = SaveAndLoadJson.loadStructFromString(out cardAttr, cardAttrJson.text); } if (!loaded) { if (Application.isEditor) { //TODO create CardPramSetter Debug.Log("Card attributes not set" + cardName + "\n" + "create using editor using CardPramSetter"); } else { Debug.LogError("something has gone wrong, there are no card Attributes in " + cardName); } } return(loaded); }
/// <summary> /// helper to load vars from json more easily /// </summary> /// <param name="vars"></param> public void loadVars(BasicCardAttributes vars) { this = vars; }
private void Awake() { cardAttrabutes = default(BasicCardAttributes); cardAttrabutes.probabilityOfDraw = 1f; }