//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base function base.WriteXml(data); // Write all data: data.Write( "Texture" , m_texture_name ); data.Write( "StarCount" , m_star_count ); data.Write( "StarSize1" , m_star_size_1 ); data.Write( "StarSize2" , m_star_size_2 ); data.Write( "StarColor1R" , m_star_color_1.X ); data.Write( "StarColor1G" , m_star_color_1.Y ); data.Write( "StarColor1B" , m_star_color_1.Z ); data.Write( "StarColor1A" , m_star_color_1.W ); data.Write( "StarColor2R" , m_star_color_2.X ); data.Write( "StarColor2G" , m_star_color_2.Y ); data.Write( "StarColor2B" , m_star_color_2.Z ); data.Write( "StarColor2A" , m_star_color_2.W ); data.Write( "ParallaxScale" , m_parallax_scale ); }
public override void WriteXml(XmlObjectData data) { base.WriteXml(data); data.Write("DirectionX", m_direction.X); data.Write("DirectionY", m_direction.Y); data.Write("Force", m_power); data.Write("CharactersAffected", m_charactersAffected); data.Write("ProjectilesAffected", m_projectilesAffected); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base function base.WriteXml(data); // Write all attributes data.Write( "VelocityX" , m_velocity.X ); data.Write( "VelocityY" , m_velocity.Y ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Font" , m_font_name ); data.Write( "ScoreFadeInTime" , m_score_fade_in_time ); data.Write( "String1st" , m_string_1st ); data.Write( "String2nd" , m_string_2nd ); data.Write( "String3rd" , m_string_3rd ); data.Write( "NewHighScoreThrobTime" , m_new_high_score_throb_time ); data.Write( "NewHighScoreThrobExpansion" , m_new_high_score_throb_expansion ); data.Write( "NewHighScoreThrobColorR" , m_new_high_score_throb_color.X ); data.Write( "NewHighScoreThrobColorG" , m_new_high_score_throb_color.Y ); data.Write( "NewHighScoreThrobColorB" , m_new_high_score_throb_color.Z ); data.Write( "NewHighScoreThrobColorA" , m_new_high_score_throb_color.W ); }
//######################################################################################### /// <summary> /// Saves the high scores for each level in the game. /// </summary> /// <param name="folder"> /// Folder name containing the xml files holding the high scores. Each xml file corresponds to /// the high scores for one level and is named the same as the level file. /// </param> //######################################################################################### public static void Save( string folder ) { // This might fail: try { // Make sure the folder exists, if not then try and make it: DirectoryInfo dir = new DirectoryInfo( folder ); // Make it if doesn't exist: if ( dir.Exists == false ) dir.Create(); // Run through all the high scores in the list: Dictionary<string,HighScoreRecord>.Enumerator e = s_scores.GetEnumerator(); // Run through the list: while ( e.MoveNext() ) { // Make up the file: FileInfo file = new FileInfo( folder + "\\" + e.Current.Key ); // Ok: open a write stream Stream stream = file.Open( FileMode.Create , FileAccess.Write ); // Write to the file: try { // Makeup an xml data object: XmlObjectData data = new XmlObjectData(); // Write all high scores for this level to it: data.Write( "Score1" , e.Current.Value.Score1 ); data.Write( "Score2" , e.Current.Value.Score2 ); data.Write( "Score3" , e.Current.Value.Score3 ); data.Write( "Name1" , e.Current.Value.Name1 ); data.Write( "Name2" , e.Current.Value.Name2 ); data.Write( "Name3" , e.Current.Value.Name3 ); // Write the data to the stream: data.Save( stream ); // Close the stream: stream.Close(); } catch ( Exception ) { // Close the stream: try { stream.Close(); } catch ( Exception ){} // Try and delete the file, it may be corrupt: try { file.Delete(); } catch ( Exception ){} } } } // On windows debug display errors: #if WINDOWS_DEBUG catch ( Exception e ) { // Show what happened: DebugConsole.PrintException(e); // Clear high scores: s_scores.Clear(); } #else catch ( Exception ) { // Clear high scores: s_scores.Clear(); } #endif }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Font" , m_font_name ); data.Write( "Center" , m_center ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base function base.WriteXml(data); // Write all attributes data.Write( "Font" , m_font_name ); data.Write( "FloatSpeed" , m_float_speed ); data.Write( "ScoreLiveTime" , m_score_live_time ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "IconEffect" , m_icon_effect_name ); data.Write( "IconSize" , m_icon_size ); data.Write( "IconOffsetY" , m_icon_offset_y ); }
//======================================================================================== /// <summary> /// Writes the xml data in the editor table to the given object. /// </summary> /// <param name="obj"> Object to write the data to </param> //======================================================================================== private static void WriteXml( XmlObject obj ) { // Make an xml document: XmlDocument xml_doc = new XmlDocument(); // Make a new node to hold the data: XmlNode xml_node = xml_doc.CreateElement("data"); // Append to document: xml_doc.AppendChild(xml_node); // Initialise xml data object: XmlObjectData xml_data = new XmlObjectData(xml_node); // Run through the table: for ( int i = 0 ; i < s_fields.Length ; i++ ) { // Set this field in the xml data: xml_data.Write( s_fields[i].Text , s_values[i].Text ); } // Get the object to read this data: obj.ReadXml(xml_data); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Font" , m_font_name ); data.Write( "PhaseStringName" , m_phase_string_name ); data.Write( "ReadyStringName" , m_ready_string_name ); data.Write( "Center" , m_center ); data.Write( "FontEnlarge" , m_font_enlarge ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Font" , m_font_name ); data.Write( "StringName" , m_string_name ); // Write text alignment: if ( m_alignment == Alignment.LEFT ) { data.Write("Alignment" , "left" ); } else if ( m_alignment == Alignment.RIGHT ) { data.Write("Alignment" , "Right" ); } else { data.Write("Alignment" , "Center"); } }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Font" , m_font_name ); data.Write( "PictureSizeX" , m_picture_size.X ); data.Write( "PictureSizeY" , m_picture_size.Y ); data.Write( "StringOffsetY" , m_string_offset_y ); data.Write( "FadeTime" , m_fade_time ); data.Write( "DisplayTime" , m_display_time ); data.Write( "StoryPartCount" , m_story_part_count ); // Write all story part data: if ( m_story_part_count > 0 ) { // Read each part of the story: the string and texture for ( int i = 0 ; i < m_story_part_count ; i++ ) { // Story part texture data.Write( "StoryPicture" + (i+1).ToString(Locale.DevelopmentCulture.NumberFormat) , m_picture_names[i] ); // Story part string data.Write( "StoryString" + (i+1).ToString(Locale.DevelopmentCulture.NumberFormat) , m_story_strings[i] ); } } }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "GameLostString" , m_game_lost_string ); data.Write( "GameWonString" , m_game_won_string ); data.Write( "MessageFont" , m_message_font_name ); data.Write( "GameWonGui" , m_game_won_gui ); data.Write( "GameLostGui" , m_game_lost_gui ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Texture" , m_texture_name ); data.Write( "NormalMap" , m_normal_map_name ); data.Write( "Effect" , m_effect_name ); data.Write( "RepeatWidth" , m_repeat_width ); data.Write( "ParallaxMultiplier" , m_parallax_multiplier ); data.Write( "TextureOffsetX" , m_texture_offset_x ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Level" , m_level_name ); data.Write( "GameGui" , m_game_gui_name ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base function base.WriteXml(data); // Write all data: data.Write( "SpawnObjectType" , m_spawn_object_type ); data.Write( "MinimumPhase" , m_mininum_phase ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Effect" , m_effect_name ); data.Write( "StringWobbleEffect" , m_string_wobble_effect_name ); data.Write( "FillTexture" , m_fill_texture_name ); data.Write( "BarTexture" , m_bar_texture_name ); data.Write( "Font" , m_font_name ); data.Write( "StringName" , m_string_name ); data.Write( "StringOffsetY" , m_string_offset_y ); data.Write( "FillPaddingX" , m_fill_padding.X ); data.Write( "FillPaddingY" , m_fill_padding.Y ); data.Write( "MinimumValue" , m_minimum_value ); data.Write( "MaximumValue" , m_maximum_value ); data.Write( "CurrentValue" , m_current_value ); data.Write( "ChangeSpeed" , m_change_speed ); data.Write( "SizeX" , m_size.X ); data.Write( "SizeY" , m_size.Y ); data.Write( "ExpandTime" , m_expand_time ); data.Write( "ExpansionX" , m_expansion.X ); data.Write( "ExpansionY" , m_expansion.Y ); data.Write( "StringExpansion" , m_string_expansion ); data.Write( "HighlightWobbleSpeed" , m_highlight_wobble_speed ); data.Write( "HighlightWobbleIntensity" , m_highlight_wobble_intensity ); data.Write( "ValueChangedEvent" , m_value_changed_event ); data.Write( "BackEvent" , m_back_event ); data.Write( "FocusSound" , m_focus_sound ); data.Write( "UseSound" , m_use_sound ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "MusicCueName" , m_music_cue_name ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base function base.WriteXml(data); // Write all data: data.Write( "Phase1EnemyCount" , m_phase1_enemy_count ); data.Write( "Phase2EnemyCount" , m_phase2_enemy_count ); data.Write( "Phase3EnemyCount" , m_phase3_enemy_count ); data.Write( "Phase4EnemyCount" , m_phase4_enemy_count ); data.Write( "Phase5EnemyCount" , m_phase5_enemy_count ); data.Write( "Phase1SpawnInterval" , m_phase1_spawn_interval ); data.Write( "Phase2SpawnInterval" , m_phase2_spawn_interval ); data.Write( "Phase3SpawnInterval" , m_phase3_spawn_interval ); data.Write( "Phase4SpawnInterval" , m_phase4_spawn_interval ); data.Write( "Phase5SpawnInterval" , m_phase5_spawn_interval ); data.Write( "Phase1MaxActiveEnemies" , m_phase1_max_active_enemies ); data.Write( "Phase2MaxActiveEnemies" , m_phase2_max_active_enemies ); data.Write( "Phase3MaxActiveEnemies" , m_phase3_max_active_enemies ); data.Write( "Phase4MaxActiveEnemies" , m_phase4_max_active_enemies ); data.Write( "Phase5MaxActiveEnemies" , m_phase5_max_active_enemies ); data.Write( "CurrentPhaseEnemyKills" , m_current_phase_enemy_kills ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Texture" , m_texture_name ); data.Write( "Effect" , m_effect_name ); data.Write( "SizeX" , m_size.X ); data.Write( "SizeY" , m_size.Y ); data.Write( "FlipHorizontal" , m_flip_horizontal ); data.Write( "FlipVertical" , m_flip_vertical ); data.Write( "HorizontalRepeats" , m_horizontal_repeats ); data.Write( "VerticalRepeats" , m_vertical_repeats ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "FadeTime" , m_fade_time ); data.Write( "NextGui" , m_next_gui ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base function base.WriteXml(data); // Write all attributes data.Write( "Effect" , m_effect_name ); data.Write( "FadeInDistance" , m_fade_in_distance ); data.Write( "Rotation" , m_rotation ); data.Write( "ShroudColorR" , m_shroud_color.X ); data.Write( "ShroudColorG" , m_shroud_color.Y ); data.Write( "ShroudColorB" , m_shroud_color.Z ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Effect" , m_effect_name ); data.Write( "CloudTexture1" , m_cloud_texture_1_name ); data.Write( "CloudTexture2" , m_cloud_texture_2_name ); data.Write( "CloudCount" , m_cloud_count ); data.Write( "CloudScaleX_1" , m_cloud_x_scale_1 ); data.Write( "CloudScaleY_1" , m_cloud_y_scale_1 ); data.Write( "CloudScaleX_2" , m_cloud_x_scale_2 ); data.Write( "CloudScaleY_2" , m_cloud_y_scale_2 ); data.Write( "CloudOffsetY_1" , m_cloud_y_offset_1 ); data.Write( "CloudOffsetY_2" , m_cloud_y_offset_2 ); data.Write( "CloudSpeed_1" , m_cloud_speed_1 ); data.Write( "CloudSpeed_2" , m_cloud_speed_2 ); data.Write( "ParallaxMultiplier_1" , m_parallax_multiplier_1 ); data.Write( "ParallaxMultiplier_2" , m_parallax_multiplier_2 ); }
//========================================================================================= /// <summary> /// Attempts to save user preferences to the preferences xml file /// </summary> //========================================================================================= public static void SavePreferences() { // This might fail: try { // Get the current storage container: StorageContainer container = StorageSystem.Container; // Only do if we have a storage device: if ( container != null ) { // Try and get the preferences file: FileInfo file = new FileInfo( container.Path + "\\" + PREFERENCES_FILE ); // Create a new xml data object: XmlObjectData data = new XmlObjectData(); // Ok: write all attributes data.Write( "SoundVolume" , s_sound_volume ); data.Write( "MusicVolume" , s_music_volume ); data.Write( "Brightness" , s_brightness ); // Open an output stream: Stream output_stream = file.Open(FileMode.Create,FileAccess.Write); // Now save the data: try { // Save: data.Save( output_stream ); } // Show what happened on windows debug if something went wrong #if WINDOWS_DEBUG catch ( Exception e ){ DebugConsole.PrintException(e); } #else catch ( Exception ){} #endif // Close the output stream output_stream.Close(); } } // In windows debug show what happened if something went wrong: #if WINDOWS_DEBUG catch ( Exception e ){ DebugConsole.PrintException(e); } #else catch ( Exception ){} #endif }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base function base.WriteXml(data); // Write all object data: data.Write( "CollisionLinesXmlFile" , m_collision_lines_xml_file ); data.Write( "CollisionLineScaleX" , m_collision_line_scale.X ); data.Write( "CollisionLineScaleY" , m_collision_line_scale.Y ); data.Write( "ReverseCollisionNormals" , m_reverse_collision_normals ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function first base.WriteXml(data); // Write all data: data.Write( "TopTexture" , m_top_texture_name ); data.Write( "TopTextureNormalMap" , m_top_texture_normal_map_name ); data.Write( "MiddleTexture" , m_middle_texture_name ); data.Write( "MiddleTextureNormalMap" , m_middle_texture_normal_map_name ); data.Write( "Effect" , m_effect_name ); data.Write("TextureRepeatsX" , m_tex_repeats_x ); }
//========================================================================================= /// <summary> /// In this function each derived class should write its own data to /// the given XML node representing this object and its attributes. Base methods should /// also be called as part of this process. /// </summary> /// /// <param name="data"> /// An object representing the xml data for this XMLObject. Data values should be /// written to here. /// </param> //========================================================================================= public override void WriteXml( XmlObjectData data ) { // Call base class function base.WriteXml(data); // Write all data: data.Write( "Texture" , m_texture_name ); data.Write( "NormalMap" , m_normal_map_name ); data.Write( "Effect" , m_effect_name ); data.Write( "Rotation" , m_rotation ); data.Write( "HorizontalFlip" , m_horizontal_flip ); data.Write( "VerticalFlip" , m_vertical_flip ); }