internal void Write(Writer writer) { //Checks To Make Sure the Data Is Valid For Saving if (this.width > 255) { throw new Exception("Cannot save as Type v1. Width in tiles > 255"); } if (this.height > 255) { throw new Exception("Cannot save as Type v1. Height in tiles > 255"); } int num_of_objects = objects.Count; if (num_of_objects >= MaxObjectCount) { Console.WriteLine("Object Count > Max Objects!"); return; } // Write zone name writer.WriteRSDKString(Title); // Write the five "display" bytes writer.Write(ActiveLayer0); writer.Write(ActiveLayer1); writer.Write(ActiveLayer2); writer.Write(ActiveLayer3); writer.Write(Midpoint); // Write width and height writer.Write((byte)this.width); writer.Write((byte)this.height); // Write tile map for (int h = 0; h < this.height; h++) { for (int w = 0; w < this.width; w++) { writer.Write((byte)(MapLayout[h][w] >> 8)); writer.Write((byte)(MapLayout[h][w] & 0xff)); } } // Write number of object type names int num_of_objtype_names = this.objectTypeNames.Count; writer.Write((byte)(num_of_objtype_names)); // Write object type names // Ignore first object type "Type zero", it is not stored. for (int n = 0; n < num_of_objtype_names; n++) { writer.WriteRSDKString(objectTypeNames[n]); } // Write number of objects writer.Write((byte)(num_of_objects >> 8)); writer.Write((byte)(num_of_objects & 0xFF)); objects = objects.OrderBy(o => o.id).ToList(); // Write object data for (int n = 0; n < num_of_objects; n++) { Object obj = objects[n]; obj.Write(writer); } writer.Close(); }
internal void Write(Writer writer) { //Checks To make sure that the file can be saved correctly int num_of_objects = objects.Count; if (num_of_objects > 65535) { throw new Exception("Cannot save as Retro-Sonic map. Number of objects > 65535"); } for (int n = 0; n < num_of_objects; n++) { Object obj = objects[n]; int obj_type = obj.getType(); int obj_subtype = obj.getSubtype(); int obj_xPos = obj.getXPos(); int obj_yPos = obj.getYPos(); if (obj_type > 255) { throw new Exception("Cannot save as Retro-Sonic map. Object type > 255"); } if (obj_subtype > 255) { throw new Exception("Cannot save as Retro-Sonic map. Object subtype > 255"); } if (obj_xPos < -32768 || obj_xPos > 32767) { throw new Exception("Cannot save as Retro-Sonic. Object X Position can't fit in 16-bits"); } if (obj_yPos < -32768 || obj_yPos > 32767) { throw new Exception("Cannot save as Retro-Sonic. Object Y Position can't fit in 16-bits"); } } // Save zone name writer.WriteRSDKString(Title); // Write the Stage Init Data writer.Write(Music); writer.Write(Background); writer.Write((byte)(PlayerXpos >> 8)); writer.Write((byte)(PlayerXpos & 0xFF)); writer.Write((byte)(PlayerYPos >> 8)); writer.Write((byte)(PlayerYPos & 0xFF)); // Write number of objects writer.Write((byte)(num_of_objects >> 8)); writer.Write((byte)(num_of_objects & 0xFF)); // Write object data for (int n = 0; n < num_of_objects; n++) { Object obj = objects[n]; int obj_type = obj.type; int obj_subtype = obj.subtype; int obj_xPos = obj.xPos; int obj_yPos = obj.yPos; writer.Write((byte)obj_type); writer.Write((byte)obj_subtype); writer.Write((byte)(obj_xPos >> 8)); writer.Write((byte)(obj_xPos & 0xFF)); writer.Write((byte)(obj_yPos >> 8)); writer.Write((byte)(obj_yPos & 0xFF)); } writer.Close(); }
internal void Write(Writer writer) { //Checks To make sure that the file can be saved correctly if (width >= 256) { throw new Exception("Cannot save as Retro-Sonic map. Level width in tiles > 255."); } if (height >= 256) { throw new Exception("Cannot save as Retro-Sonic map. Level height in tiles > 255."); } int num_of_objects = objects.Count; if (num_of_objects > 65535) { throw new Exception("Cannot save as Retro-Sonic map. Number of objects > 65535"); } for (int n = 0; n < num_of_objects; n++) { Object obj = objects[n]; int obj_type = obj.getType(); int obj_subtype = obj.getSubtype(); int obj_xPos = obj.getXPos(); int obj_yPos = obj.getYPos(); if (obj_type > 255) { throw new Exception("Cannot save as Retro-Sonic map. Object type > 255"); } if (obj_subtype > 255) { throw new Exception("Cannot save as Retro-Sonic map. Object subtype > 255"); } if (obj_xPos < -32768 || obj_xPos > 32767) { throw new Exception("Cannot save as Retro-Sonic. Object X Position can't fit in 16-bits"); } if (obj_yPos < -32768 || obj_yPos > 32767) { throw new Exception("Cannot save as Retro-Sonic. Object Y Position can't fit in 16-bits"); } } // Separate path components String dirname = Path.GetDirectoryName(writer.GetFilename()); String basename = "\\" + Path.GetFileNameWithoutExtension(writer.GetFilename()); String itmPath = dirname + basename + ".itm"; // Create item file Writer ITMwriter = new Writer(itmPath); // Save width and height writer.Write((byte)width); writer.Write((byte)height); // Save map data for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { writer.Write((byte)MapLayout[y][x]); } } // Close map file writer.Close(); // Save zone name ITMwriter.WriteRSDKString(Title); // Write the Stage Init Data ITMwriter.Write(Music); ITMwriter.Write(Background); ITMwriter.Write((byte)(PlayerXpos >> 8)); ITMwriter.Write((byte)(PlayerXpos & 0xFF)); ITMwriter.Write((byte)(PlayerYPos >> 8)); ITMwriter.Write((byte)(PlayerYPos & 0xFF)); // Write number of objects ITMwriter.Write((byte)(num_of_objects >> 8)); ITMwriter.Write((byte)(num_of_objects & 0xFF)); // Write object data for (int n = 0; n < num_of_objects; n++) { Object obj = objects[n]; int obj_type = obj.type; int obj_subtype = obj.subtype; int obj_xPos = obj.xPos; int obj_yPos = obj.yPos; ITMwriter.Write((byte)obj_type); ITMwriter.Write((byte)obj_subtype); ITMwriter.Write((byte)(obj_xPos >> 8)); ITMwriter.Write((byte)(obj_xPos & 0xFF)); ITMwriter.Write((byte)(obj_yPos >> 8)); ITMwriter.Write((byte)(obj_yPos & 0xFF)); } ITMwriter.Close(); }
public void Write(Writer writer) { writer.WriteRSDKString(PlayerAnimLocation); writer.WriteRSDKString(PlayerScriptLocation); writer.WriteRSDKString(PlayerName); }
public void Write(Writer writer) { writer.WriteRSDKString(Name); writer.Write(Value); }
internal void Write(Writer writer) { writer.WriteRSDKString(Name); }