/// <summary> /// Allows the game component to perform any initialization it needs to before starting /// to run. This is where it can query for any required services and load content. /// </summary> public override void Initialize() { // TODO: Add your initialization code here this.camera = this.Game.Services.GetService(typeof(ICameraService)) as ICameraService; if (this.camera == null) { throw new InvalidOperationException("ICameraService not found."); } this.gameMap = this.Game.Services.GetService(typeof(Map)) as Map; if (this.gameMap == null) { throw new InvalidOperationException("Map not found."); } this.player = this.Game.Services.GetService(typeof(Player)) as Player; if (this.player == null) { throw new InvalidOperationException("Player not found."); } this.shooter = this.Game.Services.GetService(typeof(Shooter)) as Shooter; if (this.shooter == null) { throw new InvalidOperationException("Shooter not found."); } base.Initialize(); }
public void BuildGameComponents(int mapSeed) { this.camera = new Camera(this, new Vector3(0, 0, 100), new Vector3(1, 0, 0), new Vector3(0, 1, 0), new Vector3(0, 0, 0)); this.Services.AddService(typeof(ICameraService), this.camera); Console.WriteLine(" {0} ", mapSeed); this.gameMap = new Map(this, new Vector3(0, 0, 0), mapSeed); this.Services.AddService(typeof(Map), this.gameMap); this.path = new Path(this); this.Services.AddService(typeof(Path), this.path); this.gamePlayer = new Player(this); this.Services.AddService(typeof(Player), this.gamePlayer); this.fps = new FPS(this); this.mainMenu = new MainMenu(this); this.Components.Add(this.camera); this.Components.Add(this.gameMap); this.Components.Add(mainMenu); this.Components.Add(fps); this.Components.Add(this.path); this.Components.Add(this.gamePlayer); }