示例#1
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.ReadString( "MusicCueName" , ref m_music_cue_name , "" );
        }
示例#2
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 function

            base.ReadXml(data);

            // Read all data:

            data.ReadString ( "SpawnObjectType"  , ref m_spawn_object_type   , "EnemyNinja" );
            data.ReadInt    ( "MinimumPhase"     , ref m_mininum_phase       , 0            );

            // Clamp the minimum phase from 0-2:

            if ( m_mininum_phase < 0 ) m_mininum_phase = 0;
            if ( m_mininum_phase > 2 ) m_mininum_phase = 2;
        }
示例#3
0
        //=========================================================================================
        /// <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    );
        }
示例#4
0
        //=========================================================================================
        /// <summary>
        /// Debug console command. Attempts to clone an object with the given id and opens up 
        /// the xml editor on it.
        /// </summary>
        /// <param name="type"> Argument given from the console by user. Object to clone and edit. </param>
        //=========================================================================================
        public static void Con_GClone( int object_id  )
        {
            // See if the object exists in the current gui:

                GuiWidget clone_obj = Core.Gui.Search.FindById(object_id);

                if ( clone_obj == null )
                {
                    DebugConsole.Print("\nGClone: given object id does not exist in current Gui ! "); return;
                }

                // Try and make a new copy of the object we found:

                try
                {
                    // Make it:

                    XmlObject xml_obj = XmlFactory.CreateObject( clone_obj.GetType().Name );

                    // Attempt to cast to a gui widget:

                    GuiWidget widget_obj = (GuiWidget)(xml_obj);

                    // Add it to the current gui:

                    Core.Gui.Data.Add(widget_obj);

                    // Create an xml document with a root data node:

                    XmlDocument xml_doc = new XmlDocument(); XmlNode xml_node = xml_doc.CreateElement("data");

                    xml_doc.AppendChild(xml_node);

                    // Create an xml data object:

                    XmlObjectData xml_data = new XmlObjectData(xml_node);

                    // Read the data from the object we are cloning:

                    try
                    {
                        clone_obj.WriteXml(xml_data);
                    }
                    catch ( Exception e ){ DebugConsole.PrintException(e); }

                    // Write the data to the object we are creating:

                    try
                    {
                        widget_obj.ReadXml(xml_data);
                    }
                    catch ( Exception e ){ DebugConsole.PrintException(e); }

                    // Open up the editor on it:

                    try
                    {
                        XmlObjectEditor.EditObject(widget_obj,"Editing gui widget with ID '" + widget_obj.Id + "' of type " + widget_obj.GetType().Name);
                    }
                    catch ( Exception e ){ DebugConsole.PrintException(e); }

                }
                catch ( Exception e ){ DebugConsole.PrintException(e); }
        }
示例#5
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.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 class function

            base.ReadXml(data);

            // Read font:

            data.ReadString ( "Font" , ref m_font_name , "Content\\Fonts\\Game_16px.xml" );

            // Read all other data

            data.ReadString ( "String1st"                   , ref m_string_1st                      , "no_string"   );
            data.ReadString ( "String2nd"                   , ref m_string_2nd                      , "no_string"   );
            data.ReadString ( "String3rd"                   , ref m_string_3rd                      , "no_string"   );
            data.ReadFloat  ( "ScoreFadeInTime"             , ref m_score_fade_in_time              , 0.25f         );
            data.ReadFloat  ( "NewHighScoreThrobTime"       , ref m_new_high_score_throb_time       , 0.25f         );
            data.ReadFloat  ( "NewHighScoreThrobExpansion"  , ref m_new_high_score_throb_expansion  , 8             );
            data.ReadFloat  ( "NewHighScoreThrobColorR"     , ref m_new_high_score_throb_color.X    , 1             );
            data.ReadFloat  ( "NewHighScoreThrobColorG"     , ref m_new_high_score_throb_color.Y    , 1             );
            data.ReadFloat  ( "NewHighScoreThrobColorB"     , ref m_new_high_score_throb_color.Z    , 1             );
            data.ReadFloat  ( "NewHighScoreThrobColorA"     , ref m_new_high_score_throb_color.W    , 1             );

            // Create font:

            m_font = new Font(m_font_name);

            // Reset this

            m_time_since_creation = 0;
        }
示例#7
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.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
            );
        }
示例#8
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 function

            base.ReadXml(data);

            // Read all attributes

            data.ReadFloat( "VelocityX" , ref m_velocity.X , 0 );
            data.ReadFloat( "VelocityY" , ref m_velocity.Y , 0 );
        }
示例#9
0
        //=========================================================================================
        /// <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
        }
示例#10
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);

            data.ReadString ( "Font"    , ref m_font_name   , "Content\\Fonts\\Game_16px.xml"   );
            data.ReadBool   ( "Center"  , ref m_center      , false                             );

            // Read in font:

            m_font = new Font(m_font_name);
        }
示例#11
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 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 );
                    }
        }
示例#12
0
        //=========================================================================================
        /// <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    );
        }
示例#13
0
        //=========================================================================================
        /// <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       );
        }
示例#14
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.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();
        }
示例#15
0
        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);
        }
示例#16
0
        public override void ReadXml(XmlObjectData data)
        {
            base.ReadXml(data);

            data.ReadFloat("DirectionX", ref m_direction.X);

            data.ReadFloat("DirectionY", ref m_direction.Y);

            data.ReadFloat("Force", ref m_power);

            data.ReadBool("CharactersAffected", ref m_charactersAffected);

            data.ReadBool("ProjectilesAffected", ref m_projectilesAffected);

            m_box.X = (int)PositionX;

            m_box.Y = (int)PositionY;

            m_box.Width = (int)BoxDimensionsX;

            m_box.Height = (int)BoxDimensionsY;
        }
示例#17
0
        //=========================================================================================
        /// <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   );
        }
示例#18
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 the base class function first:

            base.ReadXml(data);

            // Read the collision lines file name:

            data.ReadString( "CollisionLinesXmlFile" , ref m_collision_lines_xml_file , "Content\\CollisionLines\\default.xml" );

            // Read the scaling for the collision lines:

            data.ReadFloat( "CollisionLineScaleX" , ref m_collision_line_scale.X , 1 );
            data.ReadFloat( "CollisionLineScaleY" , ref m_collision_line_scale.Y , 1 );

            // Read this:

            data.ReadBool( "ReverseCollisionNormals" , ref m_reverse_collision_normals , false );

            // Load collision lines:

            ReadXmlCollisionLines();
        }
示例#19
0
        //=========================================================================================
        /// <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      );
        }
示例#20
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();
        }
示例#21
0
        //=========================================================================================
        /// <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    );
        }
示例#22
0
        //=========================================================================================
        /// <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       );
        }
示例#23
0
        //=========================================================================================
        /// <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 );
        }
示例#24
0
        //=========================================================================================
        /// <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 );
        }
示例#25
0
        //=========================================================================================
        /// <summary>
        /// Attempts to load user preferences from the preferences xml file
        /// </summary>        
        //=========================================================================================
        public static void LoadPreferences()
        {
            // If we already loaded preferences then abort:

            if ( s_loaded_preferences == true ) return;

            // This might fail:

            try
            {
                // Get current storage container

                StorageContainer container = StorageSystem.Container;

                // See if we got a storage container:

                if ( container != null )
                {
                    // Set the loaded preferences flag to true:

                    s_loaded_preferences = true;

                    // Try and get the preferences file:

                    FileInfo file = new FileInfo( container.Path + "\\" + PREFERENCES_FILE );

                    // If it doesn't exist then abort:

                    if ( file.Exists == false ) return;

                    // Open an input stream:

                    Stream input_stream = file.Open(FileMode.Open);

                    // Create a new xml data object:

                    XmlObjectData data = null;

                    // Try and read the xml:

                    try { data = new XmlObjectData( input_stream ); } catch ( Exception ){}

                    // Close the input stream:

                    input_stream.Close();

                    // Ok: try and read the attributes:

                    float sound_volume  = 0.75f;
                    float music_volume  = 0.65f;
                    float brightness    = 1.0f;

                    data.ReadFloat( "SoundVolume"   , ref sound_volume  );
                    data.ReadFloat( "MusicVolume"   , ref music_volume  );
                    data.ReadFloat( "Brightness"    , ref brightness    );

                    // Now set them:

                    SoundVolume = sound_volume;
                    MusicVolume = music_volume;
                    Brightness  = brightness;
                }

            }

            // In windows debug show what happened if something went wrong:

            #if WINDOWS_DEBUG

                catch ( Exception e ){ DebugConsole.PrintException(e); }

            #else

                catch ( Exception ){}

            #endif
        }
示例#26
0
        //#########################################################################################
        /// <summary>
        /// Reads 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 Load( string folder )
        {
            // We have read high scores from a file now:

            s_read_high_scores = true;

            // Clear high scores:

            s_scores.Clear();

            // This might fail:

            try
            {
                // Try and open the given directory:

                DirectoryInfo dir = new DirectoryInfo(folder);

                // Only do if it exists:

                if ( dir.Exists )
                {
                    // Cool: get a list of files in the dir

                    FileInfo[] files = dir.GetFiles( "*.xml" );

                    // Run through the list of files:

                    foreach ( FileInfo file in files )
                    {
                        // Make an IO stream:

                        Stream stream = file.Open(FileMode.Open,FileAccess.Read);

                        // Attempt to read its data:

                        XmlObjectData data = new XmlObjectData(stream);

                        // Make up a new high score record

                        HighScoreRecord h;

                        h.Score1 = 0;
                        h.Score2 = 0;
                        h.Score3 = 0;

                        h.Name1 = "";
                        h.Name2 = "";
                        h.Name3 = "";

                        // If any high score is negative then zero it:

                        if ( h.Score1 < 0 ) h.Score1 = 0;
                        if ( h.Score2 < 0 ) h.Score2 = 0;
                        if ( h.Score3 < 0 ) h.Score3 = 0;

                        // Attempt to read all three scores

                        data.ReadFloat( "Score1" , ref h.Score1 );
                        data.ReadFloat( "Score2" , ref h.Score2 );
                        data.ReadFloat( "Score3" , ref h.Score3 );

                        // Load user names:

                        data.ReadString( "Name1" , ref h.Name1 );
                        data.ReadString( "Name2" , ref h.Name2 );
                        data.ReadString( "Name3" , ref h.Name3 );

                        // Trim the names:

                        h.Name1 = h.Name1.Trim();
                        h.Name2 = h.Name2.Trim();
                        h.Name3 = h.Name3.Trim();

                        // If no user name given then use the '-' monkier

                        if ( h.Name1.Length <= 0 ) h.Name1 = "-";
                        if ( h.Name2.Length <= 0 ) h.Name2 = "-";
                        if ( h.Name3.Length <= 0 ) h.Name3 = "-";

                        // Ensure names are within limits:

                        if ( h.Name1.Length > User.MAX_USER_NAME_LENGTH ) h.Name1 = h.Name1.Substring( 0 , User.MAX_USER_NAME_LENGTH );
                        if ( h.Name2.Length > User.MAX_USER_NAME_LENGTH ) h.Name2 = h.Name2.Substring( 0 , User.MAX_USER_NAME_LENGTH );
                        if ( h.Name3.Length > User.MAX_USER_NAME_LENGTH ) h.Name3 = h.Name3.Substring( 0 , User.MAX_USER_NAME_LENGTH );

                        // Sort the scores if not in order:

                        if ( h.Score3 > h.Score2 ){ float t = h.Score3; h.Score3 = h.Score2; h.Score2 = t; }
                        if ( h.Score2 > h.Score1 ){ float t = h.Score2; h.Score2 = h.Score1; h.Score1 = t; }
                        if ( h.Score3 > h.Score2 ){ float t = h.Score3; h.Score3 = h.Score2; h.Score2 = t; }

                        // Save the high scores record:

                        s_scores[ file.Name.ToLower() ] = h;
                    }
                }
            }

            // 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( "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    );
        }
示例#28
0
        //#########################################################################################
        /// <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
        }
示例#29
0
        //=========================================================================================
        /// <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 );
        }
示例#30
0
        //=========================================================================================
        /// <summary>
        /// Debug console command. Attempts to create an object of the given type and 
        /// opens up the editor on it.
        /// </summary>
        /// <param name="type"> Argument given from the console by user. Type of object to make. </param>
        //=========================================================================================
        public static void Con_GNew( string type )
        {
            // Abort if no name given:

                if ( type.Length == 0 ) DebugConsole.Print("\nGNew: Must give a valid type of gui widget object to create.");

                // Try and make the given object:

                try
                {
                    // Make it:

                    XmlObject xml_obj = XmlFactory.CreateObject(type);

                    // See if that failed:

                    if ( xml_obj == null )
                    {
                        DebugConsole.Print("\nGNew: Not a valid GuiWidget sub-type."); return;
                    }

                    // Attempt to cast to a gui widget:

                    GuiWidget widget_obj = (GuiWidget)(xml_obj);

                    // See if that failed:

                    if ( widget_obj == null )
                    {
                        DebugConsole.Print("\nGNew: Not a valid GuiWidget sub-type."); return;
                    }

                    // Add it to the current gui:

                    Core.Gui.Data.Add(widget_obj);

                    // Make a blank xml document:

                    XmlDocument doc = new XmlDocument(); doc.AppendChild( doc.CreateElement("data") );

                    // Make an xml object data object:

                    XmlObjectData data = new XmlObjectData(doc.FirstChild);

                    // Do a fake read and allow the object to initialise some default values:

                    widget_obj.ReadXml(data);

                    // Open up the editor on it:

                    try
                    {
                        XmlObjectEditor.EditObject(widget_obj,"Editing gui widget with ID '" + widget_obj.Id + "' of type " + widget_obj.GetType().Name );
                    }
                    catch ( Exception e ){ DebugConsole.PrintException(e); }

                }
                catch ( Exception e ){ DebugConsole.PrintException(e); }
        }