/// <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() { collisions = (ICollisionManager)Game.Services.GetService(typeof(ICollisionManager)); camera = (GameCamera)Game.Services.GetService(typeof(GameCamera)); tmapRenderer = (ITilemapRenderer)Game.Services.GetService(typeof(ITilemapRenderer)); sfx = (Dictionary<string, SoundEffect>)Game.Services.GetService(typeof(Dictionary<string, SoundEffect>)); p.SetupGraphics(Game); collisions.AddEntity(p); base.Initialize(); }
/// <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() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); Services.AddService(typeof(SpriteBatch), spriteBatch); score = new ScoreData(); Services.AddService(typeof(ScoreData), score); camera = new GameCamera { X = 0, Y = 0, Width = Window.ClientBounds.Width, Height = Window.ClientBounds.Height }; Services.AddService(typeof(GameCamera), camera); collisionManager = new CollisionManager(this,24,24); Components.Add(collisionManager); tmapRenderer = new TilemapRenderer(this); Components.Add(tmapRenderer); map = Tilemap.Load("testmap.tmx"); tmapRenderer.Map = map; playerManager = new PlayerManager(this); Components.Add(playerManager); player = new Player(); playerManager.Player = player; escapeeManager = new EscapeeManager(this); Components.Add(escapeeManager); sfx = new Dictionary<string, SoundEffect>(); Services.AddService(typeof(Dictionary<string, SoundEffect>), sfx); round = new Round { ParticipantCount = 9, WaveInterval = 10 }; uiManager = new UIManager(this); Components.Add(uiManager); base.Initialize(); }
/// <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() { spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); camera = (GameCamera)Game.Services.GetService(typeof(GameCamera)); base.Initialize(); }
/// <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() { spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch)); collisionManager = (ICollisionManager)Game.Services.GetService(typeof(ICollisionManager)); camera = (GameCamera)Game.Services.GetService(typeof(GameCamera)); Game.Services.AddService(typeof(ITilemapRenderer), this); if (map != null) foreach (TaggedVector p in map.CollidableTiles) collisionManager.AddTile(p.Position, (Tile)p.Identifier); base.Initialize(); }