示例#1
0
 void reset_mission()
 {
     m_die_poses.Clear();
     m_arrays.Clear();
     m_map_data          = new protocol.map.map_data1();
     m_map_data.mode     = 0;
     m_map_data.time     = 300;
     m_map_data.no_music = 0;
     m_map_data.end_area = 0;
     for (int i = 0; i < 3; ++i)
     {
         m_die_poses.Add(new List <mario_point>());
         m_arrays.Add(new List <List <s_t_mission_sub> >());
     }
 }
示例#2
0
    public bool load_mission(int id, byte[] mapdata, List <int> x, List <int> y)
    {
        m_map_id = id;
        reset_mission();
        if (x != null)
        {
            for (int i = 0; i < x.Count; ++i)
            {
                int cha = x[i] / 10000000;
                m_die_poses[cha].Add(new mario_point(x[i], y[i]));
            }
        }
        if (mapdata.Length == 0)
        {
            new_mission();
        }
        else
        {
            try
            {
                byte[] arr = utils.Decompress(mapdata);
                protocol.map.map_data     tmp = net_http._instance.parse_packet <protocol.map.map_data> (arr);
                protocol.map.map_data_sub sub = new protocol.map.map_data_sub();
                sub.array           = tmp.array;
                sub.x_num           = tmp.x_num;
                sub.y_num           = tmp.y_num;
                sub.qd_y            = tmp.qd_y;
                sub.zd_y            = tmp.zd_y;
                sub.map_theme       = tmp.map_theme;
                m_map_data.map_ver  = tmp.map_ver;
                m_map_data.mode     = tmp.mode;
                m_map_data.time     = tmp.time;
                m_map_data.no_music = tmp.no_music;
                m_map_data.end_area = 0;
                m_map_data.maps.Add(sub);
            }
            catch (System.Exception)
            {
                try
                {
                    byte[] arr = utils.Decompress(mapdata);
                    m_map_data = net_http._instance.parse_packet <protocol.map.map_data1> (arr);
                }
                catch (System.Exception)
                {
                    mario._instance.show_tip(get_language_string("game_data_dtjx"));
                    new_mission();
                    return(false);
                }
            }

            try
            {
                if (m_map_data.map_ver > m_self_map_ver)
                {
                    mario._instance.show_tip(get_language_string("game_data_dtbb"));
                    new_mission();
                    return(false);
                }
                for (int m = 0; m < 3; ++m)
                {
                    if (m >= m_map_data.maps.Count)
                    {
                        new_world(m);
                        continue;
                    }
                    MemoryStream ms = new MemoryStream(m_map_data.maps[m].array);
                    byte[]       b  = new byte[4];
                    for (int j = 0; j < m_map_data.maps[m].y_num; ++j)
                    {
                        List <s_t_mission_sub> subs = new List <s_t_mission_sub>();
                        for (int i = 0; i < m_map_data.maps[m].x_num; ++i)
                        {
                            s_t_mission_sub sub = new s_t_mission_sub();
                            ms.Read(b, 0, b.Length);
                            sub.type = System.BitConverter.ToInt32(b, 0);
                            if (sub.type != 0)
                            {
                                for (int k = 0; k < 4; ++k)
                                {
                                    ms.Read(b, 0, b.Length);
                                    sub.param[k] = System.BitConverter.ToInt32(b, 0);
                                }
                            }
                            s_t_unit t_unit = get_t_unit(sub.type);
                            if (t_unit != null)
                            {
                                if (mario._instance.m_self.m_review == 1 && t_unit.review == 1)
                                {
                                    sub.type = 0;
                                }
                            }
                            subs.Add(sub);
                        }
                        m_arrays[m].Add(subs);
                    }
                }
            }
            catch (System.Exception)
            {
                mario._instance.show_tip(get_language_string("game_data_dtjx"));
                new_mission();
                return(false);
            }
        }
        return(true);
    }