Exemplo n.º 1
0
	/// <summary>
	/// get the deck path
	/// enemy decks are stored in the resource folder so they are added to build
	/// </summary>
	/// <returns></returns>
	private string getDeckPath() {
		if(playerDeck) {
			return SaveAndLoadJson.getBaseFilePath(Deck.playerDecks);
		} else {
			return SaveAndLoadJson.getResourcePath(Deck.baddyDecks,"");
		}
	}
Exemplo n.º 2
0
    private bool loadDeckFromMemory(string deckName)
    {
        JsonDeck deck;
        bool     loadSuccess = false;

        if (playerDeck)
        {
            loadSuccess = SaveAndLoadJson.loadStruct(SaveAndLoadJson.getBaseFilePath(playerDecks, deckName), out deck);
        }
        else
        {
            loadSuccess = SaveAndLoadJson.loadStruct(SaveAndLoadJson.getResourcePath(baddyDecks, deckName), out deck);
        }
        if (!loadSuccess)
        {
            if (!SaveAndLoadJson.loadStruct(SaveAndLoadJson.getResourcePath(baddyDecks, "errorDeck"), out deck))
            {
                return(false);
            }
        }
        //get card class types from names
        Type[] cardClasses = new Type[deck.cardTypeName.Length];
        for (int i = 0; i < deck.cardTypeName.Length; i++)
        {
            cardClasses[i] = Type.GetType(deck.cardTypeName[i]);
        }

        addCardsToDeck(cardClasses);


        return(loadSuccess);
    }
Exemplo n.º 3
0
 //TODO abstract which type is loaded at start
 public void loadDeckType(Toggle deckType)
 {
     if (deckType.isOn)
     {
         loadDeckFolder(SaveAndLoadJson.getBaseFilePath(Deck.playerDecks));
     }
     else
     {
         loadDeckFolder(SaveAndLoadJson.getResourcePath(Deck.baddyDecks));
     }
 }
Exemplo n.º 4
0
    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();
        }
    }