Help with XML design.
-
Hello everyone! Okay. I have a game, and it has weapons. I have code like this:
abstract class Weapon { int power; } class W_Handgun : Weapon { public W_Handgun() { power = 40; } }
Well, there will be many different types of weapons. So I'd like to save all of the different types in an XML file instead of hard-coding them. My question is, how do I do that? I know how to read XML files, but how do I convert something like
<Handgun><Power>40</Power></Handgun>
to the above mentioned class? I'm lost. (And excuse the smiley.) Thanks in advance!Windows Calculator told me I will die at 28. :(
-
Hello everyone! Okay. I have a game, and it has weapons. I have code like this:
abstract class Weapon { int power; } class W_Handgun : Weapon { public W_Handgun() { power = 40; } }
Well, there will be many different types of weapons. So I'd like to save all of the different types in an XML file instead of hard-coding them. My question is, how do I do that? I know how to read XML files, but how do I convert something like
<Handgun><Power>40</Power></Handgun>
to the above mentioned class? I'm lost. (And excuse the smiley.) Thanks in advance!Windows Calculator told me I will die at 28. :(
Look into XML serialization.
-
Look into XML serialization.
Oh, so that's how it's done. I won't use this method because it's an online game, and it'll be easy for people to hack it. But thanks!
Windows Calculator told me I will die at 28. :(
-
Oh, so that's how it's done. I won't use this method because it's an online game, and it'll be easy for people to hack it. But thanks!
Windows Calculator told me I will die at 28. :(
At least I hope you won't die at 28 :)
-
At least I hope you won't die at 28 :)
Trust me, I do too.:laugh:
Windows Calculator told me I will die at 28. :(