//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml( XmlObjectData data ) { // Call base class function base.ReadXml(data); // Read all data: data.ReadTexture( "TopTexture" , ref m_top_texture_name , ref m_top_texture , "Graphics\\default" ); data.ReadTexture( "TopTextureNormalMap" , ref m_top_texture_normal_map_name , ref m_top_texture_normal_map , "Graphics\\default" ); data.ReadTexture( "MiddleTexture" , ref m_middle_texture_name , ref m_middle_texture , "Graphics\\default" ); data.ReadTexture( "MiddleTextureNormalMap" , ref m_middle_texture_normal_map_name , ref m_middle_texture_normal_map , "Graphics\\default" ); data.ReadEffect ( "Effect" , ref m_effect_name , ref m_effect , "Effects\\default" ); data.ReadFloat("TextureRepeatsX" , ref m_tex_repeats_x ); // Get height of the top texture: int top_tex_h = 0; if ( m_top_texture != null ) { top_tex_h = m_top_texture.Height; } // Create the line representing the plane of the ground: where the top texture ends m_line = new Line ( PositionX - BoxDimensionsX , PositionY + BoxDimensionsY - top_tex_h , PositionX + BoxDimensionsX , PositionY + BoxDimensionsY - top_tex_h ); }
//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml( XmlObjectData data ) { // Call base class function base.ReadXml(data); // Read all data: data.ReadTexture( "Texture" , ref m_texture_name , ref m_texture , "Graphics\\default" ); data.ReadEffect ( "Effect" , ref m_effect_name , ref m_effect , "Effects\\textured" ); data.ReadFloat ( "SizeX" , ref m_size.X , 256 ); data.ReadFloat ( "SizeY" , ref m_size.Y , 256 ); data.ReadBool ( "FlipHorizontal" , ref m_flip_horizontal , false ); data.ReadBool ( "FlipVertical" , ref m_flip_vertical , false ); data.ReadFloat ( "HorizontalRepeats" , ref m_horizontal_repeats , 1 ); data.ReadFloat ( "VerticalRepeats" , ref m_vertical_repeats , 1 ); }
//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml( XmlObjectData data ) { // Call base function base.ReadXml(data); // Read all attributes data.ReadEffect ( "Effect" , ref m_effect_name , ref m_effect , "Effects\\colored" ); data.ReadFloat ( "FadeInDistance" , ref m_fade_in_distance , 64 ); data.ReadFloat ( "Rotation" , ref m_rotation , 0 ); data.ReadFloat ( "ShroudColorR" , ref m_shroud_color.X , 0 ); data.ReadFloat ( "ShroudColorG" , ref m_shroud_color.Y , 0 ); data.ReadFloat ( "ShroudColorB" , ref m_shroud_color.Z , 0 ); // Setup our vertices: // Color m_vertices[0].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[1].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 0 ) ); m_vertices[2].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 0 ) ); m_vertices[3].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 0 ) ); m_vertices[4].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[5].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[6].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[7].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[8].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[9].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[10].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); m_vertices[11].Color = new Color( new Vector4( m_shroud_color.X , m_shroud_color.Y , m_shroud_color.Z , 1 ) ); // Position: m_vertices[0].Position = new Vector3( Position , 0 ) + new Vector3( - m_fade_in_distance , +100000 , -2 ); m_vertices[1].Position = new Vector3( Position , 0 ) + new Vector3( 0 , +100000 , -2 ); m_vertices[2].Position = new Vector3( Position , 0 ) + new Vector3( 0 , -100000 , -2 ); m_vertices[3].Position = new Vector3( Position , 0 ) + new Vector3( 0 , -100000 , -2 ); m_vertices[4].Position = new Vector3( Position , 0 ) + new Vector3( - m_fade_in_distance , -100000 , -2 ); m_vertices[5].Position = new Vector3( Position , 0 ) + new Vector3( - m_fade_in_distance , +100000 , -2 ); m_vertices[6].Position = new Vector3( Position , 0 ) + new Vector3( - 100000 , +100000 , -2 ); m_vertices[7].Position = new Vector3( Position , 0 ) + new Vector3( - m_fade_in_distance , +100000 , -2 ); m_vertices[8].Position = new Vector3( Position , 0 ) + new Vector3( - m_fade_in_distance , -100000 , -2 ); m_vertices[9].Position = new Vector3( Position , 0 ) + new Vector3( - m_fade_in_distance , -100000 , -2 ); m_vertices[10].Position = new Vector3( Position , 0 ) + new Vector3( - 100000 , -100000 , -2 ); m_vertices[11].Position = new Vector3( Position , 0 ) + new Vector3( - 100000 , +100000 , -2 ); // Rotation: // Create rotation matrix: Matrix rot = Matrix.CreateRotationZ( m_rotation ); // Do the rotation: for ( int i = 0 ; i < m_vertices.Length ; i++ ) { // Rotate about position: m_vertices[i].Position = Vector3.Transform( m_vertices[i].Position - new Vector3( Position , 0 ), rot ); // Restore world position: m_vertices[i].Position = m_vertices[i].Position + new Vector3( Position , 0 ); } }
//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml( XmlObjectData data ) { // Call base class function base.ReadXml(data); // Read all data: data.ReadEffect( "IconEffect" , ref m_icon_effect_name , ref m_icon_effect , "Effects\\textured" ); data.ReadFloat( "IconSize" , ref m_icon_size , 32 ); data.ReadFloat( "IconOffsetY" , ref m_icon_offset_y , 0 ); // Generate the portions that we will render CreatePortions(); }
//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml(XmlObjectData data) { // Call base class function base.ReadXml(data); // Read all data: data.ReadTexture( "Texture" , ref m_texture_name , ref m_texture , "Graphics\\default" ); data.ReadTexture( "NormalMap" , ref m_normal_map_name , ref m_normal_map , "Graphics\\default" ); data.ReadEffect ( "Effect" , ref m_effect_name , ref m_effect , "Effects\\textured" ); data.ReadFloat( "RepeatWidth" , ref m_repeat_width , 32 ); data.ReadFloat( "ParallaxMultiplier" , ref m_parallax_multiplier , 0 ); data.ReadFloat( "TextureOffsetX" , ref m_texture_offset_x , 0 ); // Setup vertices for rendering: Setup(); }
//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml(XmlObjectData data) { // Call base class function base.ReadXml(data); // Read all data: data.ReadEffect ( "Effect" , ref m_effect_name , ref m_effect , "Effects\\textured" ); data.ReadTexture( "CloudTexture1" , ref m_cloud_texture_1_name , ref m_cloud_texture_1 , "Graphics\\default" ); data.ReadTexture( "CloudTexture2" , ref m_cloud_texture_2_name , ref m_cloud_texture_2 , "Graphics\\default" ); data.ReadInt ( "CloudCount" , ref m_cloud_count , 16 ); data.ReadFloat ( "CloudScaleX_1" , ref m_cloud_x_scale_1 , 1 ); data.ReadFloat ( "CloudScaleY_1" , ref m_cloud_y_scale_1 , 1 ); data.ReadFloat ( "CloudScaleX_2" , ref m_cloud_x_scale_2 , 1 ); data.ReadFloat ( "CloudScaleY_2" , ref m_cloud_y_scale_2 , 1 ); data.ReadFloat ( "CloudOffsetY_1" , ref m_cloud_y_offset_1 , 0 ); data.ReadFloat ( "CloudOffsetY_2" , ref m_cloud_y_offset_2 , 0 ); data.ReadFloat ( "CloudSpeed_1" , ref m_cloud_speed_1 , 0.5f ); data.ReadFloat ( "CloudSpeed_2" , ref m_cloud_speed_2 , 0.5f ); data.ReadFloat ( "ParallaxMultiplier_1" , ref m_parallax_multiplier_1 , 0.25f ); data.ReadFloat ( "ParallaxMultiplier_2" , ref m_parallax_multiplier_2 , 0.25f ); // Create all the clouds: CreateClouds(); }
//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml( XmlObjectData data ) { // Call base class function base.ReadXml(data); // Read all data: data.ReadEffect ( "Effect" , ref m_effect_name , ref m_effect , "Effects\\textured" ); data.ReadEffect ( "StringWobbleEffect" , ref m_string_wobble_effect_name , ref m_string_wobble_effect , "Effects\\textured" ); data.ReadTexture( "FillTexture" , ref m_fill_texture_name , ref m_fill_texture , "Graphics\\default" ); data.ReadTexture( "BarTexture" , ref m_bar_texture_name , ref m_bar_texture , "Graphics\\default" ); data.ReadString ( "Font" , ref m_font_name , "Content\\Fonts\\Game_16px.xml" ); data.ReadString ( "StringName" , ref m_string_name , "No_String" ); data.ReadFloat ( "StringOffsetY" , ref m_string_offset_y , 32 ); data.ReadFloat ( "FillPaddingX" , ref m_fill_padding.X , 0 ); data.ReadFloat ( "FillPaddingY" , ref m_fill_padding.Y , 0 ); data.ReadFloat ( "MinimumValue" , ref m_minimum_value , 0.0f ); data.ReadFloat ( "MaximumValue" , ref m_maximum_value , 1.0f ); data.ReadFloat ( "CurrentValue" , ref m_current_value , 0.5f ); data.ReadFloat ( "ChangeSpeed" , ref m_change_speed , 1.0f ); data.ReadFloat ( "SizeX" , ref m_size.X , 128 ); data.ReadFloat ( "SizeY" , ref m_size.Y , 32 ); data.ReadFloat ( "ExpandTime" , ref m_expand_time , 1 ); data.ReadFloat ( "ExpansionX" , ref m_expansion.X , 16 ); data.ReadFloat ( "ExpansionY" , ref m_expansion.Y , 4 ); data.ReadFloat ( "StringExpansion" , ref m_string_expansion , 0 ); data.ReadFloat ( "HighlightWobbleSpeed" , ref m_highlight_wobble_speed , 0.01f ); data.ReadFloat ( "HighlightWobbleIntensity" , ref m_highlight_wobble_intensity , 8 ); data.ReadString ( "ValueChangedEvent" , ref m_value_changed_event , "" ); data.ReadString ( "BackEvent" , ref m_back_event , "" ); data.ReadString ( "FocusSound" , ref m_focus_sound , "" ); data.ReadString ( "UseSound" , ref m_use_sound , "" ); // If the minimum value is bigger the max then swap: if ( m_minimum_value > m_maximum_value ) { float t = m_minimum_value; m_minimum_value = m_maximum_value; m_maximum_value = t; } // Fill in the color and texture coordinates of the vertices for rendering: m_vertices[0].Color = Color.White; m_vertices[1].Color = Color.White; m_vertices[2].Color = Color.White; m_vertices[3].Color = Color.White; m_vertices[4].Color = Color.White; m_vertices[5].Color = Color.White; m_vertices[0].TextureCoordinate = Vector2.Zero; m_vertices[1].TextureCoordinate = Vector2.UnitY; m_vertices[2].TextureCoordinate = Vector2.UnitX; m_vertices[3].TextureCoordinate = Vector2.One; m_vertices[4].TextureCoordinate = Vector2.Zero; m_vertices[5].TextureCoordinate = Vector2.UnitY; // Read in font: m_font = new Font(m_font_name); }
//========================================================================================= /// <summary> /// In this function each derived class should read its own data from /// 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 /// read from here. /// </param> //========================================================================================= public override void ReadXml(XmlObjectData data) { // Call base class function base.ReadXml(data); // Read all data: data.ReadTexture( "Texture" , ref m_texture_name , ref m_texture , "Graphics\\default" ); data.ReadTexture( "NormalMap" , ref m_normal_map_name , ref m_normal_map , "Graphics\\default" ); data.ReadEffect ( "Effect" , ref m_effect_name , ref m_effect , "Effects\\textured" ); data.ReadFloat( "Rotation" , ref m_rotation , 0 ); data.ReadBool ( "HorizontalFlip" , ref m_horizontal_flip , false ); data.ReadBool ( "VerticalFlip" , ref m_vertical_flip , false ); }