c# - How to Track Experience Points / data files -


i still pretty new @ c# , continue 'practice' i've been prototyping various things.

i working on console based rpg, without aid of c# development tool such unity.

i learning go have hit wall when comes tracking data.

i need able store experience points somewhere read/updated player character gains experience.

i use global variable of sorts, items have read c# , global variables, frowned upon ala: how declare variable global use

it can done using static class again not recommended: global variables in c#.net

public static class myglobals {     public const string prefix = "id_"; // cannot change     public static int total = 5; // can change because not const } 

i know can via streamreader feel easy things out of sorts: how save variables new text file variables loaded next time program runs?

i feel if used method load in changing variable, if added variable needed track: level, money, etc.

textwriter tw = new streamwriter("playerstats.txt");  // write lines of text file tw.writeline(playerlevel); tw.writeline(playerexperience);  // close stream      tw.close();   // create reader & open file textreader tr = new streamreader("playerstats.txt");  // read lines of text string playerlevelstring = tr.readline(); string playerexperiencestring = tr.readline();  //convert strings int playerlevel = convert.toint32(playerlevelstring); playerexperience = convert.toint32(playerexperiencestring);  // close stream tr.close(); 

i have tried use resource.resx file, cannot modify contents of file progamatically.

the obvious solution use sql seems large footprint small project. though considering how many text files using storyboards, maybe sql database not bad idea.

bottom line, how manage variables/values need able changed in other parts of program?


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -