I'm in a early stage of making my game and I'm facing a problem... the garbage collector. I have a factory that create all the pokemons information, for exemple, here is magikarp :
private PokemonInfo Magikarp()
{
//General Information
int pokedex = 052;
string name = "Magikarp";
string description = "It is said to be the world’s weakest Pokémon. No one knows why it has managed to survive.";
int gender = (int)Enum.gender.Both;
double height = 0.9;
double weight = 10;
//Typing
int type = (int)Enum.type.Water;
//Abilities
List<Ability> abilitiesPokemon = new List<Ability>();
abilitiesPokemon.Add(abilities[(int)Enum.ability.Swift_Swim]);
//Stats
int baseHP = 20;
int baseAttack = 10;
int baseDefense = 55;
int baseSpecialAttack = 15;
int baseSpecialDefense = 20;
int baseSpeed = 80;
//Battle
int catchrate = 255;
int experience = (int)Enum.experience.Slow;
int experienceYield = 20;
//Moves
List<Learnset> learnset = new List<Learnset>();
List<Move> tmPokemon = new List<Move>();
//========================================================Leveling
learnset.Add(new Learnset(moves[(int)Enum.move.Splash], 1));
learnset.Add(new Learnset(moves[(int)Enum.move.Tackle], 15));
learnset.Add(new Learnset(moves[(int)Enum.move.Flail], 30));
//========================================================TM
tmPokemon.Add(moves[(int)Enum.move.Bounce]);
return new PokemonInfo(pokedex, name, description, gender, height, weight, type, abilitiesPokemon, catchrate, experience, experienceYield, baseHP, baseAttack, baseDefense, baseSpecialAttack, baseSpecialDefense, baseSpeed, learnset, tmPokemon, Gyarados(), 20);
}
Is there a way I can create a file with all my PokemonInfo data ? Something I can use like :
Pokedex.GetInfo(FILE.Magikarp).description;
I traveled across the web, searching far and wide, but I couldn't find the solution >.<
question from:
https://stackoverflow.com/questions/65647761/c-sharp-how-to-store-data-in-a-file-so-the-garbage-collector-dont-delete-them 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…