public override GameLoop Update(GameTime g) { Screen.Update(_textureActive.Width / 2, _textureActive.Height / 2); //Center the screen! _ticks += g.ElapsedGameTime.Milliseconds; if (_anim == true) { if (_ticks > 2000) { _textureActive = _picAnimatie[1]; } if (_ticks > 4000) { _textureActive = _picAnimatie[2]; _anim = false; } } #region UpdateTexture if (_enter && _textureActive == _picAnimatie[2]) { _textureActive = _picAnimatie[3]; _enter = false; } else if (_enter && _textureActive == _picAnimatie[5]) { _textureActive = _picAnimatie[6]; _enter = false; } else if (_enter && _textureActive == _picAnimatie[6]) { _enter = false; return(new Level1(new Speler())); } else if (_esc) { if (_textureActive == _picAnimatie[3]) { _textureActive = _picAnimatie[2]; } else if (_textureActive == _picAnimatie[4]) { _textureActive = _picAnimatie[3]; } _esc = false; } else if (_i && _textureActive == _picAnimatie[3]) { _textureActive = _picAnimatie[4]; _i = false; } else if (_s && _textureActive == _picAnimatie[3]) { _s = false; _textureActive = _picAnimatie[5]; } else if (_l && _textureActive == _picAnimatie[3]) { _l = false; FileStream inFile = new FileStream(_FILENAME, FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(inFile); string recordIn; string[] fields; List <Enemy> tempEnemy = new List <Enemy>(); List <RemoveGameObject> tempBonus = new List <RemoveGameObject>(); List <Sleutels> tempSleutels = new List <Sleutels>(); bool blue = false; bool red = false; string Level = reader.ReadLine(); int ScoreSpeler = Convert.ToInt32(reader.ReadLine()); int Levens = Convert.ToInt32(reader.ReadLine()); int PosX = Convert.ToInt32(reader.ReadLine()); int PosY = Convert.ToInt32(reader.ReadLine()); Speler tempSpeler = new Speler(PosX, PosY); tempSpeler.ScoreInt = ScoreSpeler; for (int i = 0; i < Levens; i++) { tempSpeler.AddLive(); } recordIn = reader.ReadLine(); while (recordIn != null) { fields = recordIn.Split(';'); if (fields[0] == "Robot") { tempEnemy.Add(new Robot((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } else if (fields[0] == "MonsterRight") { tempEnemy.Add(new MonsterRight((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } else if (fields[0] == "MonsterLeft") { tempEnemy.Add(new MonsterLeft((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } else if (fields[0] == "Mine") { tempEnemy.Add(new Mine((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } else if (fields[0] == "Tank") { tempEnemy.Add(new Tank((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]), (int)Convert.ToDouble(fields[3]))); } else if (fields[0] == "FireRobot") { tempEnemy.Add(new FireRobot((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]), (int)Convert.ToDouble(fields[3]))); } else if (fields[0] == "Floppy") { tempBonus.Add(new Floppy((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } else if (fields[0] == "Cola") { tempBonus.Add(new Cola((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } else if (fields[0] == "KeyRed") { tempBonus.Add(new KeyRed((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } else if (fields[0] == "KeyBlue") { tempBonus.Add(new KeyBlue((int)Convert.ToDouble(fields[1]), (int)Convert.ToDouble(fields[2]))); } recordIn = reader.ReadLine(); } reader.Close(); inFile.Close(); foreach (RemoveGameObject r in tempBonus) { if (r is KeyBlue) { blue = true; } else if (r is KeyRed) { red = true; } } if (!red) { tempSleutels.Add(Sleutels.Red); } if (!blue) { tempSleutels.Add(Sleutels.Blue); } if (Level == "Level1") { return(new Level1(tempSpeler, tempEnemy, tempBonus, tempSleutels)); } else { return(new Level2(tempSpeler, tempEnemy, tempBonus, tempSleutels)); } } #endregion return(this); }