コード例 #1
0
        protected void add_generic_unit(Vector2 loc, int team, string identifier, string[] data_ary)
        {
            Game_Actor actor = Global.game_actors.new_actor();

            actor.name     = data_ary[0].Split('|')[0];
            actor.class_id = Convert.ToInt32(data_ary[1].Split('|')[0]); //Debug
            actor.gender   = Convert.ToInt32(data_ary[2].Split('|')[0]);
            actor.level_down();
            actor.exp = 0;

            int level             = Convert.ToInt32(data_ary[3].Split('|')[0]);
            int exp               = Convert.ToInt32(data_ary[4].Split('|')[0]);
            int prepromote_levels = Convert.ToInt32(data_ary[6].Split('|')[0]);
            int build             = Convert.ToInt32(data_ary[7].Split('|')[0]);
            int con               = Convert.ToInt32(data_ary[8].Split('|')[0]);

            // If units were created with NUM_ITEMS = 6,
            // and then NUM_ITEMS was changed to 4 or 5, things would break
            // Come up with a longterm solution//Yeti
            List <Item_Data> items = new List <Item_Data>();

            for (int item_index = 0; item_index < Global.ActorConfig.NumItems; item_index++)
            {
                string[] item_ary = data_ary[11 + item_index].Split('|')[0].Split(new string[] { ", " }, StringSplitOptions.None);
                items.Add(new Item_Data(Convert.ToInt32(item_ary[0]),
                                        Convert.ToInt32(item_ary[1]), Convert.ToInt32(item_ary[2])));
            }
            actor.set_items(items);

            int index_after_items = 11 + Global.ActorConfig.NumItems;

            string[] wexp_ary = data_ary[index_after_items + 0]
                                .Split('|')[0].Split(new string[] { ", " }, StringSplitOptions.None);
            int[] wexp = Enumerable.Range(0, Global.weapon_types.Count - 1)
                         .Select(x => x < wexp_ary.Length ? Convert.ToInt32(wexp_ary[x]) : 0)
                         .ToArray();

            actor.setup_generic(
                Convert.ToInt32(data_ary[1].Split('|')[0]), level, exp,
                prepromote_levels, (Generic_Builds)build, con, wexp: wexp);

            if (team <= 0)
            {
                team = Convert.ToInt32(data_ary[5].Split('|')[0]);
            }
            int priority = Convert.ToInt32(data_ary[9].Split('|')[0]);
            int mission  = Convert.ToInt32(data_ary[10].Split('|')[0]);

            new_unit_id();
            var new_unit = Objects.add_unit(
                new Game_Unit(Last_Added_Unit_Id, loc, team, priority, actor.id), identifier, mission);
        }