예제 #1
0
        protected override void Initialize()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            Type[] types = new Type[] {typeof(Enemy),typeof(Expires),typeof(Health),typeof(SpatialForm),typeof(Transform),typeof(Velocity),typeof(Weapon)};
            pool = new GamePool(100,types);
            pool.Initialize();

            spriteBatch = new SpriteBatch(GraphicsDevice);
            world = new EntityWorld();
            world.GetEntityManager().RemovedComponentEvent += new RemovedComponentHandler(RemovedComponent);
            world.SetPool(pool);

            font = Content.Load<SpriteFont>("Arial");
            SystemManager systemManager = world.GetSystemManager();
            renderSystem = systemManager.SetSystem(new RenderSystem(GraphicsDevice,spriteBatch,Content),ExecutionType.Draw);
            hudRenderSystem = systemManager.SetSystem(new HudRenderSystem(spriteBatch, font), ExecutionType.Draw);
            controlSystem = systemManager.SetSystem(new MovementSystem(spriteBatch), ExecutionType.Update,1);
            movementSystem = systemManager.SetSystem(new PlayerShipControlSystem(spriteBatch),ExecutionType.Update);
            enemyShooterSystem = systemManager.SetSystem(new EnemyShipMovementSystem(spriteBatch), ExecutionType.Update,1);
            enemyShipMovementSystem = systemManager.SetSystem(new EnemyShooterSystem(), ExecutionType.Update);
            collisionSystem = systemManager.SetSystem(new CollisionSystem(), ExecutionType.Update,1);
            healthBarRenderSystem = systemManager.SetSystem(new HealthBarRenderSystem(spriteBatch, font), ExecutionType.Draw);
            enemySpawnSystem = systemManager.SetSystem(new EnemySpawnSystem(500, spriteBatch), ExecutionType.Update);
            expirationSystem = systemManager.SetSystem(new ExpirationSystem(), ExecutionType.Update);

            systemManager.InitializeAll();

            InitPlayerShip();
            InitEnemyShips();

            base.Initialize();
        }