public UpgradeData LoadUpgradeData() { string folder = "upg"; //resource folder UpgradeData temp = new UpgradeData(); for (int i = 0; i < allUpgradeNames.Length; i++) //iterate through all { string curFile = allUpgradeNames[i] + ".dat"; //generate dat file name string imgpath = @"data\" + folder + @"\" + curFile; //generate full image path string[] lines = System.IO.File.ReadAllLines(imgpath); //read all the lines int index = 3; //start at index 3 to skip first 3 comment line basically //Load all data into data structure for easy readability Int32.TryParse(lines[index], out temp.armorImprovement[i]); index += 2; Int32.TryParse(lines[index], out temp.sightImprovement[i]); index += 2; Int32.TryParse(lines[index], out temp.speedImprovement[i]); index += 2; Int32.TryParse(lines[index], out temp.basicDamageImprovement[i]); index += 2; Int32.TryParse(lines[index], out temp.piercingDamageImprovement[i]); index += 2; Int32.TryParse(lines[index], out temp.rangeImprovement[i]); index += 2; Int32.TryParse(lines[index], out temp.goldCost[i]); index += 2; Int32.TryParse(lines[index], out temp.lumberCost[i]); index += 2; Int32.TryParse(lines[index], out temp.time[i]); index += 2; Int32.TryParse(lines[index], out temp.numberOfAssets[i]); index += 2; for (int j = 0; j < temp.numberOfAssets[i]; j++) //load list of capabilities { temp.assetNames[i].Add(lines[index]); //add to list index++; } } return(temp); }
static void initAssets() { //Load background for maplist menu //6=black, 1 = blue Bitmap backGroundImage = new Bitmap(@"data\img\Texture.png"); Color[] blueData = new Color[4]; Color[] blackData = new Color[4]; Color[] blackData2 = new Color[4]; for (int i = 0; i < 4; i++) { blueData[i] = color.GetPixel(i, 1); blackData[i] = color.GetPixel(i, 6); blackData2[i] = backGroundImage.GetPixel(i, 0); //using this actually shows that we can't change color, but it's not changing from black (so the provided colors.dat black pixels are wrong?) } //Iterate through all pixels and change black to blue for (int j = 0; j < backGroundImage.Height; j++) { for (int i = 0; i < backGroundImage.Width; i++) { if (backGroundImage.GetPixel(i, j) == blackData[0]) { backGroundImage.SetPixel(i, j, blueData[0]); } if (backGroundImage.GetPixel(i, j) == blackData[1]) { backGroundImage.SetPixel(i, j, blueData[1]); } if (backGroundImage.GetPixel(i, j) == blackData[2]) { backGroundImage.SetPixel(i, j, blueData[2]); } if (backGroundImage.GetPixel(i, j) == blackData[3]) { backGroundImage.SetPixel(i, j, blueData[3]); } } } mapListBG = backGroundImage; int numFiles = mapObject.mapNames.Length; //Asset stuff mapUnits = new AssetsOnMap(); //class to hold all loaded data PlayerAsset tempAsset = new PlayerAsset(); //the loader mapUnits.playerChoice = 1; //default as player1 (we can only play as that it seems) (set to nature = 0 for testing) mapUnits.numPlayer = new int[numFiles]; mapUnits.startGold = new int[numFiles][]; mapUnits.startLumber = new int[numFiles][]; mapUnits.mapAssets = new List <Asset> [numFiles][]; mapUnits.DLumber = new int[numFiles][]; for (int i = 0; i < numFiles; i++) { int mapY = mapObject.mapY[i]; int mapX = mapObject.mapX[i]; string[] curLines = mapObject.mapLines[i]; Tuple <List <Asset>[], int[], int[], int> tempRet = tempAsset.LoadAsset(curLines, mapY); mapUnits.mapAssets[i] = tempRet.Item1; mapUnits.startGold[i] = tempRet.Item2; mapUnits.startLumber[i] = tempRet.Item3; mapUnits.numPlayer[i] = tempRet.Item4; //mapObject.mapLines[i] = null; //free data? //init global lumber for all maps mapUnits.DLumber[i] = new int[(mapX + 1) * (mapY + 1)]; //same size as Dpartials or mapString for (int y = 0; y < mapY + 1; y++) { for (int x = 0; x < mapX + 1; x++) { if (mapObject.allMapStrings[i][y * (mapX + 1) + x] == "forest") {//is forest so set starting lumber of a tree at a spot to nature's lumber value (should be 400 by default) mapUnits.DLumber[i][y * (mapX + 1) + x] = mapUnits.startLumber[i][0]; } else { mapUnits.DLumber[i][y * (mapX + 1) + x] = 0; //no lumber as it's not forest tile } } } } Tuple <Bitmap[][], string[][], int[], int[]> tempUnit = tempAsset.LoadAssetTiles(); mapUnits.allUnitTiles = tempUnit.Item1; mapUnits.allUnitLines = tempUnit.Item2; mapUnits.allUnitTileW = tempUnit.Item3; mapUnits.allUnitTileH = tempUnit.Item4; mapUnits.decayTiles = tempAsset.LoadCorpse(); mapUnits.buildingDeathTiles = tempAsset.ScaleBuildingDeath(mapUnits.allUnitTiles, mapUnits.decayTiles); mapUnits.allProjectiles = tempAsset.LoadProjectiles(); unitData = tempAsset.LoadAssetData(); //load asset .dat unitUpgradeData = tempAsset.LoadUpgradeData(); //load upgrade .dat mapUnits.miniBevel = tempAsset.loadMiniBevel(); mapUnits.droppedResource = tempAsset.loadDroppedResource(); //free the inited temp stuff? initButtons(); }