public static void Initialize() { objectName = new List<string>(); objectInfo = new List<string>(); parts = new List<Part[][]>(); StreamReader reader = new StreamReader(TitleContainer.OpenStream(levelPath)); string name = reader.ReadLine(); while (name != null) { objectName.Add(name); objectInfo.Add(reader.ReadLine()); int frameCount = int.Parse(reader.ReadLine()); Part[][] curObjectParts = new Part[frameCount][]; for (int curFrame = 0; curFrame < frameCount; curFrame++) { int numParts = int.Parse(reader.ReadLine()); curObjectParts[curFrame] = new Part[numParts]; for (int curPart = 0; curPart < numParts; curPart++) { string partType = reader.ReadLine(); string[] boundingRectangleInfo = reader.ReadLine().Split(' '); Rectangle boundingRectangle = new Rectangle(int.Parse(boundingRectangleInfo[0]), int.Parse(boundingRectangleInfo[1]), int.Parse(boundingRectangleInfo[2]), int.Parse(boundingRectangleInfo[3])); if (partType == "bouncy") { curObjectParts[curFrame][curPart] = new BouncyPart(boundingRectangle); } else if (partType == "damaging") { curObjectParts[curFrame][curPart] = new DamagingPart(boundingRectangle); } else if (partType == "passable") { curObjectParts[curFrame][curPart] = new PassablePart(boundingRectangle); } else if (partType == "platform") { curObjectParts[curFrame][curPart] = new PlatformPart(boundingRectangle); } else if (partType == "solid") { curObjectParts[curFrame][curPart] = new SolidPart(boundingRectangle); } } } parts.Add(curObjectParts); name = reader.ReadLine(); } reader.Close(); }
/// <summary> /// Creates a copy of the part. /// </summary> public override Part Clone() { Part clone = new DamagingPart(BoundingRectangle); return clone; }