예제 #1
0
        private int farcType(string farcName)
        {
            string chaname = farcName.Substring(0, 3);

            if (chaname.Equals("cmn"))
            {
                return(0);
            }
            CharacterTbl      chaTbl = findCharactor(getStandardName(chaname));
            CharacterItemBean cib    = chaTbl.findItemByNo(Int32.Parse(farcName.Replace(chaname + "itm", "").Replace(".farc", "")));

            if (cib.sub_id == 10)
            {
                return(1);
            }
            else
            {
                return(2);
            }
        }
예제 #2
0
        public void loopObjsetFolder(string objsetpath)
        {
            var           files = Directory.GetFiles(objsetpath, "*.farc");
            List <String> items = new List <string>();

            foreach (var file in files)
            {
                String farcName  = file.ToString().Replace(objsetpath + "\\", "", StringComparison.InvariantCultureIgnoreCase);
                string cha       = farcName.Substring(0, 3);
                string farcName1 = farcName.Replace(".farc", "");
                if (farcName1.Substring(6).Equals("000"))
                {
                    continue;
                }
                switch (farcType(farcName))
                {
                case 0:
                    int no = mikTbl.findItemByNo(Int32.Parse(farcName1.Replace("cmnitm", ""))).no;
                    copyCustomizeItemByObjId(no, " " + logs.farcPath.Substring(logs.farcPath.Length - 4));
                    break;

                case 1:
                    copyModuleWithNewBody(farcName1, " " + logs.farcPath.Substring(logs.farcPath.Length - 4));
                    break;

                case 2:
                    items.Add(farcName1);
                    break;
                }
            }
            //不止替换身体的模组
            foreach (String s in items)
            {
                //额外配件的信息
                String            cha   = s.Substring(0, 3);
                int               chano = Int32.Parse(s.Replace(cha + "itm", ""));
                CharacterItemBean cib   = copyItemByNo(getStandardName(cha), chano);
                //遍历添加的模组
                foreach (ModuleLogBean mlb in logs.modules)
                {
                    //此模组与额外配件角色对应
                    if (mlb.newModule.chara.Equals(getStandardName(cha), StringComparison.InvariantCultureIgnoreCase))
                    {
                        //替换配件
                        foreach (ItemBean ib in findCharactor(mlb.newModule.chara).findCosById(mlb.newCos.id).item)
                        {
                            if (ib.item.Equals(chano.ToString()))
                            {
                                ib.item = cib.no.ToString();
                            }
                        }
                    }
                }
            }
            //特殊处理换色零件
            if (allowTextureReplace)
            {
                foreach (ItemLogBean ilb in logs.items)
                {
                    if ((ilb.newItem.attr != 1) && (ilb.newItem.sub_id != 24))
                    {
                        //非脸换色
                        foreach (ItemLogBean ilb2 in logs.items)
                        {
                            if ((ilb2.newItem.attr == 1) && (ilb.newItem.objset[0].objset.Equals(ilb2.oldItem.objset[0].objset)))
                            //是原件&&旧原件name==新原件name
                            {
                                ilb.newItem.objset[0].objset  = ilb2.newItem.objset[0].objset;
                                ilb.newItem.dataObjUid[0].uid = ilb2.newItem.dataObjUid[0].uid;
                                ilb.newItem.org_itm           = ilb2.newItem.no;
                                findCharactor(ilb.charactor).updataItemByNo(ilb.newItem);
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        public CharacterItemBean copyItemByNo(String charactor, int no, int itemid = -1, Boolean isTexReplaceAndCopyOri = false)
        //复制角色零件
        {
            //复制item
            CharacterTbl      chaTbl  = findCharactor(charactor);
            CharacterItemBean newitem = new CharacterItemBean(chaTbl.findItemByNo(no));

            String oriObjName = newitem.getObjsetName(allowTextureReplace);
            int    oriMeshNum = objdb.getMeshId(oriObjName);
            String oriUid     = objdb.getMeshName(oriObjName);

            newitem.name = newitem.name + " NEW";

            String objsetName = "";

            if (itemid == -1)
            {
                //添加普通角色配件
                newitem.no = chaTbl.lastItemNo + 1;
                objsetName = objdb.getCharacterNameUpper(charactor, 1);
            }
            else
            {
                //添加通用配件,因为要指定编号
                newitem.no = itemid;
                objsetName = "cmnitm" + itemid.ToString();
            }
            //sub_id非1的都是纹理替换更新第二个objset,特殊情况attr=9不知道什么意思
            if ((newitem.objsetLength == 1) || (!allowTextureReplace))
            {
                newitem.objset[0].objset = objsetName.ToUpper();
            }
            else
            {
                newitem.objset[1].objset = objsetName.ToUpper();
            }

            if ((newitem.sub_id == 24) && (newitem.objsetLength == 2))
            {
                //特殊处理 壱ノ桜・桜花顔 和 ctw 颜
                String t = newitem.objset[0].objset;
                newitem.objset[0].objset = newitem.objset[1].objset;
                newitem.objset[1].objset = t;
            }

            if ((newitem.attr != 1) && (!allowTextureReplace))
            {
                //不允许换色
                if (newitem.sub_id == 24)
                {
                    //脸,不能直接复制org_itm因为没有数据
                    //此外在copyFarc也要特殊处理
                    newitem.attr           = 1;
                    newitem.haveTexChg     = false;
                    newitem.haveTexOrg     = false;
                    newitem.haveTexLength  = false;
                    isTexReplaceAndCopyOri = true;
                }
                else
                {
                    //复制原色零件
                    return(copyItemByNo(charactor, newitem.org_itm, itemid, true));
                }
            }


            if (newitem.sub_id != 24)
            {
                String uid = objsetName
                             + oriUid.Replace(oriObjName, "", StringComparison.InvariantCultureIgnoreCase);

                //避免meshname长度变化
                if (uid.Length > oriUid.Length)
                {
                    uid = uid.Substring(0, oriUid.Length);
                }
                if (uid.Length < oriUid.Length)
                {
                    for (int i = uid.Length; i <= oriUid.Length - 1; i++)
                    {
                        uid = uid + "_";
                    }
                }

                newitem.dataObjUid[0].uid = uid.ToUpper();
            }


            chaTbl.addItem(newitem);
            //复制objdb
            String newObjName = newitem.getObjsetName(allowTextureReplace);

            objdb.add(newObjName,
                      objdb.lastId + 1,
                      newObjName + "_obj.bin",
                      newObjName + "_tex.bin",
                      newObjName + ".farc",
                      newitem.dataObjUid[0].uid,
                      0);

            logs.items.Add(new ItemLogBean(chaTbl.findItemByNo(no), oriMeshNum, newitem, charactor, isTexReplaceAndCopyOri));
            return(newitem);
        }