Пример #1
0
    public HidePart MappingPart(uint hide_id)
    {
        HidePart data = null;

        mapHideParts.TryGetValue(hide_id, out data);
        return(data);
    }
Пример #2
0
    static int MappingPart(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        FashionConfig obj  = (FashionConfig)LuaScriptMgr.GetNetObjectSelf(L, 1, "FashionConfig");
        uint          arg0 = (uint)LuaScriptMgr.GetNumber(L, 2);
        HidePart      o    = obj.MappingPart(arg0);

        LuaScriptMgr.PushObject(L, o);
        return(1);
    }
Пример #3
0
    public void ReadConfig()
    {
        if (isLoadFinish == false)
        {
            return;
        }
        isLoadFinish = false;
        lock (LockObject) { GameSystem.Instance.readConfigCnt += 1; }

        Debug.Log("Config reading " + name1);
        string text = ResourceLoadManager.Instance.GetConfigText(name1);

        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name1);
            return;
        }

        //读取以及处理XML文本的类
        XmlDocument doc = CommonFunction.LoadXmlConfig(name1, text);

        XmlNode node_data = doc.SelectSingleNode("Data");

        foreach (XmlNode node_line in node_data.SelectNodes("Line"))
        {
            if (node_line.SelectSingleNode("switch").InnerText == "#")
            {
                continue;
            }

            FashionItem data = new FashionItem();
            data.fashion_id = uint.Parse(node_line.SelectSingleNode("id").InnerText);

            for (int i = 0; i < 6; i++)
            {
                string tmp = "shape_id" + (i + 1);

                string shaderID = node_line.SelectSingleNode(tmp).InnerText;
                if (shaderID == "")
                {
                    continue;
                }

                FashionMatch item = new FashionMatch();

                item.shape_id = shaderID;

                tmp = "bone_id" + (i + 1);
                string   strHideId = node_line.SelectSingleNode(tmp).InnerText;
                string[] tokens    = strHideId.Split('&');
                foreach (string token in tokens)
                {
                    uint hide_Id;
                    if (uint.TryParse(token, out hide_Id))
                    {
                        item.hide_id.Add(hide_Id);
                    }
                }
                tmp            = "body_type" + (i + 1);
                item.body_type = node_line.SelectSingleNode(tmp).InnerText;


                data.fashion_matchs.Add(item.body_type, item);
            }



            configs.Add(data.fashion_id, data);
        }


        Debug.Log("Config reading " + name2);

        text = ResourceLoadManager.Instance.GetConfigText(name2);
        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name2);
            return;
        }

        //读取以及处理XML文本的类
        doc       = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_BONE_MAPPING, text);
        node_data = doc.SelectSingleNode("Data");
        foreach (XmlNode node_line in node_data.SelectNodes("Line"))
        {
            HidePart data = new HidePart();
            data.hide_id = uint.Parse(node_line.SelectSingleNode("id").InnerText);
            data.part_id = node_line.SelectSingleNode("part").InnerText;
            mapHideParts.Add(data.hide_id, data);
        }


        Debug.Log("Config reading " + name3);
        text = ResourceLoadManager.Instance.GetConfigText(name3);
        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name3);
            return;
        }

        //读取以及处理XML文本的类
        doc       = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_FASHIONATTR, text);
        node_data = doc.SelectSingleNode("Data");
        foreach (XmlNode node_line in node_data.SelectNodes("Line"))
        {
            if (node_line.SelectSingleNode("switch").InnerText == "#")
            {
                continue;
            }

            FashionAttr fashionAttr = new FashionAttr();
            fashionAttr.attr_id = uint.Parse(node_line.SelectSingleNode("attrs_id").InnerText);
            string   attrsStr = node_line.SelectSingleNode("attrs").InnerText.ToString();
            string[] attr     = attrsStr.Split(':');
            fashionAttr.player_attr_id  = uint.Parse(attr[0]);
            fashionAttr.player_attr_num = uint.Parse(attr[1]);

            if (!fashionAttrs.ContainsKey(fashionAttr.attr_id))
            {
                fashionAttrs.Add(fashionAttr.attr_id, fashionAttr);
            }
        }


        Debug.Log("Config reading " + name4);
        text = ResourceLoadManager.Instance.GetConfigText(name4);
        if (text == null)
        {
            Debug.LogError("LoadConfig failed: " + name4);
            return;
        }

        //读取以及处理XML文本的类
        doc       = CommonFunction.LoadXmlConfig(GlobalConst.DIR_XML_FASHIONDATA, text);
        node_data = doc.SelectSingleNode("Data");
        foreach (XmlNode node_line in node_data.SelectNodes("Line"))
        {
            if (node_line.SelectSingleNode("switch").InnerText == "#")
            {
                continue;
            }

            FashionData fashionData = new FashionData();
            fashionData.fashion_id = uint.Parse(node_line.SelectSingleNode("id").InnerText);
            string   resetInfo = node_line.SelectSingleNode("reset_price").InnerText.ToString();
            string[] resetArr  = resetInfo.Split(':');
            fashionData.reset_id  = uint.Parse(resetArr[0]);
            fashionData.reset_num = uint.Parse(resetArr[1]);

            if (!fashionDatas.ContainsKey(fashionData.fashion_id))
            {
                fashionDatas.Add(fashionData.fashion_id, fashionData);
            }
        }
    }
Пример #4
0
    public void _DressDown(string strType, uint itemId)
    {
        FashionItem item = GameSystem.Instance.FashionConfig.GetConfig(itemId);

        if (item == null)
        {
            Debug.LogError("Can not fashion item: " + itemId);
            return;
        }

        BodyInfo bodyInfo = null;

        // TODO: check wheather use the shape id
        GameSystem.Instance.BodyInfoListConfig.configs.TryGetValue((uint)_shapeID, out bodyInfo);


        FashionMatch fMatch = null;

        item.fashion_matchs.TryGetValue(bodyInfo.type_id, out fMatch);

        if (fMatch == null)
        {
            return;
        }
        string shapeId = fMatch.shape_id;
        //if( shapeId.StartsWith("Skin_") )
        //{
        //    shapeId = shapeId.Remove(0, 5);
        //}

        Transform fashonTran = mPlayer.gameObject.transform.FindChild(fMatch.shape_id.Remove(0, 5));

        fashonTran = null;

        if (fashonTran == null)
        {
            string     strResPath = string.Format("Object/Fashion/{0}/{0}", fMatch.shape_id);
            Object     resDress   = ResourceLoadManager.Instance.GetResources(strResPath);
            GameObject goDress    = GameObject.Instantiate(resDress) as GameObject;


            SkinnedMeshRenderer[] skinMeshes = goDress.GetComponentsInChildren <SkinnedMeshRenderer>();
            foreach (SkinnedMeshRenderer skin in skinMeshes)
            {
                Transform sfashonTran = mPlayer.gameObject.transform.FindChild(skin.name);
                if (sfashonTran != null)
                {
                    if (m_bFashionMode)
                    {
                        GameObject.Destroy(sfashonTran.gameObject);
                    }
                    else
                    {
                        GameObject.DestroyImmediate(sfashonTran.gameObject);
                    }
                }
                else
                {
                    //Debug.LogError("get rid of skin failed for the skin.name=" + skin.name);
                }
            }

            if (m_bFashionMode)
            {
                GameObject.Destroy(goDress);
            }
            else
            {
                GameObject.DestroyImmediate(goDress);
            }
            // return;
        }
        if (fashonTran != null)
        {
            if (m_bFashionMode)
            {
                GameObject.Destroy(fashonTran.gameObject);
            }
            else
            {
                GameObject.DestroyImmediate(fashonTran.gameObject);
            }
        }

        //string strResPath = string.Format("Object/Fashion/{0}/{0}", fMatch.shape_id);
        //Object resDress = ResourceLoadManager.Instance.GetResources(strResPath);
        //GameObject goDress = GameObject.Instantiate(resDress) as GameObject;
        //GameUtils.ReSkinning(goDress, mPlayer.m_goPlayer);
        //GameObject.Destroy(goDress);

        //if( m_bFashionMode )
        {
            foreach (uint hide in fMatch.hide_id)
            {
                HidePart hp = GameSystem.Instance.FashionConfig.MappingPart(hide);
                if (hp == null)
                {
                    continue;
                }
                string    strHidePart = (mPlayer.m_gender == fogs.proto.msg.GenderType.GT_FEMALE ? "G_" : "M_") + hp.part_id;
                Transform trSkin      = GameUtils.FindChildRecursive(mPlayer.gameObject.transform, strHidePart);

                if (trSkin == null)
                {
                    continue;
                }
                trSkin.gameObject.GetComponent <Renderer>().enabled = true;
            }
        }
        //  mPlayer.m_goPlayer.layer = LayerMask.NameToLayer("Player");
        GameUtils.SetLayerRecursive(mPlayer.gameObject.transform, LayerMask.NameToLayer(_layerName));
        //Resources.UnloadUnusedAssets();
    }
Пример #5
0
    public void _DressUp(string strType, uint itemId)
    {
        if (itemId == 0)
        {
            Debug.Log("fashion item id is : " + itemId);
            return;
        }

        FashionItem item = GameSystem.Instance.FashionConfig.GetConfig(itemId);

        if (item == null)
        {
            Debug.LogError("Can not fashion item: " + itemId);
            return;
        }

        BodyInfo bodyInfo = null;

        // TODO: check wheather use the shape id
        GameSystem.Instance.BodyInfoListConfig.configs.TryGetValue((uint)_shapeID, out bodyInfo);


        FashionMatch fMatch = null;

        item.fashion_matchs.TryGetValue(bodyInfo.type_id, out fMatch);

        if (fMatch == null)
        {
            return;
        }


        Transform fashonTran = mPlayer.gameObject.transform.FindChild(fMatch.shape_id.Remove(0, 5));

        if (fashonTran != null)
        {
            return;
        }


        string     strResPath = string.Format("Object/Fashion/{0}/{0}", fMatch.shape_id);
        Object     resDress   = ResourceLoadManager.Instance.GetResources(strResPath);
        GameObject goDress    = GameObject.Instantiate(resDress) as GameObject;

        GameUtils.ReSkinning(goDress, mPlayer.gameObject);
        GameObject.Destroy(goDress);

        foreach (uint hide in fMatch.hide_id)
        {
            HidePart hp = GameSystem.Instance.FashionConfig.MappingPart(hide);
            if (hp == null)
            {
                continue;
            }
            string    strHidePart = (mPlayer.m_gender == fogs.proto.msg.GenderType.GT_FEMALE ? "G_" : "M_") + hp.part_id;
            Transform trSkin      = GameUtils.FindChildRecursive(mPlayer.gameObject.transform, strHidePart);

            if (trSkin == null)
            {
                continue;
            }

            trSkin.gameObject.GetComponent <Renderer>().enabled = false;
        }

        GameUtils.SetLayerRecursive(mPlayer.gameObject.transform, LayerMask.NameToLayer(_layerName));
    }