示例#1
0
    void Awake()
    {
        Instance = this;

        goChina = new GameObject("ChinaProvinceCity");
        goChina.transform.localScale = new Vector3(-1f, 1f, 1f);
        mr_china = goChina.AddComponent <MeshRenderer>();
        MeshFilter mf_china = goChina.AddComponent <MeshFilter>();

        mesh_china = new Mesh();
        mesh_china.subMeshCount = 5;
        mesh_china.name         = "mesh_china";
        mf_china.mesh           = mesh_china;
        mat_china = Resources.Load <Material>("Materials/country");
        mat_china.SetFloat("_Deform", 1f);
        mat_china_pick = Resources.Load <Material>("Materials/country_pick");
        mat_china_pick.SetFloat("_Deform", 1f);
        mat_china_border_picked_province = Resources.Load <Material>("Materials/border_picked");
        mat_china_border_picked_province.SetFloat("_Deform", 1f);
        mat_china_border_picked_city = Resources.Load <Material>("Materials/border_picked");
        mat_china_border_picked_city.SetFloat("_Deform", 1f);
        mat_china_border = Resources.Load <Material>("Materials/border_picked");
        mat_china_border.SetFloat("_Deform", 1f);
        mat_china_boundary = Resources.Load <Material>("Materials/boundary");
        mat_china_boundary.SetFloat("_Deform", 1f);
        ChinaMats          = new Material[5];
        ChinaMats[0]       = mat_china;
        ChinaMats[1]       = mat_china_boundary;
        ChinaMats[2]       = mat_china_border_picked_province;
        ChinaMats[3]       = mat_china_border_picked_city;
        ChinaMats[4]       = mat_china_border;
        mr_china.materials = ChinaMats;
        ChinaPickMats      = new Material[1];
        ChinaPickMats[0]   = mat_china_pick;

        cdd = Resources.Load <ChinaDetailData>("Datas/ChinaDetailData");

        mesh_china.SetVertices(cdd.vertex_mecator);
        mesh_china.SetUVs(0, cdd.id_all);
        mesh_china.SetUVs(1, cdd.vertex_ecef);
        mesh_china.SetUVs(2, cdd.color_all);

        mesh_china.subMeshCount = 5;
        mesh_china.SetIndices(cdd.index_all, MeshTopology.Triangles, 0);
        mesh_china.SetIndices(cdd.index_boundary, MeshTopology.Lines, 1);
        mesh_china.SetIndices(cdd.index_no_picked, MeshTopology.Lines, 2);
        mesh_china.SetIndices(cdd.index_no_picked, MeshTopology.Lines, 3);
        mesh_china.SetIndices(cdd.index_no_picked, MeshTopology.Lines, 4);
        mesh_china.bounds = new Bounds(Vector3.zero, new Vector3(100f, 100f, 100f));
        //         cdd.index_all = null;
        //         cdd.index_boundary = null;
        //
        //         cdd.id_all = null;
        //         cdd.vertex_ecef = null;
        //         cdd.vertex_mecator = null;
        //         cdd.color_all = null;
    }
示例#2
0
文件: Map.cs 项目: samucc/cybermap
    //O = !! e.widget,
    //C = !! e.screensaver,
    public void FocusPickedCountry(float fDist)   //     function E(e) { // 点击国家
    {
        //      if (!O && !C) {// 不在widget和screensaver状态下
        float r = 5f;                        //             var r = 5;// 鼠标按下和抬起间移动距离

        if (fDist < r)                       //             if (!(e > r)) {
        {
            if (pick.picked_country_id == 0) //                 if (z.pick_index < 0) return o(null),
            {
                //o(null);
                a(false);// void a();
                return;
            }
            t(); // t();
            // var n = he.countries[z.pick_index];
            // n === j ? (o(null), a()) : (vec3.set(z.geocam.coord_target, n.center[0], n.center[1], U), o(n)),
            if (curPickedCountryId != pick.picked_country_id)
            {
                curPickedCountryId = pick.picked_country_id;
                if (curPickedCountryId >= 300)
                {
                    //curPickedCountryId = 89;
                    ChinaDetailData cdd      = ChinaProvinceCity.Instance.cdd;
                    Vector3         v3Target = Vector3.zero;
                    if (cdd.bIncCity && curPickedCountryId >= cdd.iCityIdBeg)
                    {
                        v3Target = cdd.china_cities[curPickedCountryId - cdd.iCityIdBeg].center_location;
                    }
                    else
                    {
                        v3Target = cdd.china_provinces[curPickedCountryId - 301].center_location;
                    }

                    geocam.coord_target.Set(v3Target.x, v3Target.y, geocam.coord[2]);
                    JSInterface.Instance.OnAreaClicked(curPickedCountryId);
                }
                else
                {
                    if (Country.dic_pick_index.ContainsKey(curPickedCountryId))
                    {
                        country_data c_data = Country.dic_pick_index[curPickedCountryId];
                        geocam.coord_target.Set(c_data.center_location[0], c_data.center_location[1], geocam.coord[2]);
                        JSInterface.Instance.OnAreaClicked(curPickedCountryId);
                    }
                }
                //o(n)
            }
            else
            {
                //o(null);
                a();
            }
            //D(null); // D(null)
        }
    }