protected override void LoadContent() { this.IsMouseVisible = true; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); viewportRect = new Rectangle(0, 0, graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height); //font defaultFont = Content.Load <SpriteFont>("arial12"); //car textures texAcc = Content.Load <Texture2D>("car_gadgets\\acc"); texBrake = Content.Load <Texture2D>("car_gadgets\\brake"); texSteer = Content.Load <Texture2D>("car_gadgets\\steer"); //LBM textures texWall = Content.Load <Texture2D>("gas\\wall"); //config load var xmlSettings = XmlSettings.CreateFromFile(Path.Combine("Configs", Config.ConfigDir, "settings.xml"), this); this.routeConfigList = xmlSettings.RouteConfigList; this.lightList = xmlSettings.LightList; this.lightConfigList = xmlSettings.LightConfigList; //inicjacja tabLBM lightTabLBM = new LBMElement[countX, countY]; tabLBM = new LBMElement[routeConfigList.Count][, ]; for (int i = 0; i < routeConfigList.Count; i++) { tabLBM[i] = new LBMElement[countX, countY]; } //getting all color data beforehand _colorMap = new Color[resX * resY]; mapTexture.GetData <Color>(0, new Rectangle(0, 0, resX, resY), _colorMap, 0, resX * resY); //okreslanie tabLogicMap + instancjonowanie tabeli elementow for (int x = 0; x < countX; x++) { for (int y = 0; y < countY; y++) { //wyciaganie koloru z logic map bool wall = false; if (x == 0 || y == 0 || x == countX - 1 || y == countY - 1) { wall = true; } for (int tx = x * elementSize; ((tx < x * elementSize + elementSize) && (tx < resX)); tx++) { if (wall) { break; } for (int ty = y * elementSize; ((ty < y * elementSize + elementSize) && (ty < resY)); ty++) { if (wall) { break; } var retrievedColor = _colorMap[ty * resX + tx]; if ((retrievedColor.A > 254) && (retrievedColor.G > 128)) { wall = true; } } } lightTabLBM[x, y] = new LBMElement(); for (int i = 0; i < routeConfigList.Count; i++) { tabLBM[i][x, y] = new LBMElement(); if (wall) { tabLBM[i][x, y].isWall = true; } else { tabLBM[i][x, y].isNormal = true; } } } } //wkladanie w odpowiednie tabLBM pkt startowe, koncowe i sciany for (int i = 0; i < routeConfigList.Count; i++) { RouteConfig rc = routeConfigList[i]; foreach (RouteStart rs in rc.routeStart) { LBMController.DrawLineLBM(tabLBM[i], elementSize, rs.x1, rs.y1, rs.x2, rs.y2, LBMNodeType.Source); } foreach (RouteEnd re in rc.routeEnd) { LBMController.DrawLineLBM(tabLBM[i], elementSize, re.x1, re.y1, re.x2, re.y2, LBMNodeType.Sink); } foreach (RouteWall rw in rc.routeWall) { LBMController.DrawLineLBM(tabLBM[i], elementSize, rw.x1, rw.y1, rw.x2, rw.y2, LBMNodeType.Wall); } } base.LoadContent(); }