public static Fruit Load(BinaryReader reader) { Fruit fruit = new Fruit(); fruit.unknown = reader.ReadBytes(3); fruit._ID = reader.ReadByte(); fruit.unknown2 = reader.ReadBytes(64); fruit.fruitType = IndexResolver.Load(reader, fruitType_LENGTH); fruit.unknown3 = reader.ReadBytes(13); return(fruit); }
/// <summary> /// Creates a fruit with the ID and type specified /// /// If the third parameter is specified and not set to FruitType.NONE, random selection using a range is created /// </summary> /// <param name="ID">ID of the fruit</param> /// <param name="fruitType">Type the fruit should be</param> /// <param name="fruitTypeRangeEnd">If not FruitType.NONE, the fruit will be a runtime-random fruit ranging from `fruitType` (inclusive) to `fruitTypeRangeEnd` (inclusive)</param> /// TODO MH: Replace fruit range with fruit array (via '.' instead of '~' public Fruit(byte ID, FruitType fruitType, FruitType fruitTypeRangeEnd) { if (fruitTypeRangeEnd != (FruitType)(-1)) { this.fruitType = new IndexResolver((int)fruitType, (int)fruitTypeRangeEnd, (byte)'~'); } else { this.fruitType = new IndexResolver((int)fruitType); } this._ID = ID; this.unknown = new byte[] { 0x00, 0x00, 0x00 }; this.unknown2 = new byte[] { 0x4E, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x7E, 0x39, 0x39, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; this.unknown3 = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; }
public static Stage Load(BinaryReader reader) { Stage level = new Stage(); level.tutorialText1 = reader.ReadBytes(2); level.tutorialText2 = reader.ReadBytes(2); level.tutorialTextbuffer = reader.ReadBytes(2); level.unknownCP = reader.ReadBytes(2); level.unknownPostCP = reader.ReadBytes(3); level._ID = reader.ReadByte(); if (level._ID == 0) { level._ID = 99; } else { --level._ID; } level.backgroundID = IndexResolver.Load(reader, backgroundID_LENGTH); level.notDoor = IndexResolver.Load(reader, notDoor_LENGTH); level.teleportIndices = IndexResolver.Load(reader, teleportIndices_LENGTH); foreach (byte key in HOLE_DEFINITION_KEYS) { level.holeDefinitions.Add(key, (NintendoLand.TileTypes.Hole.Size)reader.ReadByte()); reader.ReadBytes(holeDefinitions_LENGTH - 1); } for (int contentFlagIndex = 0; contentFlagIndex < MAXIMUM_CONTENT_FLAGS; contentFlagIndex++) { level.contentFlags.Add((ContentFlag)reader.ReadByte()); bool isDone = reader.ReadByte() != 0x20; if (isDone) { contentFlagIndex++; for (int i = contentFlagIndex; i < MAXIMUM_CONTENT_FLAGS; i++) { reader.ReadBytes(contentFlag_LENGTH); } break; } } for (int switchOrPepperIndex = 0; switchOrPepperIndex < SWITCHORPEPPER_DEFINITIONS; switchOrPepperIndex++) { level.switchOrPepperDefinitions[switchOrPepperIndex] = (PepperOrSwitchFlag)reader.ReadByte(); // < SWITCHORPEPPER_DEFINITIONS * (1 byte (value) + 7 bytes (padding)) reader.ReadBytes(switchOrPepperDefinitions_LENGTH - 1); } for (int patternIndex = 0; patternIndex < MOVEMENTPATTERN_DEFINITIONS; patternIndex++) { level.movementPatterns[patternIndex] = IndexResolver.Load(reader, movementPattern_LENGTH); } for (int FDefinitionIndex = 0; FDefinitionIndex < FRUIT_ORDER_DEFINITIONS; FDefinitionIndex++) // < FRUIT_ORDER_DEFINITIONS * (1 or 2 bytes (value) + 10 or 11 bytes (padding)) { // related to fruit order? actual usage unknown level.orderedFruitDefinition[FDefinitionIndex] = IndexResolver.Load(reader, orderedFruitDefinition_LENGTH); } for (int fruitAssociationIndex = 0; fruitAssociationIndex < FRUIT_ASSOCIATIONS_DEFINITIONS; fruitAssociationIndex++) // < FRUIT_ASSOCIATIONS_DEFINITIONS * (2 bytes (min) + 1 byte (delimiter) + 2 bytes (max)) + 7 bytes (padding)) { // related to fruit order? actual usage unknown level.fruitAssociations[fruitAssociationIndex] = IndexResolver.Load(reader, fruitAssociations_LENGTH); } return(level); }