public void BuildStorage(List <Box> boxes, int numFrames) { storageBox = new Storage.CollisionBox(); storageBox.boxIds = new int[numFrames]; Box searchBox; int boxIndex; for (int i = 0; i < numFrames; ++i) { searchBox = i < boxesPerFrame.Count ? boxesPerFrame[i] : null; if (searchBox == null || !enabledFrames[i]) { storageBox.boxIds[i] = Box.invalidBoxId; } else { boxIndex = boxes.FindIndex(x => x.IsEqual(searchBox)); if (boxIndex < 0) { boxIndex = boxes.Count; boxes.Add(searchBox); } storageBox.boxIds[i] = boxIndex; } } }
public static CollisionBox LoadFromStorage(Storage.CollisionBox storageBox, Storage.Character storageCharacter) { CollisionBox newBox = new CollisionBox(); int[] boxIds = storageBox.boxIds; if (boxIds != null && boxIds.Length > 0) { // Populate boxes newBox.boxesPerFrame = new List <Box>(boxIds.Length); newBox.enabledFrames = new List <bool>(boxIds.Length); foreach (int boxId in storageBox.boxIds) { if (boxId == Box.invalidBoxId) { newBox.enabledFrames.Add(false); newBox.boxesPerFrame.Add(new Box()); } else { newBox.enabledFrames.Add(true); newBox.boxesPerFrame.Add(Box.LoadFromStorage(storageCharacter.boxes[boxId])); } } } return(newBox); }
public Storage.CollisionBox SaveToStorage() { Storage.CollisionBox ret = storageBox; storageBox = null; return(ret); }