PLAYPAL ReadColorPalette(string filePath, string name) { PLAYPAL pal = new PLAYPAL(); foreach (DrctEntry entry in newWad.directory) { if (entry.name.Contains(name)) { //we can assume this is the entry we are looking for byte[] temp = new byte[768]; wadOpener.Position = entry.filepos; //set the location to the beginning of a column wadOpener.Read(temp, 0, temp.Length); //fill columnBytes with bytes for the column //Debug.Log("Name: " + entry.name); //Debug.Log("Size: " + entry.size); //Debug.Log("Position: " + entry.filepos); for (int i = 0; i < 768; i += 3) { pal.colors.Add(new Color32(temp[i], temp[i + 1], temp[i + 2], 255)); } } } return(pal); }
private void Awake() { wadFilePath = Application.dataPath + "/DOOM2.wad"; wadOpener = new FileStream(wadFilePath, FileMode.Open, FileAccess.Read); ReadWADHeader(); ReadWADDirectory(); playPal = ReadColorPalette(wadFilePath, "PLAYPAL"); ReadWADPatches(); ReadWADTextures(); ReadWADFlats(); ReadWADSprites(); ReadMAPEntries(); ReadWADSounds(); ReadWADUISprites(); CreateFonts(); isDone = true; }