/// <summary> /// LoadContent wird einmal pro Spiel aufgerufen und ist der Platz, wo /// Ihr gesamter Content geladen wird. /// </summary> protected override void LoadContent() { // Erstellen Sie einen neuen SpriteBatch, der zum Zeichnen von Texturen verwendet werden kann. _spriteBatch = new SpriteBatch(GraphicsDevice); _tileSetTexture = Content.Load<Texture2D>(@"grass"); _treeTexture = Content.Load<Texture2D>("tree"); _deadTreeTexture = Content.Load<Texture2D>("deadtree"); _gruselUteTexture = Content.Load<Texture2D>("wildboar"); _blackHoleTexture = Content.Load<Texture2D>("blackhole"); _potionTexture = Content.Load<Texture2D>("potion"); _cestTexture = Content.Load<Texture2D>("Schatztruhe"); _input = new InputManager(this); _interface = new Interface(this); _player = new Player(this); _parser = new XML_Parser(this); _dialogSystem = new DialogSystem(this); //_parser.SetFilename("Horst"); //_parser.SaveText(); _parser.SetFilename("0"); //_parser.SetLevel(); //_parser.SaveLevel(); try { _parser.LoadLevel(); _currentLevel = _parser.GetLevel(); } catch (Exception e) { _currentLevel = new Level(this); int[,] layer0 = new int[,] { {1,1,1,1,1,1,1,1}, {1,9,9,9,9,9,9,1}, {1,9,9,9,9,9,9,1}, {1,9,9,54,111,111,9,1}, {1,9,9,9,111,111,9,1}, {1,9,9,9,9,54,9,1}, {1,9,9,9,9,9,9,1}, {1,1,1,1,1,1,1,1}}; int[,] layer1 = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 87 } }; layer0[1, 5] = 65; _currentLevel.AddFloor(layer0); _currentLevel.AddCeiling(new int[0, 0]); } PlayerClasses.CollisionDetector.Setup(_currentLevel); this.Components.Add(_input); _currentLevel.LoadContent(); _player.LoadContent(Content); // TODO: Verwenden Sie this.Content, um Ihren Spiel-Inhalt hier zu laden }
public Level GetLevel() { // Variablen String[] splitvektor; String[] split; // Ermittlung Ebenengroeße split = _level._ebenengroeße.Split(';'); int[,] levelgroeße = new int[split.Length, 2]; for (int i = 0; i < split.Length; i++) { splitvektor = split[i].Split(','); levelgroeße[i, 0] = int.Parse(splitvektor[0]); levelgroeße[i, 1] = int.Parse(splitvektor[1]); } // Ermittlung Ebene0 split = _level._ebene_0_Grundtextur.Split(';'); int[,] ebene0 = new int[levelgroeße[0, 0], levelgroeße[0, 1]]; for (int i = 0; i < levelgroeße[0, 0]; i++) { splitvektor = split[i].Split(','); for (int j = 0; j < levelgroeße[0, 1]; j++) { ebene0[i, j] = int.Parse(splitvektor[j]); } } // Ermittlung Ebene2 split = _level._ebene_2_obereObjekts.Split(';'); int[,] ebene2 = new int[levelgroeße[2, 0], levelgroeße[2, 1]]; for (int i = 0; i < levelgroeße[2, 0]; i++) { splitvektor = split[i].Split(','); for (int j = 0; j < levelgroeße[2, 1]; j++) { ebene2[i, j] = int.Parse(splitvektor[j]); } } // Erzeugung von Liste mit Einheiten split = _level._unitsposition.Split(';'); List<Entity> units = new List<Entity>(); Entity unit; Level level = new Level(_game); for (int i = 0; i < split.Length; i++) { splitvektor = split[i].Split(','); Vector2 vektor = new Vector2(int.Parse(splitvektor[0]), int.Parse(splitvektor[1])); switch (i) { case 0: unit = new EntityGruselUte(_game, vektor, (_game as Game1)._gruselUteTexture); break; case 1: unit = new EntityTree(_game, vektor, (_game as Game1)._treeTexture); break; case 2: unit = new EntityHorst(_game, vektor, (_game as Game1)._treeTexture, "Horst"); break; case 3: unit = new EntityJumpPoint(_game, vektor, (_game as Game1)._blackHoleTexture, level, new Vector2(500,500)); break; case 4: // Truhe http://mariowiki.net/w/images/8/89/WL4_Sprite_Schatztruhe.png unit = new EntityChest(_game, vektor, (_game as Game1)._cestTexture); break; default: unit = new EntityPotion(_game, vektor, (_game as Game1)._potionTexture); break; } level.AddDynamics(unit); } /*level.AddLayer(0, ebene0); level.AddLayer(2, ebene2);*/ level.AddFloor(ebene0); level.AddCeiling(ebene2); return level; }