Example #1
0
    void dingchu()
    {
        m_hit       = true;
        m_is_static = true;
        m_has_floor = true;
        m_is_dzd    = 2;
        m_fxdiv     = 2;
        m_bkcf      = true;

        if (m_param[0] == 0)
        {
            play_anim("hit1");
            mario._instance.play_sound("sound/coins");
        }
        else
        {
            s_t_unit t_unit = game_data._instance.get_t_unit(m_param[0]);
            play_anim("hit");
            mario._instance.play_sound("sound/dinfo");
            List <int> p = new List <int>();
            p.Add(m_param[1]);
            p.Add(m_param[2]);
            p.Add(m_param[3]);
            p.Add(0);
            mario_obj obj1 = play_mode._instance.create_mario_obj(t_unit.res, null, p, m_init_pos.x, m_init_pos.y);
            obj1.set_bl(0, 1);
        }
        this.transform.FindChild("sprite").GetComponent <SpriteRenderer>().sortingOrder = 1;
    }
Example #2
0
 public void change_row(int row)
 {
     if ((row - 1) * 8 >= game_data._instance.m_unit_num)
     {
         return;
     }
     m_row = row;
     m_row_num.GetComponent <UILabel>().text = (row + 1).ToString();
     for (int i = 0; i < 8; ++i)
     {
         s_t_unit t_unit = game_data._instance.get_t_unit_by_site(m_row * 8 + i);
         if (t_unit == null)
         {
             m_row_icons[i].GetComponent <UISprite>().spriteName = "";
         }
         else if (t_unit.kfg == 1)
         {
             m_row_icons[i].GetComponent <UISprite>().spriteName = t_unit.icon + "_" + game_data._instance.m_map_data.maps[m_world].map_theme.ToString();
         }
         else
         {
             m_row_icons[i].GetComponent <UISprite>().spriteName = t_unit.icon;
         }
     }
 }
Example #3
0
 public override void reset()
 {
     mario._instance.remove_child(m_s);
     if (m_shadow != null)
     {
         mario._instance.remove_child(m_shadow.GetComponent <mario_wenhao>().m_s);
     }
     m_edit_obj = null;
     if (m_param[0] != 0 && m_edit_mode)
     {
         s_t_unit   t_unit = game_data._instance.get_t_unit(m_param[0]);
         string     cname  = "unit/" + t_unit.res + "/" + t_unit.res;
         GameObject res    = (GameObject)Resources.Load(cname);
         m_edit_obj = (GameObject)Instantiate(res);
         m_edit_obj.transform.parent     = m_s.transform;
         m_edit_obj.transform.localScale = new Vector3(1, 1, 1);
         mario_obj mobj = m_edit_obj.GetComponent <mario_obj> ();
         mobj.m_edit_mode = true;
         List <int> p = new List <int>();
         p.Add(m_param[1]);
         p.Add(m_param[2]);
         p.Add(m_param[3]);
         p.Add(0);
         mobj.init(t_unit.res, p, m_world, -1, -1, 0, 0);
     }
 }
Example #4
0
 void dingchu()
 {
     if (m_param[0] == 0)
     {
     }
     else
     {
         while (m_objs.Count < 3)
         {
             m_objs.Add(null);
         }
         int index = -1;
         for (int i = 0; i < m_objs.Count; ++i)
         {
             if (m_objs[i] == null)
             {
                 index = i;
                 break;
             }
         }
         if (index == -1)
         {
             return;
         }
         s_t_unit   t_unit = game_data._instance.get_t_unit(m_param[0]);
         List <int> p      = new List <int>();
         p.Add(m_param[1]);
         p.Add(m_param[2]);
         p.Add(m_param[3]);
         p.Add(0);
         mario_obj obj1 = play_mode._instance.create_mario_obj(t_unit.res, null, p, m_init_pos.x, m_init_pos.y);
         m_objs[index] = obj1.gameObject;
     }
 }
Example #5
0
    public virtual void init(string name, List <int> param, int world, int x, int y, int xx, int yy)
    {
        m_name       = name;
        m_param      = param;
        m_collider   = this.GetComponent <mario_collider> ();
        m_animator   = this.GetComponent <Animator>();
        m_mario_anim = this.GetComponent <mario_anim>();
        if (m_mario_anim != null)
        {
            if (m_mario_anim.do_defualt())
            {
                if (m_animator != null)
                {
                    m_animator.enabled = false;
                }
            }
            else
            {
                m_mario_anim.enabled = false;
            }
        }
        m_pos.set(xx, yy);
        reset_bound();
        record_per();
        set_pos();
        m_world = world;
        m_init_pos.set(x, y);
        reset();

        if (x != -1)
        {
            if (x > 0)
            {
                int type = game_data._instance.m_arrays[m_world][y][x - 1].type;
                if (type != 0)
                {
                    s_t_unit t_unit = game_data._instance.get_t_unit(type);
                    if (t_unit.is_static == 1)
                    {
                        m_nleft = true;
                    }
                }
            }
            if (x < game_data._instance.m_map_data.maps[m_world].x_num - 1)
            {
                int type = game_data._instance.m_arrays[m_world][y][x + 1].type;
                if (type != 0)
                {
                    s_t_unit t_unit = game_data._instance.get_t_unit(type);
                    if (t_unit.is_static == 1)
                    {
                        m_nright = true;
                    }
                }
            }
        }
    }
Example #6
0
    void reset_icon(bool is_change = false)
    {
        if (is_change)
        {
            change_row(0);
        }
        else
        {
            change_row(m_row);
        }
        int num = (game_data._instance.m_unit_num + 7) / 8;

        mario._instance.remove_child(m_tool_view);
        for (int i = 0; i < num; ++i)
        {
            GameObject obj = (GameObject)Instantiate(m_tool_sub);
            obj.name                    = (i + 1).ToString();
            obj.transform.parent        = m_tool_view.transform;
            obj.transform.localPosition = new Vector3(0, 170 - 80 * i, 0);
            obj.transform.localScale    = new Vector3(1, 1, 1);
            obj.SetActive(true);
            obj.transform.FindChild("row").FindChild("Label").GetComponent <UILabel>().text = (i + 1).ToString();
            for (int j = 1; j <= 8; ++j)
            {
                int      index  = i * 8 + j;
                s_t_unit t_unit = game_data._instance.get_t_unit_by_site(index - 1);
                if (t_unit == null)
                {
                    obj.transform.FindChild(j.ToString()).FindChild("icon").GetComponent <UISprite>().spriteName = "";
                }
                else if (t_unit.kfg == 1)
                {
                    obj.transform.FindChild(j.ToString()).FindChild("icon").GetComponent <UISprite>().spriteName = t_unit.icon + "_" + game_data._instance.m_map_data.maps[m_world].map_theme.ToString();
                }
                else
                {
                    obj.transform.FindChild(j.ToString()).FindChild("icon").GetComponent <UISprite>().spriteName = t_unit.icon;
                }
            }
        }
        if (m_world != game_data._instance.m_map_data.end_area)
        {
            m_ending.SetActive(true);
        }
        else
        {
            m_ending.SetActive(false);
        }
    }
Example #7
0
    public void select(GameObject obj)
    {
        int      index1 = int.Parse(obj.name);
        int      index  = m_row * 8 + index1;
        s_t_unit t_unit = game_data._instance.get_t_unit_by_site(index - 1);

        if (t_unit == null)
        {
            return;
        }
        m_index = index1;
        m_select.transform.localPosition = obj.transform.localPosition;
        m_select.SetActive(true);
        m_select1.SetActive(false);
    }
Example #8
0
    public void select_xuan(GameObject obj)
    {
        int      index1 = int.Parse(obj.name);
        int      index2 = int.Parse(obj.transform.parent.name);
        int      index  = (index2 - 1) * 8 + index1;
        s_t_unit t_unit = game_data._instance.get_t_unit_by_site(index - 1);

        if (t_unit == null)
        {
            return;
        }
        m_index = index1;
        m_select.transform.localPosition = m_selects[m_index - 1].transform.localPosition;
        m_select.SetActive(true);
        m_select1.SetActive(false);

        m_tool_xuan.SetActive(false);
        change_row(index2 - 1);
        m_flag = true;
    }
Example #9
0
 void hit1()
 {
     if (m_hit)
     {
         return;
     }
     m_hit  = true;
     m_bkcf = true;
     {
         s_t_unit t_unit = game_data._instance.get_t_unit(m_param[0]);
         play_anim("hit");
         mario._instance.play_sound("sound/dinfo");
         List <int> p = new List <int>();
         p.Add(m_param[1]);
         p.Add(m_param[2]);
         p.Add(m_param[3]);
         p.Add(0);
         mario_obj obj1 = play_mode._instance.create_mario_obj(t_unit.res, null, p, m_init_pos.x, m_init_pos.y);
         obj1.set_bl(0, 1);
     }
     this.transform.FindChild("sprite").GetComponent <SpriteRenderer>().sortingOrder = 1;
 }
Example #10
0
    void Update()
    {
        if (m_start)
        {
            return;
        }
        if (edit_mode._instance == null || edit_mode._instance.m_main_char == null)
        {
            return;
        }
        if (m_joy.IsHolding)
        {
            m_ts1.SetActive(false);
            return;
        }
#if !UNITY_IPHONE && !UNITY_ANDROID
        if (mario._instance.key_down(KeyCode.LeftArrow) || mario._instance.key_down(KeyCode.RightArrow) || mario._instance.key_down(KeyCode.Z))
        {
            m_sm_panel.SetActive(false);
        }
#endif
        if (mario._instance.get_mouse_button())
        {
            if (mario._instance.m_self.guide == 2)
            {
                mario._instance.show_tip(game_data._instance.get_language_string("edit_gui_djsw"));
                return;
            }
            if (mario._instance.m_self.guide == 4)
            {
                mario._instance.show_tip(game_data._instance.get_language_string("edit_gui_djbc"));
                return;
            }
            Vector2 v    = mario._instance.get_mouse_position();
            bool    flag = true;
            if (v.x <= 96 || v.x >= Screen.width * utils.g_height / Screen.height - 96 || v.y <= 48 || v.y >= 560)
            {
                flag = false;
            }
            RaycastHit m_rayhit;
            Ray        _ui_ray = mario._instance.m_ui_camera.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(_ui_ray, out m_rayhit, 20.0f))
            {
                m_flag = true;
            }
            if (m_flag)
            {
                flag = false;
            }
            float x   = v.x - Screen.width * utils.g_height / 10 / Screen.height / 2;
            float y   = v.y - 64;
            int   mxx = (int)(x / 0.8 * 10 + edit_mode._instance.m_roll.x);
            int   myy = (int)(y / 0.8 * 10 + edit_mode._instance.m_roll.y);
            int   xx  = mxx / utils.g_grid_size;
            int   yy  = myy / utils.g_grid_size;
            if (xx == 1 && yy == game_data._instance.m_map_data.maps[m_world].qd_y && m_tuo_type == 0)
            {
                m_tuo_type = 1;
                m_tuo_pos  = v;
            }
            else if (xx == game_data._instance.m_map_data.maps[m_world].x_num - 2 && yy == game_data._instance.m_map_data.maps[m_world].zd_y && m_tuo_type == 0)
            {
                m_tuo_type = 2;
                m_tuo_pos  = v;
            }
            else if (m_tuo_type == 0 && flag && !(m_change_point.x == xx && m_change_point.y == yy))
            {
                m_change_point = new mario_point(xx, yy);
                int index = m_index;
                if (m_index > 0)
                {
                    index = m_row * 8 + m_index;
                    s_t_unit t_unit = game_data._instance.get_t_unit_by_site(index - 1);
                    index = t_unit.id;
                }
                if (index != 0 && mario._instance.m_self.guide == 1)
                {
                    bool fflag = false;
                    int  dnum  = utils.jx_block.Length / 3;
                    for (int i = 0; i < dnum; ++i)
                    {
                        int dx  = utils.jx_block[i * 3];
                        int dy  = utils.jx_block[i * 3 + 1];
                        int did = utils.jx_block[i * 3 + 2];
                        if (dy == yy && dx == xx)
                        {
                            fflag = true;
                            if (index != did)
                            {
                                mario._instance.show_tip(game_data._instance.get_language_string("edit_gui_zlbd"));
                                return;
                            }
                        }
                    }
                    if (!fflag)
                    {
                        mario._instance.show_tip(game_data._instance.get_language_string("edit_gui_qaxy"));
                        return;
                    }
                }
                edit_mode._instance.add_obj(xx, yy, index);
                m_need_save = true;
            }

            if (m_tuo_type > 0)
            {
                int vx = 0;
                if (v.x - m_tuo_pos.x > 50)
                {
                    vx = 1;
                }
                else if (v.x - m_tuo_pos.x < -50)
                {
                    vx = -1;
                }
                int vy = 0;
                if (v.y - m_tuo_pos.y > 50)
                {
                    vy = 1;
                }
                else if (v.y - m_tuo_pos.y < -50)
                {
                    vy = -1;
                }
                if (vx != 0 || vy != 0)
                {
                    edit_mode._instance.add_qz(m_tuo_type, vx, vy);
                    m_need_save = true;
                }
            }
            else
            {
                edit_mode._instance.add_qz(0, 0, 0);
            }
            edit_mode._instance.set_mpos(mxx, myy);
        }
        else
        {
            m_change_point = new mario_point();
            m_tuo_type     = 0;
            edit_mode._instance.not_add_obj();
            edit_mode._instance.add_qz(0, 0, 0);
            m_flag = false;
        }
        m_end.transform.localPosition           = new Vector3(game_data._instance.m_map_data.maps[m_world].x_num * 2 - 200 + 32, 42, 0);
        m_tip.transform.localPosition           = new Vector3(edit_mode._instance.m_main_char.m_pos.x / utils.g_grid_size * 2 - 200, 42, 0);
        m_zuobiao.GetComponent <UILabel>().text = "x:" + (edit_mode._instance.m_main_char.m_pos.x / utils.g_grid_size).ToString() + " y:" + (edit_mode._instance.m_main_char.m_pos.y / utils.g_grid_size).ToString();
    }
Example #11
0
    public void init()
    {
        load_native();
        dbc tdbc = new dbc();

        tdbc.load_txt("t_language");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_language t_l = new s_t_language();
            t_l.id = tdbc.get(0, i);
            t_l.zw = tdbc.get(1, i);
            t_l.ew = tdbc.get(2, i);
            m_t_language [t_l.id] = t_l;
        }

        tdbc.load_txt("t_unit");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_unit t_unit = new s_t_unit();
            t_unit.id            = int.Parse(tdbc.get(0, i));
            t_unit.name          = tdbc.get(1, i);
            t_unit.icon          = tdbc.get(2, i);
            t_unit.res           = tdbc.get(3, i);
            t_unit.yc            = int.Parse(tdbc.get(4, i));
            t_unit.kfg           = int.Parse(tdbc.get(5, i));
            t_unit.is_static     = int.Parse(tdbc.get(6, i));
            t_unit.fwt           = int.Parse(tdbc.get(7, i));
            t_unit.review        = int.Parse(tdbc.get(8, i));
            t_unit.is_sw         = int.Parse(tdbc.get(9, i));
            t_unit.max_num       = int.Parse(tdbc.get(10, i));
            m_t_unit [t_unit.id] = t_unit;

            if (t_unit.yc == 0)
            {
                m_unit_sites.Add(t_unit.id);
                m_unit_num++;
            }
        }

        tdbc.load_txt("t_error");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            int    id  = int.Parse(tdbc.get(0, i));
            string des = get_language_string(tdbc.get(1, i));
            m_t_error [id] = des;
        }

        tdbc.load_txt("t_view_map");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_view_map t_view = new s_t_view_map();
            t_view.id   = int.Parse(tdbc.get(0, i));
            t_view.name = get_language_string(tdbc.get(1, i));
            t_view.icon = tdbc.get(2, i);
            m_t_view_map [t_view.id] = t_view;
        }

        tdbc.load_txt("t_view_title");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_view_title t_view = new s_t_view_title();
            t_view.id   = int.Parse(tdbc.get(0, i));
            t_view.name = get_language_string(tdbc.get(1, i));
            t_view.icon = tdbc.get(2, i);
            m_t_view_title [t_view.id] = t_view;
        }

        tdbc.load_txt("t_touxiang");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            int    id   = int.Parse(tdbc.get(0, i));
            string icon = tdbc.get(1, i);
            m_t_touxiang [id] = icon;
        }

        tdbc.load_txt("t_guojia");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            string code = tdbc.get(0, i);
            string icon = tdbc.get(2, i);
            m_t_guojia [code] = icon;
        }

        tdbc.load_txt("t_exp");
        int zm = 0;

        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_exp t_exp = new s_t_exp();
            t_exp.level           = int.Parse(tdbc.get(0, i));
            t_exp.exp             = int.Parse(tdbc.get(1, i));
            t_exp.zm              = int.Parse(tdbc.get(2, i));
            t_exp.icon            = tdbc.get(3, i);
            t_exp.max_exp         = int.Parse(tdbc.get(4, i));
            m_t_exp [t_exp.level] = t_exp;
            if (t_exp.zm != zm)
            {
                zm          = t_exp.zm;
                m_t_zm [zm] = t_exp.level;
            }
        }

        tdbc.load_txt("t_job_exp");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_job_exp t_job_exp = new s_t_job_exp();
            t_job_exp.level = int.Parse(tdbc.get(0, i));
            t_job_exp.exp   = int.Parse(tdbc.get(1, i));
            m_t_job_exp [t_job_exp.level] = t_job_exp;
        }

        tdbc.load_txt("t_shop");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_shop t_shop = new s_t_shop();
            t_shop.id            = int.Parse(tdbc.get(0, i));
            t_shop.slot          = int.Parse(tdbc.get(1, i));
            t_shop.name          = get_language_string(tdbc.get(2, i));
            t_shop.type          = int.Parse(tdbc.get(3, i));
            t_shop.price         = int.Parse(tdbc.get(4, i));
            t_shop.price_my      = float.Parse(tdbc.get(5, i));
            t_shop.icon          = tdbc.get(6, i);
            t_shop.db            = tdbc.get(7, i);
            t_shop.def           = int.Parse(tdbc.get(8, i));
            t_shop.code          = tdbc.get(9, i);
            t_shop.desc          = get_language_string(tdbc.get(10, i));
            m_t_shop [t_shop.id] = t_shop;
        }

        tdbc.load_txt("t_fg");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_fg t_fg = new s_t_fg();
            t_fg.id          = int.Parse(tdbc.get(0, i));
            t_fg.name        = get_language_string(tdbc.get(1, i));
            t_fg.tj          = int.Parse(tdbc.get(2, i));
            t_fg.desc        = get_language_string(tdbc.get(3, i));
            t_fg.music       = tdbc.get(4, i);
            m_t_fg [t_fg.id] = t_fg;
            m_fg_num++;
        }

        tdbc.load_txt("t_map");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            int id = int.Parse(tdbc.get(0, i));
            m_t_map.Add(id);
        }

        tdbc.load_txt("t_br");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_br t_br = new s_t_br();
            t_br.id     = int.Parse(tdbc.get(0, i));
            t_br.name   = get_language_string(tdbc.get(2, i));
            t_br.num    = int.Parse(tdbc.get(3, i));
            t_br.desc   = get_language_string(tdbc.get(4, i));
            t_br.unlock = get_language_string(tdbc.get(6, i));
            m_t_br.Add(t_br);
        }

        tdbc.load_txt("t_key");
        for (int i = 0; i < tdbc.get_y(); ++i)
        {
            s_t_key t_key = new s_t_key();
            t_key.code = int.Parse(tdbc.get(0, i));
            t_key.name = tdbc.get(1, i);
            m_t_key.Add(t_key.code, t_key);
        }

        new_mission();

        if (Application.isEditor)
        {
                        #if STEAM
            m_channel = "win_steam";
                        #else
            m_channel = "";
                        #endif
        }
        else
        {
                        #if UNITY_ANDROID
            LJSDK._instance.init_channel();
            m_channel = LJSDK._instance.m_channel;
                        #elif UNITY_IPHONE
            m_channel = "IOS_yymoon";
                        #elif UNITY_WEBPLAYER
            LJSDK._instance.init_channel();
            return;
                        #elif UNITY_STANDALONE_WIN
                        #if STEAM
            m_channel = "win_steam";
                        #else
            m_channel = "win_yymoon";
                        #endif
                        #else
            m_channel = "";
                        #endif
        }
        init_pt_ver();
    }
Example #12
0
    public Texture2D mission_to_texture(byte[] data)
    {
        if (data.Length == 0)
        {
            return(Resources.Load("texture/back/back") as Texture2D);
        }
        try
        {
            byte[] arr = utils.Decompress(data);
            protocol.map.map_url mu      = net_http._instance.parse_packet <protocol.map.map_url> (arr);
            Texture2D            texture = new Texture2D(360, 240, TextureFormat.RGBA32, false);
            Texture2D            bt      = Resources.Load("texture/back/back_" + mu.map_theme.ToString()) as Texture2D;
            texture.SetPixels(0, 0, 360, 240, bt.GetPixels());

            MemoryStream ms = new MemoryStream(mu.array);
            byte[]       b  = new byte[4];
            for (int j = 0; j < 10; ++j)
            {
                for (int i = 0; i < 15; ++i)
                {
                    ms.Read(b, 0, b.Length);
                    int type = System.BitConverter.ToInt32(b, 0);
                    if (type > 0)
                    {
                        s_t_unit unit = game_data._instance.get_t_unit(type);
                        if (unit == null)
                        {
                            continue;
                        }
                        if (mario._instance.m_self.m_review == 1 && unit.review == 1)
                        {
                            continue;
                        }
                        Texture2D tt = null;
                        if (unit.kfg == 1)
                        {
                            tt = Resources.Load("texture/" + unit.icon + "_" + mu.map_theme.ToString()) as Texture2D;
                        }
                        else
                        {
                            tt = Resources.Load("texture/" + unit.icon) as Texture2D;
                        }
                        Color[] c = tt.GetPixels();
                        for (int y = 0; y < 24; ++y)
                        {
                            for (int x = 0; x < 24; ++x)
                            {
                                Color cc  = c[y * 24 + x];
                                Color cc1 = texture.GetPixel(i * 24 + x, j * 24 + y);
                                cc.r = cc.r * cc.a + cc1.r * (1 - cc.a);
                                cc.g = cc.g * cc.a + cc1.g * (1 - cc.a);
                                cc.b = cc.b * cc.a + cc1.b * (1 - cc.a);
                                cc.a = 1;
                                texture.SetPixel(i * 24 + x, j * 24 + y, cc);
                            }
                        }
                    }
                }
            }
            texture.Apply(false);

            return(texture);
        }
        catch (System.Exception)
        {
            return(Resources.Load("texture/back/back") as Texture2D);
        }
    }
Example #13
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);
    }
Example #14
0
 public void message(s_message message)
 {
     if (message.m_type == "play_mode")
     {
         m_edit_mode.SetActive(false);
         m_play_mode.SetActive(true);
         m_rd.SetActive(true);
         m_rd1.SetActive(true);
         m_fuzhu.SetActive(false);
         mario_point p     = (mario_point)message.m_object[0];
         int         world = 0;
         if (message.m_ints.Count > 0)
         {
             world = (int)message.m_ints[0];
         }
         int mode = 0;
         if (message.m_ints.Count > 1)
         {
             mode = (int)message.m_ints[1];
         }
         m_play_mode.GetComponent <play_mode>().reload(p, world, mode);
     }
     if (message.m_type == "close_play_mode")
     {
         m_play_mode.SetActive(false);
         if (mario._instance.m_game_state != e_game_state.egs_edit)
         {
             m_rd.SetActive(false);
             m_rd1.SetActive(false);
         }
     }
     if (message.m_type == "edit_mode")
     {
         m_play_mode.SetActive(false);
         m_edit_mode.SetActive(true);
         m_rd.SetActive(true);
         m_rd1.SetActive(true);
         m_fuzhu.SetActive(true);
         mario_point p = null;
         if (message.m_object.Count > 0)
         {
             p = (mario_point)message.m_object[0];
         }
         int world = 0;
         if (message.m_ints.Count > 0)
         {
             world = (int)message.m_ints[0];
         }
         m_edit_mode.GetComponent <edit_mode>().reload(p, world, m_edit_cys);
         m_edit_cys = new List <edit_cy>();
     }
     if (message.m_type == "close_edit_mode")
     {
         m_edit_mode.SetActive(false);
         m_rd.SetActive(false);
         m_rd1.SetActive(false);
     }
     if (message.m_type == "first_load")
     {
         foreach (KeyValuePair <int, s_t_unit> kv in game_data._instance.m_t_unit)
         {
             s_t_unit t_unit = kv.Value;
             string   name   = t_unit.res;
             string   cname  = "unit/" + name + "/" + name;
             if (t_unit != null && t_unit.kfg == 1)
             {
                 cname = "unit/" + name + "/1/" + name;
             }
             GameObject res = (GameObject)Resources.Load(cname);
             GameObject obj = (GameObject)Instantiate(res);
             obj.transform.parent        = m_loading.transform;
             obj.transform.localPosition = new Vector3(0, 0, 0);
             obj.transform.localScale    = new Vector3(1, 1, 1);
         }
         s_message mes = new s_message();
         mes.m_type = "first_load_end";
         mes.time   = 0.3f;
         cmessage_center._instance.add_message(mes);
     }
     if (message.m_type == "first_load_end")
     {
         mario._instance.remove_child(m_loading);
     }
     if (message.m_type == "edit_canying")
     {
         edit_cy ec = (edit_cy)message.m_object[0];
         if (m_edit_cys.Count > 0)
         {
             edit_cy cy1 = m_edit_cys[m_edit_cys.Count - 1];
             float   d   = Mathf.Sqrt((cy1.p.x - ec.p.x) * (cy1.p.x - ec.p.x) + (cy1.p.y - ec.p.y) * (cy1.p.y - ec.p.y));
             if (d < 640)
             {
                 return;
             }
         }
         m_edit_cys.Add(ec);
         if (m_edit_cys.Count > 50)
         {
             m_edit_cys.RemoveAt(0);
         }
     }
 }