Beispiel #1
0
        public static Condition load_Condition(Save_tag path)
        {
            Condition e = null;
            Save_tag  a = path.copy();

            a.add_tag("ID");
            long     ID = load_long(a);
            Save_tag b  = path.copy();

            b.add_tag("text");
            string   text = load_string(b);
            Save_tag c    = path.copy();

            c.add_tag("params");
            List <float> ps = load_list_of_floats(c);

            if (ID == 1)
            {
                e = new Empty_Condition();
            }
            else if (ID == 2)
            {
                e = new Cumulative_condition((int)ps[1], (int)ps[0]);
            }
            else if (ID == 3)
            {
                e = new Player_have_in_inventory((long)ps[0], ps[1]);
            }
            return(e);
        }
Beispiel #2
0
        public static void save_Condition(Save_tag path, Condition c)
        {
            Save_tag a = path.copy();

            a.add_tag("ID");
            save_long(a, c.get_ID());
            List <float> parameters = new List <float>();
            Save_tag     e          = path.copy();

            e.add_tag("text");
            save_string(e, c.get_info());
            Save_tag b = path.copy();

            b.add_tag("params");
            if (c.get_ID() == 1)
            {
                parameters.Add(0.0f);
            }
            else if (c.get_ID() == 2)
            {
                Cumulative_condition cc = (Cumulative_condition)c;
                parameters.Add(cc.get_counter());
                parameters.Add(cc.max_count);
            }
            else if (c.get_ID() == 3)
            {
                Player_have_in_inventory phii = (Player_have_in_inventory)c;
                parameters.Add(phii.item_ID);
                parameters.Add(phii.count);
            }
            save_list_of_floats(b, parameters);
        }