|Implementing Crusader Kings 2 style diplomacy||Locked|
|Mar 17 2013 Anchor|
(I am using Unity, so Unity specific advice would be great, but I'll take any advice I can get really - and yes, I already asked the same question on Unity forums)
I've been thinking about this one for a while and I'm not sure how to go about it. I want to have a game where diplomacy is handled the way it is implemented in Paradox's Crusader Kings 2, where you have a whole bunch of characters and every character has an opinion score about every other character, ranging from -100 to 100. This score needs to be dynamic as certain events in the game can change a character's opinion about another at any time. So I will probably need to use an array or some other data structure attached to every character object to store the data. I need a unique identifier in this structure for every character so that I can update the opinion score based on game events. I also need to be able to add and remove entries when new characters are instantiated or removed from the game.
How would you go about implementing this in code? What data structure would be best suited to this when using UnityScript or C#? A dictionary? Array? Array list? Database table? Any pointers would be appreciated.
|Apr 10 2013 Anchor|
Well a good place to start looking is XML. These can be easily implemented in both the languages you mentioned, you could then simply setup the structure within that XML document for each character as well as any of it's other attributes.
You can then read and change each of their nodes and if the character is removed from the game then you can just remove the node completely.
|Apr 10 2013 Anchor|
Thanks for the reply. I was also thinking of temporary buffs that wear out over time, like a bonus 20 points that goes down by 1 every second. XML would be written on hdd, no? Would it not cause a performance issue if there are too many updates called on that one xml file while processing such time based effects?
|Apr 12 2013 Anchor|
If you were to add more things like buffs then you'd simply add more nodes to the XML file to hold each of the different buffs. Your correct in saying that you would need to write to the HDD but it would be done in practically the blink of an eye and it should be able to handle many updates without a problem.
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.