コード例 #1
0
ファイル: game_data.cs プロジェクト: dqchess/mario
 void new_world(int index)
 {
     m_die_poses[index].Clear();
     m_arrays[index].Clear();
     protocol.map.map_data_sub mdsub = new protocol.map.map_data_sub();
     mdsub.x_num     = 20;
     mdsub.y_num     = 10;
     mdsub.qd_y      = 2;
     mdsub.zd_y      = 2;
     mdsub.map_theme = Random.Range(1, 5);
     m_map_data.maps.Add(mdsub);
     for (int i = 0; i < mdsub.y_num; ++i)
     {
         List <s_t_mission_sub> arr = new List <s_t_mission_sub>();
         for (int j = 0; j < mdsub.x_num; ++j)
         {
             s_t_mission_sub sub = new s_t_mission_sub();
             if (i < 2)
             {
                 sub.type = 1;
             }
             else
             {
                 sub.type = 0;
             }
             arr.Add(sub);
         }
         m_arrays[index].Add(arr);
     }
     m_arrays[index][2][1].type  = 1000;
     m_arrays[index][2][18].type = 1001;
 }
コード例 #2
0
ファイル: game_data.cs プロジェクト: dqchess/mario
    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);
    }