public override void Start() { base.Start(); var menuparser = new XmlParser(@"States/Menu/menu.xml"); _bgimage = new Image(this, "BGImage"); _bgimage.ParseXml(menuparser, "Menu->BGImage"); AddEntity(_bgimage); _starttext = new Text(this, "StartText"); _starttext.ParseXml(menuparser, "Menu->StartText"); float x = GameRef.Viewport.Width / 2 - _starttext.TextRender.DrawRect.Width / 2; _starttext.Body.Position = new Vector2(x, 500); AddEntity(_starttext); _startkey = new DoubleInput(null, "StartKey", Keys.Enter, Buttons.Start, PlayerIndex.One); }
public override void Start() { if (!_alreadystarted) { base.Start(); _alreadystarted = true; XmlParser xp = new XmlParser(@"States/Game/Game.xml"); _bgimage = new Image(this, "BGImage"); _bgimage.ParseXml(xp, Name + "->" + _bgimage.Name); AddEntity(_bgimage); _town = new Town(this, xp); AddEntity(_town); _scoretext = new Text(this, "ScoreText"); _scoretext.ParseXml(xp, Name + "->" + _scoretext.Name); _scoretext.Body.Position = new Vector2( GameRef.Viewport.Width / 2 - _scoretext.TextRender.DrawRect.Width / 2, 10); AddEntity(_scoretext); _healthtext = new Text(this, "HealthText"); _healthtext.ParseXml(xp, Name + "->" + _healthtext.Name); _healthtext.Body.Position = new Vector2( GameRef.Viewport.Width / 2 - _healthtext.TextRender.DrawRect.Width / 2, 50); AddEntity(_healthtext); _difficultytext = new Text(this, "DifficultyText"); _difficultytext.ParseXml(xp, Name + "->" + _difficultytext.Name); _difficultytext.Body.Position = new Vector2( GameRef.Viewport.Width / 2 - _difficultytext.TextRender.DrawRect.Width / 2, 90); AddEntity(_difficultytext); _es = new EnemySpawner(this, xp); EntityRemoved += _es.RemoveEnemy; _es.Targets.Add(_town); AddEntity(_es); _town.Targets.List = _es.Enemies; } }