예제 #1
0
    void  LoadXML(WindoManager item2, string xml)
    {
        //yield return new WaitWhile(() => MsgCenter._instance.xml == "");
        List <CurtainManager> tempw = NewReadXml.ReadCurtainXml(item2.GroupID, xml);

        Load(tempw);
    }
예제 #2
0
 public void InitWindow(WindoManager Window)
 {
     ID               = Window.Id;
     Curtain          = Window.Curtain;
     WindowPictureUrl = Window.WindowPictureUrl;
     //Up = Window.Up;
     //Middle = Window.Middle;
     Position = Window.Position;
     Rotation = Window.Rotation;
     Scale    = Window.Scale;
     GroupID  = Window.GroupID;
     Sequ     = Window.Sequ;
 }
예제 #3
0
    /// <summary>
    /// 比较前后两个窗户信息  true:一样 false:不一样
    /// </summary>
    /// <param name="befor"></param>
    /// <param name="after"></param>
    /// <returns> 是否一样 </returns>
    bool ContrastManager(WindoManager befor)
    {
        bool temp = true;

        if (befor.Position != RoundV3(Rotetarget.localPosition, 2))
        {
            temp = false;
        }
        else if (befor.Scale != RoundV3(Rotetarget.localScale, 2))
        {
            temp = false;
        }
        else if (befor.Rotation != RoundV3(Rotetarget.localEulerAngles, 2))
        {
            temp = false;
        }
        return(temp);
    }
예제 #4
0
    /// <summary>
    /// 添加窗户
    /// </summary>
    void AddWindow()
    {
        i = Asset.WindowList.Count;
        CaiZuo.SetActive(true);
        if (Rotetarget)
        {
            Save();
        }
        GameObject WindowObj = Instantiate(Window);

        WindowObj.transform.parent = WParent;

        //WindowObj.transform.localPosition = Vector3.zero;
        //WindowObj.transform.localPosition = new Vector3(0, 7, 0);
        WindowObj.transform.position = Controller.Target1.transform.TransformPoint(0, 0, 7);
        float Zvalue = Controller.Target1.transform.localEulerAngles.y;

        WindowObj.transform.localEulerAngles = new Vector3(0, 0, Zvalue + 180);

        Rotetarget = WindowObj.transform;

        ReAssigned(Rotetarget); //赋值

        WindowObj.name = i.ToString();

        Save();
        //Asset.WindowList.Add(WindowObj.transform);
        MsgCenter._instance.AddWindowList(WindowObj.name, new Dictionary <string, GameObject>());

        MsgCenter._instance.nowWidow = WindowObj.transform;

        s_rotation.value = Rotetarget.localEulerAngles.z;


        isAddWindow = false;
        WindoManager temp = WindowObj.GetComponent <WindoManager>();

        temp.ID     = i;
        isAddWindow = false;
    }
예제 #5
0
    //public IEnumerator StartInitWindow()
    //{
    //    yield return new WaitWhile(() => MsgCenter._instance.xml == "");
    //    List<WindoManager> item = NewReadXml.ReadLoyoutXml(MsgCenter.xml);
    //    Debug.Log(MsgCenter._instance.xml);
    //    LoadQiuTexture(MsgCenter._instance.QiuIcon);
    //    LoadQiuTexture(MsgCenter._instance.QiuURL);
    //    LoadWindow(item);
    //}
    /// <summary>
    /// 加载默认场景的XML
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>


    /// <summary>
    /// 动态创建窗户
    /// </summary>
    /// <param name="data"></param>
    void LoadWindow(List <WindoManager> data)
    {
        if (WindowList.Count != 0)
        {
            foreach (GameObject temp in WindowList.Values)
            {
                DestroyImmediate(temp);
            }
            WindowList.Clear();
        }

        IsInit = true;

        Debug.Log(data.Count);
        foreach (WindoManager item in data)
        {
            //根据信息生成window
            //如果是窗户
            MsgCenter.DefaultWindo = item;
            if (item.ModleType == 102)
            {
                GameObject WholeCurtain = (GameObject)Instantiate(Resources.Load("WholeCurtain"));
                WholeCurtain.transform.parent = QIU;
                WholeCurtain.name             = item.GroupID;
                //WholeCurtain.transform.localScale = item.Scale;
                WindowList.Add(item.GroupID, WholeCurtain);
                Debug.Log(item.GroupID + "     wwwwwwwwwwwww");
                WholeCurtain.transform.localEulerAngles = new Vector3(item.Rotation.x, item.Rotation.y, item.Rotation.z);
                WholeCurtain.transform.localPosition    = new Vector3(item.Position.x, item.Position.y, item.Position.z);
                Transform chuanghu = WholeCurtain.transform.FindChild("chaunghu");
                chuanghu.localScale        = item.Scale;
                chuanghu.parent.localScale = item.OfferScale;
                string       path = MsgCenter.WWWURL + item.WindowPictureUrl;
                WindoManager wm   = WholeCurtain.GetComponent <WindoManager>();
                wm.InitWindow(item);
                Parent2D     = wm.TwoD;
                ParentMiddle = wm.Middle;
                ParentUp     = wm.Up;
                StartCoroutine(loadWindowPicture(path, chuanghu));
                foreach (WindoManager item2 in data)
                {
                    if (item.GroupID == item2.GroupID && item2.ModleType == 101)
                    {
                        WholeCurtain.transform.FindChild("guadian").localScale = item2.Scale;

                        //if (item.Sequ == "0" && MsgCenter.isSingleInit)
                        //{
                        //    item2.Prod_ID = MsgCenter.S_RProud;
                        //    MsgCenter.isSingleInit = false;
                        //}

                        //string qingqiu = "corp_id=" + "\"" + MsgCenter._instance.nowHouse.Corp_ID + "\"" + " prod_id=" + "\"" + item2.Prod_ID + "\"";
                        //string temp = MsgCenter._instance.start(MsgCenter._instance.strXML("MM404442", "detail", qingqiu));
                        LoadXML(item2, MsgCenter.ReadAndLoadXml("ProduceXML/" + item2.Prod_ID));
                    }
                }
            }
            //不是窗户(家具)
            else
            {
            }
        }
        //Debug.Log(MsgCenter.DefaultWindo.GroupID+"     "+  WindowList[MsgCenter.DefaultWindo.GroupID].transform.name + "     wwwwwwwwwwwww");
        if (WindowList.ContainsKey(MsgCenter.DefaultWindo.GroupID))
        {
            Camera.main.GetComponent <UseCamareController>().Target1.LookAt(WindowList[MsgCenter.DefaultWindo.GroupID].transform);
        }
    }
예제 #6
0
    // 解析窗户的XML
    public static List <WindoManager> ReadWindowXml(string[] WindowsID, string path)
    {
        int index = -1;
        int Inde  = 0;

        MsgCenter._instance.CleanList();
        //MsgCenter._instance.CleanAllList(MsgCenter._instance.nowWidow);
        MsgCenter._instance.TempDisctionary.Clear();
        List <WindoManager> AllWindow = new List <WindoManager>();

        System.IO.StringReader stringReader = new System.IO.StringReader(path);
        stringReader.Read(); // 跳过 BOM
        System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stringReader);
        XmlDocument          myXML  = new XmlDocument();

        myXML.LoadXml(stringReader.ReadToEnd());
        XmlElement Xmlroot = myXML.DocumentElement;

        foreach (XmlNode item in Xmlroot.ChildNodes)
        {
            Debug.Log(WindowsID[0]);
            if (((IList)WindowsID).Contains(item.Attributes["ID"].Value))
            {
                index++;
                MsgCenter._instance.AddWindowList(Inde.ToString(), new Dictionary <string, GameObject>());
                WindoManager newExcel = new WindoManager();
                newExcel.WindowPictureUrl = item["WindowPictureUrl"].InnerText;
                newExcel.ID = index;

                float Scalex = float.Parse(item["WindowScale"].Attributes["X"].Value);
                float Scaley = float.Parse(item["WindowScale"].Attributes["Y"].Value);
                float Scalez = float.Parse(item["WindowScale"].Attributes["Z"].Value);

                float Positionx = float.Parse(item["WindowPosition"].Attributes["X"].Value);
                float Positiony = float.Parse(item["WindowPosition"].Attributes["Y"].Value);
                float Positionz = float.Parse(item["WindowPosition"].Attributes["Z"].Value);
                float Rotationx = float.Parse(item["WindowRotation"].Attributes["X"].Value);
                float Rotationy = float.Parse(item["WindowRotation"].Attributes["Y"].Value);
                float Rotationz = float.Parse(item["WindowRotation"].Attributes["Z"].Value);


                MsgCenter._instance.ModuleCount = (index + 1) * item["Model"].ChildNodes.Count;

                for (int i = 0; i < item["Model"].ChildNodes.Count; i++)
                {
                    Curtain temp = new Curtain();

                    temp.IsModel         = true;
                    temp.ModelUrl        = item["Model"].ChildNodes[i].InnerText;
                    temp.ScaleParameters = float.Parse(item["Model"].Attributes["CurtainScale"].Value);
                    Debug.Log(" index   " + index);
                    temp.Id = index;
                    string Stemp = temp.Id + temp.ModelUrl.Split('.')[0];

                    if (!MsgCenter._instance.TempDisctionary.ContainsKey(Stemp))
                    {
                        MsgCenter._instance.TempDisctionary.Add(Stemp, false);
                    }
                    temp.TextureUrl = item["Model"].ChildNodes[i].Attributes["TextureUrl"].InnerText;
                    temp.Material   = new Material(Resources.Load <Shader>("Standard"));
                    string[] rgba = item["Model"].ChildNodes[i].Attributes["RGB"].InnerText.Split('.');

                    if (rgba[0] != "")
                    {
                        float r = float.Parse(rgba[0]);
                        float g = float.Parse(rgba[1]);
                        float b = float.Parse(rgba[2]);
                        float a = float.Parse(rgba[3]);
                        temp.Material.color = new Color(r / 255, g / 255, b / 255, a / 255);
                    }
                    newExcel.Curtain.Add(temp);
                }
                newExcel.Scale    = new Vector3(Scalex, Scaley, Scalez);
                newExcel.Position = new Vector3(Positionx, Positiony, Positionz);
                newExcel.Rotation = new Vector3(Rotationx, Rotationy, Rotationz);

                AllWindow.Add(newExcel);
                Inde++;
            }
        }
        index = 0;
        Inde  = 0;
        return(AllWindow);
    }
예제 #7
0
    /// <summary>
    /// 解析布局
    /// </summary>
    /// <param name="path"></param>
    /// <returns></returns>
    public static List <WindoManager> ReadLoyoutXml(string path)
    {
        MsgCenter._instance.CleanList();
        int index = -1;
        List <WindoManager> window = new List <WindoManager>();

        System.IO.StringReader stringReader = new System.IO.StringReader(path);
        //stringReader.Read(); // 跳过 BOM
        //System.Xml.XmlReader reader = System.Xml.XmlReader.Create(stringReader);
        XmlDocument myXML = new XmlDocument();

        myXML.LoadXml(stringReader.ReadToEnd());
        XmlElement Xmlroot = myXML.DocumentElement;

        MsgCenter._instance.QiuURL = new string[3];
        if (Xmlroot["panorama_list"] != null)
        {
            foreach (XmlNode item in Xmlroot["panorama_list"].ChildNodes)
            {
                //Debug.Log(item.SelectSingleNode("//row").Attributes);
                string Type = item.Attributes["panorama_kind"] != null ? item.Attributes["panorama_kind"].Value : "";
                string idx  = item.Attributes["sequ"] != null ? item.Attributes["sequ"].Value : "";
                string URL  = item.Attributes["panorama_file_url"] != null ? item.Attributes["panorama_file_url"].Value : "";
                string Icon = item.Attributes["panorama_spic_url"] != null ? item.Attributes["panorama_spic_url"].Value : "";
                //Debug.Log(URL + "    " + item.Attributes["panorama_kind"].Value);
                if (idx == "0")
                {
                    if (Type == "103")
                    {//吊顶
                        MsgCenter._instance.QiuURL[0]  = URL;
                        MsgCenter._instance.QiuIcon[0] = Icon;
                    }
                    if (Type == "102")
                    {//墙面
                        MsgCenter._instance.QiuURL[2]  = URL;
                        MsgCenter._instance.QiuIcon[2] = Icon;
                    }
                    if (Type == "101")
                    {//地面
                        MsgCenter._instance.QiuURL[1]  = URL;
                        MsgCenter._instance.QiuIcon[1] = Icon;
                    }
                }
            }
        }
        if (Xmlroot["layout_res_list"] != null)
        {
            foreach (XmlNode item in Xmlroot["layout_res_list"].ChildNodes)
            {
                WindoManager temp = new WindoManager();
                index++;
                temp.ID = index;
                temp.WindowPictureUrl = item.Attributes["def_model_url"] != null ? item.Attributes["def_model_url"].Value : "";
                temp.ModleType        = item.Attributes["prod_kind"] != null?int.Parse(item.Attributes["prod_kind"].Value) : 0;

                if (item.Attributes["unit_group"] != null)
                {
                    temp.GroupID = item.Attributes["unit_group"].Value;
                }
                if (item.Attributes["prod_id"] != null)
                {
                    temp.Prod_ID = item.Attributes["prod_id"].Value;
                }
                if (item.Attributes["sequ"] != null)
                {
                    temp.Sequ = item.Attributes["sequ"].Value;
                }

                float Positionx = item.Attributes["pos_x"] != null?float.Parse(item.Attributes["pos_x"].Value) : 0;

                float Positiony = item.Attributes["pos_y"] != null?float.Parse(item.Attributes["pos_y"].Value) : 0;

                float Positionz = item.Attributes["pos_z"] != null?float.Parse(item.Attributes["pos_z"].Value) : 0;

                temp.Position = new Vector3(Positionx, Positiony, Positionz);

                float scale = item.Attributes["scaling_per"] != null?float.Parse(item.Attributes["scaling_per"].Value) : 0;

                temp.OfferScale = new Vector3(scale, scale, scale);

                temp.Scale = new Vector3(float.Parse(item.Attributes["size_l"].Value), float.Parse(item.Attributes["size_h"].Value), float.Parse(item.Attributes["size_w"].Value));

                float Rotation = item.Attributes["rotation_angle"] != null?float.Parse(item.Attributes["rotation_angle"].Value) : 0;

                temp.Rotation = new Vector3(0, 0, Rotation);

                window.Add(temp);
            }
        }

        return(window);
    }