Esempio n. 1
0
        public static void DrawWeapon(GameObject go, RoleShape shape, string dir, XRolePart part, uint presentid, int weapon_index, FashionList.RowData row)
        {
            string    sshape    = shape.ToString().ToLower();
            Transform transf    = go.transform.Find("Player_" + sshape + "_" + TCConst.WEAPON);
            string    shape_dir = "Player_" + sshape;
            string    cname     = "Player_" + sshape + "_" + dir + "_" + TCConst.WEAPON + "_" + presentid + "_" + weapon_index;
            string    asset     = "Assets/BundleRes/FBXRawData/" + shape_dir + "/" + shape_dir + "_" + dir + "/" + cname;

            for (int i = 0; i < part.weapon.Length; i++)
            {
                if (part.weapon[i].presentid == presentid)
                {
                    if (weapon_index == 1)
                    {
                        FashionUtility.DrawPart(transf, asset, part.weapon[i].weapon1, part.weapon[i].sweapon1, row);
                    }
                    else
                    {
                        DrawPart(transf, asset, part.weapon[i].weapon2, part.weapon[i].sweapon2, row);
                    }
                    break;
                }
            }
        }
Esempio n. 2
0
        public static void DrawPart(GameObject go, string part, RoleShape shape, string dir, string suffix, Transform[] bones, string[] dbones, FashionList.RowData row)
        {
            string    sshape    = shape.ToString().ToLower();
            Transform transf    = go.transform.Find("Player_" + sshape + "_" + suffix);
            string    asset     = string.Empty;
            string    shape_dir = "Player_" + sshape;

            if (string.IsNullOrEmpty(part))
            {
                string cname = "Player_" + sshape + "_" + dir + "_" + suffix;
                asset = "Assets/BundleRes/FBXRawData/" + shape_dir + "/" + shape_dir + "_" + dir + "/" + cname;
                DrawPart(transf, asset, bones, dbones, row);
            }
            else if (!part.Equals("E"))
            {
                string cname = "Player_" + sshape + "_common_" + suffix + "_" + part;
                asset = "Assets/BundleRes/FBXRawData/" + shape_dir + "/Common/" + cname;
                DrawPart(transf, asset, bones, dbones, row);
            }
        }
Esempio n. 3
0
        public static void DrawPart(Transform tranf, string asset, Transform[] bones, string[] dbones, FashionList.RowData row)
        {
            if (tranf != null)
            {
                SkinnedMeshRenderer smr = tranf.gameObject.GetComponent <SkinnedMeshRenderer>();
                var mesh = AssetDatabase.LoadAssetAtPath <Mesh>(asset + ".asset");
                var mat  = AssetDatabase.LoadAssetAtPath <Material>(asset + ".mat");
                if (mesh != null)
                {
                    smr.sharedMesh = mesh;
                }
                if (mat != null)
                {
                    smr.sharedMaterial = mat;
                }

                if (row != null && row.dbparent != null)
                {
                    for (int k = 0; k < row.dbparent.Length; k++)
                    {
                        GameObject prefab = AssetDatabase.LoadAssetAtPath <GameObject>("Assets/BundleRes/Prefabs/DynamicBones/" + row.dbprefab[k] + ".prefab");
                        if (prefab == null)
                        {
                            Debug.LogError("DynamicBones error: fashionlist id: " + row.ID + " index: " + k + "  prefab config: " + row.dbprefab[k]);
                        }
                        else
                        {
                            GameObject go  = GameObject.Instantiate(prefab);
                            Vector3    pos = go.transform.localPosition;
                            Quaternion rot = go.transform.localRotation;
                            Transform  par = tranf.parent.Find(row.dbparent[k]);
                            go.transform.SetParent(par);
                            go.transform.localPosition = pos;
                            go.transform.localRotation = rot;

                            Transform[] childs = go.GetComponentsInChildren <Transform>();
                            for (int i = 0; i < bones.Length; i++)
                            {
                                if (dbones != null && !string.IsNullOrEmpty(dbones[i]))
                                {
                                    var tf = SearchChild(childs, tranf, dbones[i]);
                                    if (tf != null)
                                    {
                                        bones[i] = tf;
                                    }
                                }
                            }
                        }
                    }
                }
                smr.bones = bones;
            }
        }
Esempio n. 4
0
    public static void MakeEquip(string name, int[] fashionIDs, List <EquipPart> equipList, TempEquipSuit tmpFashionData, int suitID)
    {
        FashionList fashionList = XTableMgr.GetTable <FashionList>();

        if (fashionIDs != null)
        {
            tmpFashionData.hash = 0;
            tmpFashionData.data.Clear();
            bool threePart = false;
            for (int i = 0; i < fashionIDs.Length; ++i)
            {
                int fashionID           = fashionIDs[i];
                FashionList.RowData row = fashionList.GetByUID(fashionID);
                if (row != null)
                {
                    List <ThreePart> tpLst = new List <ThreePart>();
                    if (row.EquipPos == 7 || row.EquipPos == 8 || row.EquipPos == 9)
                    {
                        ThreePart tp = FindThreePart(suitID, tpLst);
                        if (row.EquipPos == 9)
                        {
                            tp.part[2] = row.ModelPrefabArcher;
                        }
                        threePart = true;
                    }
                    else
                    {
                        if (row.ReplaceID != null && row.ReplaceID.Length > 1)
                        {
                            FashionList.RowData replace = fashionList.GetByUID(row.ReplaceID[1]);
                            if (replace != null)
                            {
                                if (replace.EquipPos == row.EquipPos)
                                {
                                    row = replace;
                                }
                            }
                        }
                        string path = row.ModelPrefabArcher;
                        if (!string.IsNullOrEmpty(path))
                        {
                            Hash(ref tmpFashionData.hash, path);
                            TempEquipData data = new TempEquipData();
                            data.row  = row;
                            data.path = path;
                            tmpFashionData.data.Add(data);
                        }
                    }
                }
            }
            if (threePart)
            {
                return;
            }

            bool          findSame = false;
            TempEquipSuit suit     = tmpFashionData;
            if (suit.hash == 0)
            {
                return;
            }
            for (int j = 0; j < equipList.Count; ++j)
            {
                EquipPart part = equipList[j];
                if (part != null && part.hash == suit.hash)
                {
                    part.suitName.Add(name);
                    findSame = true;
                    break;
                }
            }
            if (!findSame)
            {
                EquipPart part = new EquipPart();
                part.hash = suit.hash;
                part.suitName.Add(name);
                for (int j = 0; j < suit.data.Count; ++j)
                {
                    TempEquipData data    = suit.data[j];
                    int           partPos = ConvertPart(data.row.EquipPos);
                    if (partPos < part.partPath.Length)
                    {
                        part.partPath[partPos] = data.path;
                    }
                    else if (partPos == part.partPath.Length)
                    {
                        part.mainWeapon = data.path;
                    }
                }
                equipList.Add(part);
            }
        }
    }