Storing level data

Level 1
Type: Attack
Map: DeadEnd
Time: 1:00
Enemies: GFB
EnemiesHealth: 238
EnemiesStrength: 339
WaveOrder: GFGFGFFGGFGB
Weapons: PistolShotgun
Reward: 1000

Level 2
Type: Survive
Map: Junkyard
Time: 1:30
Enemies: F
EnemiesHealth: 2
EnemiesStrength: 3
WaveOrder: FFFFFFFFFFF
Weapons: PistolShotgunRifle
Reward: 500

I need to store properties for each of my levels like the example above but I’m clueless on the best way to store this data. I’m fine reading this and generating a level from it but I don’t know the best way to store and manage the data, especially considering it could grow to be 50+ levels. I’ve read a lot on using external text files, XML files, structs, dictionaries, serializing… but I don’t know what is most common, or if any of those is even the right approach for me.

Should I just put all of this information into one long JavaScript script? What’s the advantage to using an external text file(s)? Would an external file open up the game to easy cheating?

I’m unfamiliar with this area of game development so any advice would be valuable to me. I’m hoping for a JavaScript option if possible, and it’s for an iOS game.

i think you sould use xml to store this information. in C# XMLDocument will be perfect for this. in java i dont know =( if you will use this informantion will not change until the game you should create your xml in Assets/Resouses folder, and load it use

XmlDocument doc = new XmlDocument();
TextAsset ta = (TextAsset) Resources.Load("myXML");
doc.LoadXml(ta.text);

it’s a rough answer but in C# you can do…

//at the top of the script
using System.Collections.Generic;
//put this in the monobehaviour
public Level CurrentLevel;
public List<Level> LevelList = new List<Level>();
void Start()
{
    DontDestroyOnLoad(this);
}

//put this outside the monobehaviour

//level data structure
[System.Serializable]
public class Level
{
     public MapType type
     public string name;
     public float time;
     public string enemies;
     public int enemies_health;
     public int enemies_strenght;
     public string WaveOrder;
     public List<Weapon> WeaponList;
     public int reward;
}

//map types
[System.Serializable]
public enum MapType
{
     Attack,
     Defence,
     Other
}

now assign levels directly inside the unity editor
then you can set the current level with

CurrentLevel = LevelList[0]; // zero is the number of the level

load the level with
Application.LoadLevel(CurrentLevel.name);

and acces data about the current level with the Currentlevel variable

I think you should use scriptable object.

Unity Reference: ScriptableObject