示例#1
0
        protected void Initialize(Options options,GraphicsDevice graphics)
        {
            basicTarget = new RenderTarget2D(graphics,
                graphics.PresentationParameters.BackBufferWidth,
                graphics.PresentationParameters.BackBufferHeight,
                false,
                SurfaceFormat.Color,
                DepthFormat.None,
                graphics.PresentationParameters.MultiSampleCount,
                RenderTargetUsage.PreserveContents);
            player = new Player(new Vector2(100, 100), Content);
            blur = content.Load<Effect>("Stuff/Effects/Blur");
            waether = content.Load<Effect>("Stuff/Effects/Weather");
            waether.CurrentTechnique = waether.Techniques["Technique1"];
            motionblur = content.Load<Effect>("Stuff/Effects/MotionBlur");
            waether.Parameters["effectTexture"].SetValue(content.Load<Texture2D>("Stuff/Effects/Rain"));
            level = new Level();
            level.LoadLevel(content.ServiceProvider,graphics,options);
            InitializeLayer(options,graphics);
            player.Pos = level.Startpos;
            bg_rect = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight);

            gamelogic = new GameLogic();
            gamelogic.Initialize(content.ServiceProvider,graphics, level.LevelVariables, options);
            camera = new Camera(options.ScreenWidth,
                options.ScreenHeight,
                level.Startpos,
                (float)options.ScaleFactor);
            debugscreen = new DebugScreen(Content, level.Startpos);
            Matrix viewMatrix = Matrix.CreateLookAt(
                   new Vector3(0.0f, 0.0f, 1.0f),
                   Vector3.Zero,
                   Vector3.Up
                   );

            Matrix projectionMatrix = Matrix.CreateOrthographicOffCenter(
                0,
                (float)options.ScreenWidth,
                (float)options.ScreenHeight,
                0,
                1.0f, 1000.0f);

            effect = new BasicEffect(graphics);
            effect.Alpha = 1.0f;
            effect.View = viewMatrix;
            effect.Projection = projectionMatrix;
            effect.VertexColorEnabled = true;

            colorizePost = new ColorizeLUT();
            colorizeBackground = new ColorizeLUT();
            JumpPad pad = new JumpPad();
            pad.Initialize(content.ServiceProvider, options, graphics, "0,0,32,32,0,-5000,0.95");
            iObjectManager.AddObject(pad);
            target = new RenderTarget2D(graphics,
                graphics.PresentationParameters.BackBufferWidth,
                graphics.PresentationParameters.BackBufferHeight,
                false,
                SurfaceFormat.Color,
                DepthFormat.None,
                graphics.PresentationParameters.MultiSampleCount,
                RenderTargetUsage.PreserveContents);

            toonShader = new ToonShader();
            toonShader.Initialize(Content.ServiceProvider, graphics, options);
            toonShader.Enabled = true;
        }
示例#2
0
        public void LoadLevel(IServiceProvider ServiceProvider,GraphicsDevice device,string level_name, LevelType leveltype,Options options)
        {
            level.Dispose();
            level = new Level();
            level.LevelLoadLineEnhanced += new LevelLoadLineEnhancedEventHandler(level_LevelLoadLineEnhanced);
            level.LoadLevel(ServiceProvider,device,options, level_name, leveltype);
            //level = new Level(ServiceProvider, level_name, leveltype);
            GameParameters.CurrentGraphXPack = level.LevelVariables.Dictionary[LV.GraphXPack];
            colorizeBackground.Dispose();
            colorizeBackground = new ColorizeLUT();
            colorizeBackground.Initialize(ServiceProvider, device, options);
            colorizeBackground.Enabled = true;
            colorizeBackground.StartResetEffect();
            colorizeBackground.FxData = LayerFXData.FromString(level.LevelVariables.Dictionary[LV.BackgroundFX]);
            colorizePost.Dispose();
            colorizePost = new ColorizeLUT();
            colorizePost.Initialize(ServiceProvider, device, options);
            colorizePost.Enabled = true;
            colorizePost.StartResetEffect();
            colorizePost.FxData = LayerFXData.FromString(level.LevelVariables.Dictionary[LV.PostFX]);
            iObjectManager.Dispose();
            iObjectManager = new InteractiveObjectManager();
            iObjectManager.Initialize(content.ServiceProvider, level.LevelVariables,device, options);

            LevelLoadEnhanced(50, "Level Loaded...");
            player = new Player(level.Startpos, Content);
            InitializeLayer(options,device);
            LevelLoadEnhanced(60, "Layers Initialized");
            gamelogic.Dispose();
            gamelogic = new GameLogic();
            gamelogic.Initialize(content.ServiceProvider,device, level.LevelVariables, options);
            camera = new Camera(options.ScreenWidth,
                options.ScreenHeight,
                level.Startpos,
                (float) options.ScaleFactor);
            debugscreen = new DebugScreen(Content, level.Startpos);
            LevelLoadEnhanced(75, "Game Logic Loaded");
            bg_tex = content.Load<Texture2D>(GameConstants.GraphXPacksPath + level.LevelVariables.Dictionary[LV.GraphXPack] + "/Backgrounds/" + level.LevelVariables.Dictionary[LV.BackgroundImg]);
            enemyManager.Dispose();
            enemyManager = new EnemyManager(ServiceProvider,options);
            LoadEnemies(options);

            enemyManager.PlayerKilled += gamelogic.PlayerKilled;

            //Invoke LevelLoaded Event
            LevelLoaded();
            //Cleaning UP...
            GC.Collect();

            firstFrame = true;
        }