If the game is not archived and starts from scratch every time, it will be boring. To improve the playability of the game, I have added the information access function, mainly including the game points, the access and ranking of the game role, so that each time you open the game, you can see the highest score! In this way, it is challenging. Challenge the highest score and record your name on the hero list!
I use points. The player-format saves the Game Information on the notepad of the local disk @ "D:/snkegameinfo.txt". This way, after starting the game, you can read and store the game information.
And sort the hero rankings by points:
Savegameinfo. CS
Public class savegameinfo <br/>{< br/> private string filepath = @ "D:/snkegameinfo.txt "; <br/> // save information <br/> Public bool saveinfo (string score, string player) <br/>{< br/> try <br/> {<br/> // if there is no information archiving file, the new key file, otherwise, append information to the end of an existing file <br/> filestream; <br/> If (! File. exists (filepath) <br/> filestream = new filestream (filepath, filemode. create); <br/> else <br/> filestream = new filestream (filepath, filemode. append); <br/> streamwriter = new streamwriter (filestream); <br/> streamwriter. write (score + ";" + player + "-"); <br/> streamwriter. close (); <br/> return true; <br/>}< br/> catch {return false ;} </P> <p >}< br/> // read information <br/> Public String [] Readinfo () <br/>{< br/> If (! File. exists (filepath) <br/> return NULL; <br/> else <br/>{< br/> string [] scores = new string [] {}; // score and player <br/> try <br/>{</P> <p> string STR = ""; <br/> filestream = new filestream (filepath, filemode. open); <br/> streamreader = new streamreader (filestream); <br/> STR = streamreader. readtoend (); <br/> scores = Str. split ('-'); <br/> streamreader. close (); <br/>}< br/> catch {}< br/> return scores; <br/>}< br/>}