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; }
public void GraphicsChanged(GraphicsDevice device,Options options) { //3_1 //resolvedtexture.Dispose(); //resolvedtexture = new ResolveTexture2D(device, options.ScreenWidth, options.ScreenHeight, device.PresentationParameters.BackBufferCount, SurfaceFormat.Color); PresentationParameters pp = device.PresentationParameters; basicTarget = new RenderTarget2D( device, pp.BackBufferWidth, pp.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.PreserveContents); target = new RenderTarget2D( device, pp.BackBufferWidth, pp.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None, pp.MultiSampleCount, RenderTargetUsage.PreserveContents); bg_rect = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight); camera = new Camera(options.ScreenWidth, options.ScreenHeight, Player.Pos, options.ScaleFactor); }
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; }
protected override void Initialize() { //Initilaize Layer Data layerData = new Dictionary<LayerFX, LayerFXData>(); //Fill Dictionary with Default Values foreach (LayerFX layer in Enum.GetValues(typeof(LayerFX))) { layerData.Add(layer, LayerFXData.Default); } editorcontent = new ContentManager(Services, "StarEditData"); gamecontent = new ContentManager(Services, "Data"); blanktex = gamecontent.Load<Texture2D>("Stuff/Blank"); recttool = new Rectangle(); options = new Options(); options.ScreenHeight = DisplayRectangle.Height; options.ScreenWidth = DisplayRectangle.Width; options.ScreenWidth = GraphicsDevice.PresentationParameters.BackBufferWidth; options.ScreenHeight = GraphicsDevice.PresentationParameters.BackBufferHeight; options.InitObjectHolder.graphics = GraphicsDevice; options.InitObjectHolder.serviceProvider = Services; oldscreensize = new Point(DisplayRectangle.Width, DisplayRectangle.Height); try { arial = editorcontent.Load<SpriteFont>("Arial"); spritebatch = new SpriteBatch(GraphicsDevice); } catch (Exception e) { string error = e.Message; } level = new Level(); level.LoadLevel(Services,GraphicsDevice,options); //level = new Level(Services); iObjectManager = new InteractiveObjectManager(); iObjectManager.Initialize(Services, level.LevelVariables, GraphicsDevice, options); rearparallaxLayer = new ParallaxLayer(); frontparallaxLayer = new ParallaxLayer(); cloudlayer = new CloudLayer(); reardecoLayer = new DecoLayer(); frontDecoLayer = new DecoLayer(); SetBGRect(); camera = new Camera(DisplayRectangle.Width, DisplayRectangle.Height, Vector2.Zero, DisplayRectangle.Height / 600f); mousetile = new Tile(0, 0); mousetile.load_tile((int)TileType.Wall,null); mouseTex = editorcontent.Load<Texture2D>("mousetile"); if (level.Tiles != null) { mousetile.LoadGrass(); } SetBorders(1, 1); enemymanager = new EnemyManager(Services, new Options()); try { placeEnemy = new SingleEnemyManager(Services); placeEnemy.LoadEnemy(selectedEnemy); } catch (Exception e) { FileManager.WriteInErrorLog(this, e.Message, e.GetType()); } bg_tex = new Texture2D(GraphicsDevice, 1, 1); colorizePost = new ColorizeLUT(); colorizePost.Initialize(Services,GraphicsDevice,new Options()); colorizePost.Enabled = true; colorizePost.StartResetEffect(); colorizePost.FxData = LayerFXData.Default; colorizeBackground = new ColorizeLUT(); colorizeBackground.Initialize(Services, GraphicsDevice, new Options()); colorizeBackground.Enabled = true; colorizeBackground.StartResetEffect(); target = new RenderTarget2D(GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None, GraphicsDevice.PresentationParameters.MultiSampleCount, RenderTargetUsage.PreserveContents); }
public void NewLevel(int x, int y) { SetBGRect(); level = new Level(); level.LoadLevel(Services,GraphicsDevice,options, x, y); //level = new Level(Services,x,y); SetBorders(x, y); camera = new Camera(DisplayRectangle.Width, DisplayRectangle.Height, new Vector2(DisplayRectangle.Width*1.5f, y * Tile.TILE_SIZE - DisplayRectangle.Height ), DisplayRectangle.Height / 2000f); mouseoffset = new Vector2(DisplayRectangle.Width / 2, DisplayRectangle.Height / 2); InitializeLayer(options); bg_tex = gamecontent.Load<Texture2D>(GameConstants.GraphXPacksPath + level.LevelVariables.Dictionary[LV.GraphXPack] + "/Backgrounds/" + level.LevelVariables.Dictionary[LV.BackgroundImg]); }
public void LoadLevel(string levelPath) { SetBGRect(); level = new Level(); level.LoadLevel(Services,GraphicsDevice,options, levelPath); //level = new Level(Services, levelPath); SetBorders(level.Tiles.GetLength(1), level.Tiles.GetLength(0)); camera = new Camera(DisplayRectangle.Width, DisplayRectangle.Height, level.Startpos, DisplayRectangle.Height / 1200f); mouseoffset = new Vector2(DisplayRectangle.Width/2, DisplayRectangle.Height/2); InitializeLayer(options); LoadEnemies(); iObjectManager.Dispose(); iObjectManager = new InteractiveObjectManager(); iObjectManager.Initialize(Services, level.LevelVariables, GraphicsDevice, options); bg_tex = gamecontent.Load<Texture2D>(GameConstants.GraphXPacksPath + level.LevelVariables.Dictionary[LV.GraphXPack] + "/Backgrounds/" + level.LevelVariables.Dictionary[LV.BackgroundImg]); }
public void Initialize(Options options, GraphicsDevice graphics) { camera = new Camera(options.ScreenWidth, options.ScreenHeight, new Vector2(options.ScreenWidth / 2, options.ScreenHeight / 2), options.ScaleFactor); this.options = options; optionsMenu.Options = options; optionsMenu.Initialize(content.ServiceProvider, graphics, new MenuList[1]); MenuList[] mainmenuList = new MenuList[1]; string[] names = new string[5]; names[0] = "Story"; names[1] = "Custom Maps"; names[2] = "Options"; names[3] = "Credits"; names[4] = "Quit"; mainmenuList[0] = new MenuList("S.T.A.R.", names); mainmenuList[0].ChangeButtonState(0, ButtonIndicator.Button_Locked); mainmenuList[0].SetActiveButton(0); font = content.Load<SpriteFont>("Stuff/Arial"); background = content.Load<Texture2D>("Img/Menu/StdBG"); //bgrect = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight); int height = (int)(((float)options.ScreenWidth / background.Width) * background.Height); if (height >= options.ScreenHeight) { bgrect = new Rectangle(0, options.ScreenHeight - height, options.ScreenWidth, height); } else { int width = (int)(((float)options.ScreenHeight / background.Height) * background.Width); bgrect = new Rectangle(options.ScreenWidth - width, 0, width, options.ScreenHeight); } screenWidth = options.ScreenWidth; screenHeight = options.ScreenHeight; options.InitObjectHolder.dataHolder.PutData(Layer.Data_Layer.NumLayerObjects.GetKey(),4); cloudlayer.Initialize(options, new LevelVariables()); custmapmenu.Initialize(options); mainmenu.Initialize(content.ServiceProvider, graphics, mainmenuList); pBackground.Initialize(options); }
public void GraphicsChanged(GraphicsDevice device, Options options) { camera = new Camera(options.ScreenWidth, options.ScreenHeight, new Vector2(options.ScreenWidth / 2, options.ScreenHeight / 2), options.ScaleFactor); cloudlayer.GraphicsChanged(device, options); int height = (int)(((float)options.ScreenWidth / background.Width) * background.Height); if (height>=options.ScreenHeight) { bgrect = new Rectangle(0, options.ScreenHeight - height, options.ScreenWidth, height); } else { int width = (int)(((float)options.ScreenHeight / background.Height) * background.Width); bgrect = new Rectangle(options.ScreenWidth - width, 0, width, options.ScreenHeight); } //bgrect = new Rectangle(0, 0, options.ScreenWidth, options.ScreenHeight); }