示例#1
0
        public void save_resource_linked_list( SharedResourceLinkedList<GameObject> objects, String filename )
        {
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Indent = true;

            using ( XmlWriter writer = XmlWriter.Create( filename, settings ) ) {

                IntermediateSerializer.Serialize( writer, objects, null );

            }
        }
示例#2
0
        // Creates the world, sets the ninja
        public void create_world( GameWorld g_world, string filename )
        {
            Ninja ninja = new Ninja();
            DeathPitController deathcontrol = new DeathPitController( g_world, 120 );
            XML_Manager xml_guy = new XML_Manager();
            g_world.curr_filename = filename;
            m_objects = xml_guy.load_resource_linked_list( filename );
            foreach ( GameObject g_obj in m_objects ) {
                g_obj.m_world = g_world;

                g_obj.add_to_world();   //Handles whether to load GameObjects if they have been destroyed
                if ( g_obj.m_is_dead ) {

                }
                if ( g_obj is FloorTile ) {
                    g_obj.remove_from_world();
                }

                if ( g_obj is Ninja ) {
                    m_ninja = (Ninja)g_obj;
                    NinjaController n_control = new NinjaController( g_obj.m_world, (Ninja)g_obj );
                    m_ninja_controller = n_control;
                    g_obj.m_world.m_world.AddController( n_control );
                    g_obj.m_body.Awake = true;
                    g_obj.m_body.Enabled = true;

                    //Makes sure to update target
                    foreach ( Controller control in m_world.ControllerList ) {
                        if ( control is AlienController ) {
                            AlienController alien_control = (AlienController)control;
                            alien_control.m_target = m_ninja;
                        }
                    }
                }
                else if ( g_obj is Alien ) {
                    Alien alien = (Alien)g_obj;
                    alien.set_textures();
                    alien.m_ai_type_change = alien.m_ai_type;
                    m_enemy_count++;
                }
                else if ( g_obj is DeathTouch && !( g_obj is MovingDeath ) ) {
                    deathcontrol.addPit( (DeathTouch)g_obj );
                }
                else if ( g_obj is ConditionTriggered ) {
                    ConditionTriggered ob = (ConditionTriggered)g_obj;
                    Color color;
                    switch ( ob.m_condition_type ) {
                        case ConditionTriggered.ConditionType.DEATH:
                            color = Color.CornflowerBlue;
                            break;
                        case ConditionTriggered.ConditionType.NINJA_HAS_ITEM:
                            color = Color.OrangeRed;
                            break;
                        default:
                            color = Color.White;
                            break;

                    }
                    foreach ( TriggerableObject to in ob.m_attached_to )
                        to.m_tint = color;

                }

            }

            g_world.m_world.AddController( deathcontrol );
        }