//[NonSerialized] private KryptonEngine krypton; //[NonSerialized] private World _world; public Level(Game game) { _game = game; _camera = _camera = _game.Services.GetService<Camera>(); //krypton = game.Services.GetService<KryptonEngine>(); //_world = game.Services.GetService<World>(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> /// protected override void Initialize() { krypton.Initialize(); _world = new World(new Vector2(0, 0)); _camera = new Camera(new Viewport(0, 0, (int)Globals.Screensize.X, (int)Globals.Screensize.Y)); _particleRenderer = new SpriteBatchRenderer { GraphicsDeviceService = graphics }; _particleRenderer.LoadContent(Content); spriteBatch = new SpriteBatch(GraphicsDevice); gameTextures = new Textures(this); //audio initialise audioEngine = new AudioEngine("Content\\Audio\\artefactAudio.xgs"); waveBank = new WaveBank(audioEngine, "Content\\Audio\\Wave Bank.xwb"); SoundBanks[0] = new SoundBank(audioEngine, "Content\\Audio\\Sound Bank.xsb"); SoundBanks[1] = new SoundBank(audioEngine, "Content\\Audio\\AMB.xsb"); SoundBanks[2] = new SoundBank(audioEngine, "Content\\Audio\\Menu.xsb"); //_ambcues = new AMBCues(); AMBCues.LoadContent(SoundBanks[1]); //Add services Services.AddService(typeof(World), _world); Services.AddService(typeof(SpriteBatch), spriteBatch); Services.AddService(typeof(GameComponentCollection), Components); Services.AddService(typeof(SpriteBatchRenderer), _particleRenderer); Services.AddService(typeof(Camera), _camera); Services.AddService(typeof(KryptonEngine), krypton); Services.AddService(typeof(Textures), gameTextures); Services.AddService(typeof(SoundBank[]), SoundBanks); //Services.AddService(typeof(AMBCues), _ambcues); //Services.AddService(typeof(KeyboardState), _keyboardState); SolidsMaker.Initialise(this); /*/TESTDOOR!!! HACK!!! var door = new DoorVert(this, new Vector2(800-Globals.SmallGridSize.X,600-(Globals.SmallGridSize.Y*10)), 0); Components.Add(door); //Globals.CurrentRoom = Globals.LevelList[0].Roomlist[0]; */ base.Initialize(); }
public void ReLoadServices(Game game) { _game = game; _camera = _camera = _game.Services.GetService<Camera>(); foreach (Room room in Globals.CurrentLevel.Roomlist) { room.ReLoadServices(game); } foreach (var door in Doorlist) { door.ReLoadServices(game); } foreach (var mapSprite in Map) { mapSprite.ReloadServices(game); } }