0

I am making a card game right now and I have learned some strategy from execute c# code at runtime from code file and Is it possible to dynamically compile and execute C# code fragments? about how to implement the card effects.

Since I am using unity, and I know that there is a kind of script called ScriptableObject, which will take less space than normal script. Can I store the card effect implementation through ScriptableObject as well? I am already using it to store some basic card attributes like name and description. But I don't think it is good to use it to store card effect implementation. Is there a space-saving way to store it? Or I have to create a normal script?

enter image description hereenter image description here

And any advice on how to implement the card effects will be appreciated since I only have a rough sense of how to do that.

Seaky Lone
  • 992
  • 1
  • 10
  • 29
  • are you talking about data saving or rendering of the effect? – David Apr 12 '18 at 05:39
  • @David The former. For instance, how to implement the card effect in the description part in the photo. Right now I am thinking I should write a trigger class and then each card effects will inherit from that. So my problem is to find a good way to put the card effect implementation functions. Should I just use the normal script or there is a more efficient way to do that? – Seaky Lone Apr 12 '18 at 06:58
  • What exactly is a *card effect implementation*? If it's just code then space will not be an issue here. – Lece Apr 12 '18 at 09:04
  • @Lece Please look at the description of fat soldier card. My question is like how I implement that? How do I store that implementation? – Seaky Lone Apr 12 '18 at 14:01
  • @Lece It will be a script of class, like you said just code, as far as I am concerned. Because I know scriptobject seems better, I am wondering whether there is a better way to store code. – Seaky Lone Apr 12 '18 at 17:38
  • You can either write vanilla C# classes, initialise and call into them as required, write components (Monobehaviours) and attach them to your GameObject or create ScriptableObject assets and drag them into the Inspector. In this context there's little difference between the three other than how you create and use them. – Lece Apr 12 '18 at 21:47

1 Answers1

0

To save info:

PlayerPrefs.SetInt("HeartCounts", 3);
PlayerPrefs.SetString("Description", "Some words");

To restore:

int n = PlayerPrefs.GetInt("HeartCounts", 0);
var desc= PlayerPrefs.GetString("Description", "Some words");
David
  • 15,894
  • 22
  • 55
  • 66