public void InitData(DummyProp dummyProp, Enity enity) { this.enity = enity; this.dummyProp = dummyProp; bool isSetDefault = false; long enityitemid = 0; if (this.enity != null) { if (this.enity.hero.dummyPropDic.ContainsKey(dummyProp)) { enityitemid = this.enity.hero.dummyPropDic[dummyProp]; if (DataManager.GetInstance().GetGameData().Items.ContainsKey(enityitemid)) { Item item = DataManager.GetInstance().GetGameData().Items[enityitemid]; AddEquipToItemsView(item); UpdateSelectItem(item); isSetDefault = true; } } } foreach (KeyValuePair <long, Item> item in DataManager.GetInstance().GetGameData().Items) { ItemTableData itemTableData = DataManager.GetInstance().GetItemTableDataByItemId(item.Value.itemId); if (itemTableData.group == (int)dummyProp && enityitemid != item.Key) { AddEquipToItemsView(item.Value); if (!isSetDefault) { UpdateSelectItem(item.Value); isSetDefault = true; } } } }
public Dictionary <DummyProp, List <string> > GetFileNameByPath(string path, string format) { Dictionary <DummyProp, List <string> > names = new Dictionary <DummyProp, List <string> >(); //1、获得当前运行程序的路径 string rootPath = Directory.GetCurrentDirectory(); //C#遍历指定文件夹中的所有文件 DirectoryInfo TheFolder = new DirectoryInfo(path); if (!TheFolder.Exists) { return(null); } DirectoryInfo[] directoryInfos = TheFolder.GetDirectories(); for (int i = 0; i < directoryInfos.Length; i++) { //FileInfo[] fileInfosAll = directoryInfos[i].GetFiles(directoryInfos[i].FullName, SearchOption.AllDirectories); DirectoryInfo[] directoryInfos2 = directoryInfos[i].GetDirectories(); for (int k = 0; k < directoryInfos2.Length; k++) { FileInfo[] fileInfos = directoryInfos2[k].GetFiles(); //遍历文件 foreach (FileInfo NextFile in fileInfos) { //if (NextFile.Name == "0-0-11.grid") // continue; // 获取文件完整路径 //string heatmappath = NextFile.FullName; DummyProp keyname = DummyProp.NULL; if (NextFile.Directory.Name.Contains("(Back)")) { keyname = DummyProp.Back; } if (NextFile.Directory.Name.Contains("(Head)")) { keyname = DummyProp.Head; } if (NextFile.Directory.Name.Contains("(R Arm)")) { keyname = DummyProp.Right; } if (NextFile.Directory.Name.Contains("(L Arm)")) { keyname = DummyProp.Left; } if (NextFile.Directory.Name.Contains("(Main Prefab)")) { keyname = DummyProp.Chest; } if (NextFile.Directory.Name.Contains("(Both Arms)")) { keyname = DummyProp.Left; } if (keyname != DummyProp.NULL) { if (!names.ContainsKey(keyname)) { names[keyname] = new List <string>(); } if (format == NextFile.Extension) { string name = NextFile.Name.Replace(format, "").Trim(); if (!name.Contains("Beard") && !name.Contains("FX") && !name.Contains("Hand Aura")) { names[keyname].Add(name); } } } } } } return(names); }
public void UpdateEquipsByDummyProp(long itemid, bool isAdd = true, bool isupdate = false) { Item item = DataManager.GetInstance().GetGameData().GetItemById(itemid); ItemTableData equipdata = DataManager.GetInstance().GetItemTableDataByItemId(item.itemId); if (equipdata != null) { DummyProp dummyProp = (DummyProp)equipdata.group; if (dummyProp_Enity.ContainsKey(dummyProp)) { GameObject obj = dummyProp_Enity[dummyProp]; dummyProp_Enity.Remove(dummyProp); Destroy(obj); } if (isAdd) { GameObject equip = DataManager.GetInstance().CreateGameObjectFromAssetsBundle("", equipdata.itemPrefab); if (equip != null && dummyProp_Parent.Count > (int)dummyProp) { dummyProp_Enity[dummyProp] = equip; equip.transform.SetParent(dummyProp_Parent[(int)dummyProp], false); } if (dummyProp == DummyProp.Chest)// 如果是护甲,获取护甲的动作类,需要一同播放 { Animator animatorChest = equip.GetComponent <Animator>(); if (animatorChest != null && !animatorList.Contains(animatorChest)) { animatorList.Add(animatorChest); } } if (dummyProp == DummyProp.Back)//如果是翅膀,改成飞行状态 { //isFly = true; //OnPlayAnimation(AnimatorParameters.FlyIdle, ActionParamtersType.Bool); } } if (isupdate)//刷新装备 { //Hero hero = DataManager.GetInstance().GetGameData().GetHeroById(heroId); if (hero != null) { Item olditem = null; Hero oldmaster = null; //先把当前装备脱下 if (hero.dummyPropDic.ContainsKey(dummyProp)) { long olditemid = hero.dummyPropDic[dummyProp]; olditem = DataManager.GetInstance().GetGameData().GetItemById(olditemid); hero.dummyPropDic.Remove(dummyProp); //olditem.masterId = 0; } if (isAdd) { hero.dummyPropDic[dummyProp] = itemid; if (item.masterId > 0)//之前有穿戴者,需要卸下来 { oldmaster = DataManager.GetInstance().GetGameData().GetHeroById(item.masterId); //if(oldmaster != null) //{ // oldmaster.dummyPropDic.Remove(dummyProp); //} } item.masterId = hero.id; } if (olditem != null) { olditem.masterId = oldmaster != null ? oldmaster.id : 0; } if (oldmaster != null) { if (olditem != null) { oldmaster.dummyPropDic[dummyProp] = olditem.id; } else { oldmaster.dummyPropDic.Remove(dummyProp); } } if (hero.teamPosition >= 0)//如果再阵容需要更新战斗场景 { //GameObject.Find("FightScene").SendMessage("InitFightingHero",null); } } } if (dummyProp == DummyProp.Left || dummyProp == DummyProp.Right)//更新动作 { Item itemEquip = GetEnityEquip(); if (itemEquip != null) { ItemTableData itemTableData = DataManager.GetInstance().GetItemTableDataByItem(itemEquip); if (itemTableData != null) { animationTableData = DataManager.GetInstance().GetAnimationTableDataById(itemTableData.animationId); if (isupdate) { OnPlayAnimation(animatorAction); } } } } } }