示例#1
0
 public void Change(string func, KeyBinding newbinding)
 {
     foreach (DataStructure child in keydata.AllChildren)
     {
         if (child.Contains <ushort>(func))
         {
             if (newbinding.act_code.Length == 1)
             {
                 child.Set(func, newbinding.keyids [0]);
             }
             else
             {
                 child.short_integers_arr.Remove(func);
                 child.short_integers.Add(func, newbinding.keyids [0]);
             }
             return;
         }
         if (child.Contains <ushort []>(func))
         {
             if (newbinding.act_code.Length == 1)
             {
                 child.short_integers.Remove(func);
                 child.short_integers_arr.Add(func, newbinding.keyids);
             }
             else
             {
                 child.Set(func, newbinding.keyids);
             }
             return;
         }
     }
     DeveloppmentTools.LogFormat("Keybinding \"{0}\" not found", func);
 }
示例#2
0
 /// <summary>
 ///		Returns the current binding of a certain funtion
 /// </summary>
 public KeyBinding GetByFunction(string function)
 {
     foreach (KeyBinding binding in AllBindings)
     {
         if (binding.function == function)
         {
             return(binding);
         }
     }
     DeveloppmentTools.LogFormat("No such key function exists: \"{0}\"", function);
     return(KeyBinding.None);
 }
示例#3
0
    /// <summary> Checks if certain items of certain types are in the data </summary>
    /// <param name="item_array"></param>
    /// <returns> True if all items are contained </returns>
    public bool Check4Items(System.Type[] types, string[] names)
    {
        bool present = true;

        for (int i = 0; i < Mathf.Min(types.Length, names.Length); i++)
        {
            if (!data.Contains(names[i], types[i]))
            {
                DeveloppmentTools.LogFormat("\"{0}\" not found", names [i]);
                present = false;
            }
        }
        return(present);
    }
示例#4
0
    public static void Save()
    {
        GeneralExecution general = SceneGlobals.general;

        System.DateTime t0 = System.DateTime.Now;
        DataStructure   save_datastructure = new DataStructure();

        DataStructure general_information = new DataStructure("GeneralInformation", save_datastructure);

        general_information.Set("original_path", general.battle_path);
        general_information.Set("in level progress", (int)general.mission_core.in_level_progress);
        general_information.Set("in stage progress", (int)general.mission_core.in_stage_progress);

        ReferenceSystem ref_sys = SceneGlobals.ReferenceSystem;

        if (ref_sys.HasParent)
        {
            general_information.Set("RS offset", ref_sys.Offset);
            general_information.Set("RS parent", ref_sys.ref_obj.ID);
        }
        else
        {
            general_information.Set("RS position", ref_sys.Position);
        }

        SceneObject[]       scene_array     = new SceneObject[SceneObject.TotObjectList.Count];
        Explosion[]         explosion_array = new Explosion[SceneGlobals.explosion_collection.Count];
        Bullet[]            bullet_array    = new Bullet[SceneGlobals.bullet_collection.Count];
        DestroyableTarget[] target_array    = new DestroyableTarget[SceneGlobals.destroyables.Count];

        SceneObject.TotObjectList.Values.CopyTo(scene_array, 0);
        SceneGlobals.bullet_collection.CopyTo(bullet_array);
        SceneGlobals.destroyables.CopyTo(target_array);

        scene_array = System.Array.FindAll(scene_array,
                                           x =>
                                           !(x is Missile && !(x as Missile).Released) &&
                                           !(x is Network && (x as Network).Name == "\"friendly rogue\"-Network" | (x as Network).Name == "\"hostile rogue\"-Network") &&
                                           !(x is Target)
                                           );

        ISavable[] savable_objects = new ISavable[scene_array.Length +
                                                  explosion_array.Length +
                                                  bullet_array.Length +
                                                  target_array.Length];

        int indx = 0;

        System.Array.ConvertAll(scene_array, x => x as ISavable).CopyTo(savable_objects, indx);
        indx += scene_array.Length;
        System.Array.ConvertAll(explosion_array, x => x as ISavable).CopyTo(savable_objects, indx);
        indx += explosion_array.Length;
        System.Array.ConvertAll(bullet_array, x => x as ISavable).CopyTo(savable_objects, indx);
        indx += bullet_array.Length;
        System.Array.ConvertAll(target_array, x => x as ISavable).CopyTo(savable_objects, indx);

        DataStructure object_states = new DataStructure("ObjectStates", save_datastructure);

        foreach (ISavable obj in savable_objects)
        {
            if (obj != null)
            {
                DataStructure ds = new DataStructure(obj.Name, object_states);
                obj.Save(ds);
            }
        }

        //save_datastructure.Save("saved/Saves/" + System.DateTime.Now.ToString("dd_MM_yyyy_hh_mm_ss"));
        save_datastructure.Save("saved/Saves/def_save");
        DeveloppmentTools.LogFormat("Saved: {0} ms", (System.DateTime.Now - t0).Milliseconds.ToString());
    }