示例#1
0
 /*
 ====================================================================
 Delete unit library.
 ====================================================================
 */
 public void unit_lib_delete()
 {
     int i;
     if (unit_lib != null) {
         unit_lib.Clear ();
         unit_lib = null;
     }
     if (trgt_types != null) {
         for (i = 0; i < trgt_type_count; i++) {
             if (!string.IsNullOrEmpty (trgt_types [i].id))
                 trgt_types [i].id = null;
             if (!string.IsNullOrEmpty (trgt_types [i].name))
                 trgt_types [i].name = null;
         }
         trgt_types = null;
         trgt_type_count = 0;
     }
     if (mov_types != null) {
         for (i = 0; i < mov_type_count; i++) {
             if (!string.IsNullOrEmpty (mov_types [i].id))
                 mov_types [i].id = null;
             if (!string.IsNullOrEmpty (mov_types [i].name))
                 mov_types [i].name = null;
     #if WITH_SOUND
     if ( mov_types[i].wav_move )
         wav_free( mov_types[i].wav_move );
     #endif
         }
         mov_types = null;
         mov_type_count = 0;
     }
     if (unit_classes != null) {
         for (i = 0; i < unit_class_count; i++) {
             if (!string.IsNullOrEmpty (unit_classes [i].id))
                 unit_classes [i].id = null;
             if (!string.IsNullOrEmpty (unit_classes [i].name))
                 unit_classes [i].name = null;
         }
         unit_classes = null;
         unit_class_count = 0;
     }
     if (unit_info_icons != null) {
         if (unit_info_icons.str != null)
             SDL_FreeSurface (unit_info_icons.str);
         if (unit_info_icons.atk != null)
             SDL_FreeSurface (unit_info_icons.atk);
         if (unit_info_icons.mov != null)
             SDL_FreeSurface (unit_info_icons.mov);
         if (unit_info_icons.guard != null)
             SDL_FreeSurface (unit_info_icons.guard);
         unit_info_icons = null;
     }
     unit_lib_main_loaded = false;
 }
示例#2
0
        public int UnitLibLoad(string fname)
        {
            string path = "Assets/Resources/DB/"+fname;
            try{
                XmlSerializer SerializerObj = new XmlSerializer(typeof(Unit_Lib_Entry));
                // Create a new file stream for reading the XML file
                FileStream ReadFileStream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read);
                // Load the object saved above by using the Deserialize function
                Unit_Lib_Entry LoadedObject = (Unit_Lib_Entry)SerializerObj.Deserialize(ReadFileStream);
                ReadFileStream.Close();
                this.ammo = LoadedObject.ammo;
                this.atks = LoadedObject.atks;
                this.atk_count = LoadedObject.atk_count;
                this.def_air = LoadedObject.def_air;
                this.def_cls = LoadedObject.def_cls;
                this.def_grnd = LoadedObject.def_grnd;
                this.end_year = LoadedObject.end_year;
                this.entr_rate = LoadedObject.entr_rate;
                this.eval_score = LoadedObject.eval_score;
                this.flags = LoadedObject.flags;
                this.fuel = LoadedObject.fuel;
                this.icon_img_name = LoadedObject.icon_img_name;
                this.icon_h = LoadedObject.icon_h;
                this.icon_tiny_img_name = LoadedObject.icon_tiny_img_name;
                this.icon_tiny_h = LoadedObject.icon_tiny_h;
                this.icon_tiny_w = LoadedObject.icon_tiny_w;
                this.icon_type = LoadedObject.icon_type;
                this.icon_w = LoadedObject.icon_w;
                this.id = LoadedObject.id;
                this.ini = LoadedObject.ini;
                this.mov = LoadedObject.mov;
                this.mov_type = LoadedObject.mov_type;
                this.mov_types = LoadedObject.mov_types;
                this.mov_type_count = LoadedObject.mov_type_count;
                this.name = LoadedObject.name;
                this.rng = LoadedObject.rng;
                this.spt = LoadedObject.spt;
                this.start_month = LoadedObject.start_month;
                this.start_year = LoadedObject.start_year;
                this.trgt_type = LoadedObject.trgt_type;
                this.trgt_types = LoadedObject.trgt_types;
                this.trgt_type_count = LoadedObject.trgt_type_count;
                this.unit_class = LoadedObject.unit_class;
                this.unit_classes = LoadedObject.unit_classes;
                this.unit_class_count = LoadedObject.unit_class_count;
                this.unit_info_icons = LoadedObject.unit_info_icons;
            #if TODO_RR
                this.unit_info_icons = new Unit_Info_Icons();
                this.unit_info_icons.atk_img_name = LoadedObject.unit_info_icons.atk_img_name;
                this.unit_info_icons.guard_img_name = LoadedObject.unit_info_icons.guard_img_name;
                this.unit_info_icons.mov_img_name = LoadedObject.unit_info_icons.mov_img_name;
                this.unit_info_icons.str_img_name = LoadedObject.unit_info_icons.str_img_name;
                this.unit_info_icons.str_h = LoadedObject.unit_info_icons.str_h;
                this.unit_info_icons.str_w = LoadedObject.unit_info_icons.str_w;
            #endif
                this.unit_lib = LoadedObject.unit_lib;
                this.unit_lib_main_loaded = true;
                this.offset_img = LoadedObject.offset_img;

                return 0;
            }catch(Exception ex){
                Debug.LogError("exception: "+ex.Message);
                return -1;
            }
        }