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); }
private void UpdateMouseTile() { Vector2 tilepos = new Vector2(); tilepos += new Vector2(MousePosition.X, MousePosition.Y) / camera.Scale; tilepos -= FormLocation / camera.Scale; tilepos -= camera.Position; tilepos -= camera.Offset; tilepos -= mouseoffset / camera.Scale; int tx = (int)(tilepos.X / 32 - 0.5f); int ty = (int)((tilepos.Y / 32)) - (int)(1 / camera.Scale); mousetile = new Tile(tx, ty); if (tx >= 0 && ty >= 0 && tx < level.Tiles.GetLength(1) && ty < level.Tiles.GetLength(0)) { mousetile.load_tile((int)mousetiletype,null); if (level.Tiles != null && mousetile.TileType == TileType.Wall) { mousetile.LoadGrass(); } } else { mousetile.load_tile((int)TileType.Error,null); } if (placing == true) { PlaceMouseTile(); } }