Edit: I hope to end up with something like this:
int EnemyId = Levels[1].Waves[3].Enemies[5].Id;
int SpawnAmount = Levels[1].Waves[3].Enemies[5].Amount;
Hi guys, I have an XML scheme like this:
<WaveList>
<Level levelId = "1">
<Wave waveId = "1">
<Enemy enemyId = "1"> 5 </Enemy>
<Enemy enemyId = "2"> 0 </Enemy>
<Enemy enemyId = "3"> 0 </Enemy>
</Wave>
</Level>
</WaveList>
And I have a class scheme like this (in XML reader code):
[XmlRoot ("WaveList")]
public class WaveList
{
[XmlElement("Level")]
public List<Level> Levels = new List<Level>();
public class Enemy
{
[XmlAttribute ("enemyId")]
public int Id;
public int Amount;
}
public class Wave
{
[XmlAttribute ("waveId")]
public int Id;
//[XmlArray ("Wave"), XmlArrayItem("Enemy")]
[XmlElement("Enemy")]
public List<Enemy> Enemies = new List<Enemy>();
}
public class Level
{
[XmlAttribute ("levelId")]
public int Id;
[XmlElement("Wave")]
public List<Wave> Waves = new List<Wave>();
}
}
But when i try to call like this:
WaveList.Wave waveToSpawn = new WaveList.Wave();
waveToSpawn = WaveList.Levels[curLevel].Waves[idOfWaveToSpawn];
It gives me a non-static reference error. And i tried with many other combinations and faced different errors. Can anybody give me a tip about how to fetch a wave and enemies in that wave from this code?
If my code is rubbish, you may suggest a new code scheme too, of course.
Thanks in advance!