示例#1
0
        /// <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));
            score = (ScoreData)Game.Services.GetService(typeof(ScoreData));

            font = Game.Content.Load<SpriteFont>("font");

            base.Initialize();
        }
示例#2
0
        /// <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()
        {
            tmapRenderer = (ITilemapRenderer)Game.Services.GetService(typeof(ITilemapRenderer));
            score = (ScoreData)Game.Services.GetService(typeof(ScoreData));
            collisions = (ICollisionManager)Game.Services.GetService(typeof(ICollisionManager));
            sfx = (Dictionary<string, SoundEffect>)Game.Services.GetService(typeof(Dictionary<string, SoundEffect>));

            Game.Services.AddService(typeof(IEscapeeManager), this);

            base.Initialize();
        }
示例#3
0
        /// <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();
        }