public void OnClickDemoButton(GameObject obj) { int floorId = 20101; SM.RandomRoomLevel.Singleton.m_curFloorId = floorId; CSItem item = null; Helper helper = User.Singleton.HelperList.LookupHelper(StageMenu.Singleton.m_curHelperGuid); if (null != helper) { item = new CSItem(); item.m_guid = helper.m_cardGuid; item.IDInTable = (short)helper.m_cardId; item.Level = helper.m_cardLevel; item.BreakCounts = helper.m_cardBreakCounts; item.Init(); // 测试用 HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(helper.m_cardId); if (null != heroInfo) { List <int> skillIDList = heroInfo.GetAllSkillIDList(); foreach (int skillId in skillIDList) { HeroCardSkill info = new HeroCardSkill(); info.m_skillID = skillId; item.AddSkill(info); } foreach (var item1 in heroInfo.PassiveSkillIDList) {//被动技能 HeroCardSkill info = new HeroCardSkill(); info.m_skillID = item1; item.AddSkill(info); } } } Team.Singleton.Comrade = item; BattleArena.Singleton.PrepareEnterDungeons(); // MainGame.Singleton.CurrentState.SwitchNexted = true; // StageMenu.Singleton.m_isReqHelpData = true; }
// 进入战斗准备界面 void OnHelperConfirm(object sender) { HideHelper(); CSItem item = null; Helper helper = User.Singleton.HelperList.LookupHelper(StageMenu.Singleton.m_curHelperGuid); if (null != helper) { item = new CSItem(); item.m_guid = helper.m_cardGuid; item.IDInTable = (short)helper.m_cardId; item.Level = helper.m_cardLevel; item.BreakCounts = helper.m_cardBreakCounts; item.Init(); // 测试用 HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(helper.m_cardId); if (null != heroInfo) { List <int> skillIDList = heroInfo.GetAllSkillIDList(); foreach (int skillId in skillIDList) { HeroCardSkill info = new HeroCardSkill(); info.m_skillID = skillId; item.AddSkill(info); } foreach (var item1 in heroInfo.PassiveSkillIDList) {//被动技能 HeroCardSkill info = new HeroCardSkill(); info.m_skillID = item1; item.AddSkill(info); } } } Team.Singleton.Comrade = item; BattleArena.Singleton.PrepareEnterDungeons(); //UpdateBattlePreparation(); }
// 更新信息 void UpdateInfo() { CSItem card = CardBag.Singleton.m_cardForDetail; if (null == card) { return; } // 如果卡牌ID为0则 是用预览卡牌(不是背包里的卡牌) 此时 加到最爱 进化 强化等按钮不显示 if (CardBag.Singleton.m_curOptinGuid.Equals(CSItemGuid.Zero)) { m_levelUpBtn.gameObject.SetActive(false); m_evolutionBtn.gameObject.SetActive(false); m_breachBtn.gameObject.SetActive(false); } else { m_levelUpBtn.gameObject.SetActive(card.IsStengthen()); m_evolutionBtn.gameObject.SetActive(card.IsEvlotion()); m_breachBtn.gameObject.SetActive(true); } m_grid.Reposition(); AddModel(card, m_model); HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(card.IDInTable); if (null == heroInfo) { Debug.LogWarning("heroInfo == NULL heroInfo cardID:" + card.IDInTable); return; } m_cardPanel.Update(card.IDInTable); IconInfomation iconInfo = GameTable.IconInfoTableAsset.Lookup(heroInfo.ImageId); OccupationInfo occupationInfo = GameTable.OccupationInfoAsset.LookUp(heroInfo.Occupation); RaceInfo raceInfo = GameTable.RaceInfoTableAsset.LookUp(heroInfo.Type); // LevelUpInfo levelupInfo = GameTable.LevelUpTableAsset.LookUp(card.Level); m_cost.text = "" + heroInfo.Cost; m_phyAttack.text = "" + (int)card.GetPhyAttack(); m_magAttack.text = "" + (int)card.GetMagAttack(); m_hp.text = "" + (int)card.GetHp(); m_occupation.text = occupationInfo.m_name; m_type.text = raceInfo.m_name; m_curLevel.text = "" + card.Level; m_maxLevel.GetComponent <UILabel>().text = card.GetMaxLevel().ToString(); IconInfomation icon = GameTable.IconInfoTableAsset.Lookup(occupationInfo.m_iconId); m_occTexture.GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); icon = GameTable.IconInfoTableAsset.Lookup(raceInfo.m_iconId); m_raceTexture.GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); // 段位升级 UpdateDanData(card.BreakCounts); foreach (UICardDetailSkillItem item in m_skillList) { if (null != item) { item.HideWindow(); } } foreach (UICardDetailSkillItem item in m_passvieSkillList) { if (null != item) { item.HideWindow(); } } int i = 0; List <int> skillIDList = heroInfo.GetAllSkillIDList(); foreach (int skillId in skillIDList) { if (0 != heroInfo.NormalSkillIDList.Find(item => item == skillId)) { continue; } SkillInfo skillInfo = GameTable.SkillTableAsset.Lookup(skillId); if (null == skillInfo) { continue; } // 普通技能才被列入 if (skillInfo.SkillType != 0) { continue; } iconInfo = GameTable.IconInfoTableAsset.Lookup(skillInfo.Icon); if (null == iconInfo) { continue; } if (i < m_skillList.Length) { UICardDetailSkillItem item = m_skillList[i]; if (null == item) { item = UICardDetailSkillItem.Create(); m_skillList[i] = item; item.SetParent(m_skillParent.transform); item.SetPressCallbacked(OnShowTips); item.SetClickCallbacked(OnHideTips); } item.ShowWindow(); item.Update(skillId); i++; } } m_skillParent.GetComponent <UIGrid>().Reposition(); i = 0; bool bNone = true; foreach (int skillId in heroInfo.PassiveSkillIDList) { SkillInfo skillInfo = GameTable.SkillTableAsset.Lookup(skillId); if (null == skillInfo) { continue; } iconInfo = GameTable.IconInfoTableAsset.Lookup(skillInfo.Icon); if (null == iconInfo) { continue; } if (i >= m_passvieSkillList.Length) { continue; } bNone = false; UICardDetailSkillItem item = m_passvieSkillList[i]; if (null == item) { item = UICardDetailSkillItem.Create(); m_passvieSkillList[i] = item; item.SetParent(m_passiveSkillParent.transform); item.SetPressCallbacked(OnShowTips); item.SetClickCallbacked(OnHideTips); } item.ShowWindow(); item.Update(skillId); i++; } m_passiveSkillParent.GetComponent <UIGrid>().Reposition(); m_skillNoneLabel.gameObject.SetActive(bNone); }
void UpdateCardInfo(int cardId) { Debug.Log("UpdateCardInfo:" + cardId); m_cardDetail.SetActive(true); HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(cardId); if (null == heroInfo) { return; } Login.Singleton.m_curCardId = cardId; IconInfomation iconInfo = GameTable.IconInfoTableAsset.Lookup(heroInfo.ImageId); m_infoName.text = heroInfo.StrName; RarityRelativeInfo rarityInfo = GameTable.RarityRelativeAsset.LookUp(heroInfo.Rarity); IconInfomation icon = GameTable.IconInfoTableAsset.Lookup(rarityInfo.m_iconId); m_star.GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); m_cardPic.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName); OccupationInfo occInfo = GameTable.OccupationInfoAsset.LookUp(heroInfo.Occupation); RaceInfo raceInfo = GameTable.RaceInfoTableAsset.LookUp(heroInfo.Type); m_infoOp.text = occInfo.m_name; m_ocInfo.text = occInfo.m_name; m_raceInfo.text = raceInfo.m_name; m_ocDetail.text = occInfo.m_describe; int i = 0; List <int> skillIDList = heroInfo.GetAllSkillIDList(); foreach (int skillId in skillIDList) { SkillInfo skillInfo = GameTable.SkillTableAsset.Lookup(skillId); if (null == skillInfo || 0 != skillInfo.SkillType) { continue; } iconInfo = GameTable.IconInfoTableAsset.Lookup(skillInfo.Icon); if (iconInfo == null) { Debug.LogWarning("iconInfo 为空 skillId:" + skillId + ",skillInfo.Icon:" + skillInfo.Icon); continue; } if (m_skillList.ContainsKey(skillId)) { GameObject obj = m_skillList[skillId]; obj.SetActive(true); obj.GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName); Parma parma = obj.GetComponent <Parma>(); parma.m_id = skillId; } else { GameObject copy = GameObject.Instantiate(m_skillItem.gameObject) as GameObject; copy.transform.parent = m_skillParent.transform; copy.transform.localScale = m_skillItem.transform.localScale; copy.gameObject.SetActive(true); copy.transform.LocalPositionX(0 + i * 90f); copy.transform.LocalPositionY(-45f); copy.GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName); copy.name = copy.name + i; Parma parma = copy.GetComponent <Parma>(); parma.m_id = skillId; EventDelegate.Add(copy.GetComponent <UIEventTrigger>().onPress, OnShowTips); AddChildMouseClickEvent(copy.name, OnHideTips); m_skillList.Add(skillId, copy); } i++; } }
//更新荣誉戒指商店界面 void UpDateRingOfHonorShopUI() { int ring = User.Singleton.UserProps.GetProperty_Int32(UserProperty.ring); int index = 1; foreach (RingOfHonorInfo item in ShopProp.Singleton.m_ringOfHonorList) { UIDragScrollView copy = GameObject.Instantiate(m_ringItem) as UIDragScrollView; copy.GetComponent <Parma>().m_id = item.m_infoId; copy.GetComponent <Parma>().m_type = item.m_cardId; copy.transform.Find("Exchange").GetComponent <UIButton>().transform.Find("RingNum").GetComponent <UILabel>().text = item.m_price.ToString(); //如果戒指数量不足 按钮为灰色 if (ring < item.m_price) { copy.transform.Find("Exchange").GetComponent <UIButton>().enabled = false; } //设置卡牌显示 兑换时间 RingExchangeTableInfo info = GameTable.RingExchangeTableAsset.Lookup(item.m_infoId); UISlider timeSlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("ExchangeTime").GetComponent <UISlider>(); timeSlider.transform.Find("StartTime").GetComponent <UILabel>().text = info.startDate + "~"; timeSlider.transform.Find("EndTime").GetComponent <UILabel>().text = info.endDate; //获得卡牌信息 HeroInfo heroInfo = GameTable.HeroInfoTableAsset.Lookup(item.m_cardId); //设置卡牌名字 copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("Name").GetComponent <UILabel>().text = heroInfo.StrName; copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("Name").GetComponent <UILabel>().text = heroInfo.StrName; //设置种族职业 UISlider typeSlider = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("TypePanel").GetComponent <UISlider>(); typeSlider.transform.Find("Type").GetComponent <UILabel>().text = GameTable.RaceInfoTableAsset.LookUp(heroInfo.Type).m_name; UISlider occupationSlider = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("OccupationPanel").GetComponent <UISlider>(); occupationSlider.transform.Find("Occupation").GetComponent <UILabel>().text = GameTable.OccupationInfoAsset.LookUp(heroInfo.Occupation).m_name; UITexture occupationSprite = occupationSlider.transform.Find("Texture").GetComponent <UITexture>(); //设置职业图标 OccupationInfo occInfo = GameTable.OccupationInfoAsset.LookUp(heroInfo.Occupation); IconInfomation occicon = GameTable.IconInfoTableAsset.Lookup(occInfo.m_iconId); occupationSprite.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(occicon.dirName); //设置星级 UISlider raritySlider = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("RarityPanel").GetComponent <UISlider>(); RarityRelativeInfo rarityInfo = GameTable.RarityRelativeAsset.LookUp(heroInfo.Rarity); IconInfomation icon = GameTable.IconInfoTableAsset.Lookup(rarityInfo.m_iconId); raritySlider.transform.Find("Rarity").GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); icon = GameTable.IconInfoTableAsset.Lookup(heroInfo.ImageId); //设置卡牌图片 copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("Card").GetComponent <UITexture>().mainTexture = PoolManager.Singleton.LoadIcon <Texture>(icon.dirName); //设置魔法攻击力 UISlider magicSlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("MaxMagAttackPanel").GetComponent <UISlider>(); // RarityRelativeInfo rarityRelative = GameTable.RarityRelativeAsset.LookUp(heroInfo.Rarity); magicSlider.transform.Find("MagAttackNum").GetComponent <UILabel>().text = BattleFormula.GetMagAttack(item.m_cardId, 1) + ""; UISlider phySlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("MaxPhyAttackPanel").GetComponent <UISlider>(); phySlider.transform.Find("PhyAttackNum").GetComponent <UILabel>().text = BattleFormula.GetPhyAttack(item.m_cardId, 1) + ""; //设置生命值 UISlider hpSlider = copy.transform.Find("CardDetail").GetComponent <UISlider>().transform.Find("CardNamePanel").transform.Find("MaxHpPanel").GetComponent <UISlider>(); hpSlider.transform.Find("MaxHpNum").GetComponent <UILabel>().text = BattleFormula.GetHp(item.m_cardId, 1) + ""; //设置卡牌编号 UILabel cardNum = copy.transform.Find("Attribute").GetComponent <UISlider>().transform.Find("CardNumText").GetComponent <UILabel>(); cardNum.text = string.Format(Localization.Get("MercenaryNum"), heroInfo.CardId); copy.transform.parent = FindChildComponent <UIGrid>("CardGridList").transform; // 设置大小 copy.transform.localScale = m_ringItem.transform.localScale; copy.gameObject.SetActive(true); //设置主动技能 IconInfomation iconInfo = null; SkillInfo skillInfo = null; int skillIndex = 1; List <int> skillIDList = heroInfo.GetAllSkillIDList(); foreach (int skillId in skillIDList) { skillInfo = GameTable.SkillTableAsset.Lookup(skillId); if (0 == skillInfo.SkillType) { UITexture copySkillItem = GameObject.Instantiate(m_skillItem) as UITexture; copySkillItem.GetComponent <Parma>().m_id = skillId; copySkillItem.transform.localScale = m_skillItem.transform.lossyScale; copySkillItem.gameObject.SetActive(true); iconInfo = GameTable.IconInfoTableAsset.Lookup(skillInfo.Icon); copySkillItem.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName); copySkillItem.name = copySkillItem.name + skillIndex; copySkillItem.transform.parent = copy.transform.Find("CardDetail").transform.Find("Skill").transform; EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onPress, OnShowTips); EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onClick, OnHideTips); //AddChildMouseClickEvent(copySkillItem.name, OnHideTips); } skillIndex++; } m_skillGirdList.Reposition(); //设置被动技能 int passiveIndex = 1; foreach (int skillId in heroInfo.PassiveSkillIDList) { skillInfo = GameTable.SkillTableAsset.Lookup(skillId); if (0 == skillInfo.SkillType) { UISprite copySkillItem = m_skillItem.gameObject.AddComponent <UISprite>(); copySkillItem.GetComponent <Parma>().m_id = skillId; copySkillItem.transform.localScale = m_skillItem.transform.lossyScale; copySkillItem.gameObject.SetActive(true); iconInfo = GameTable.IconInfoTableAsset.Lookup(skillInfo.Icon); copySkillItem.mainTexture = PoolManager.Singleton.LoadIcon <Texture>(iconInfo.dirName); copySkillItem.name = copySkillItem.name + skillIndex; copySkillItem.transform.parent = copy.transform.Find("CardDetail").transform.Find("PassiveSkill").transform; EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onPress, OnShowTips); EventDelegate.Add(copySkillItem.GetComponent <UIEventTrigger>().onClick, OnHideTips); //AddChildMouseClickEvent(copySkillItem.name, OnHideTips); } passiveIndex++; } m_ringHonorGridList.Add(index, copy); AddMouseClickEvent(copy.transform.Find("Exchange").gameObject, OnBuyRingCardButton); index++; } for (; index < m_ringHonorGridList.Count; index++) { m_ringHonorGridList[index].gameObject.SetActive(false); m_ringHonorGridList[index].GetComponent <Parma>().m_id = 0; m_ringHonorGridList[index].GetComponent <Parma>().m_type = 0; } m_cardGridList.Reposition(); }
//打开 void Open(bool isTest = false, int testID = 0, Info.ENTabelType testType = Info.ENTabelType.enNone) { Delete(); Info.ENTabelType type = Info.ENTabelType.enNone; int modelID = 0, weaponID = 0; List <int> allSkillIDList = new List <int>(); int id = 0; if (isTest) {//测试用 id = testID; if (testType == Info.ENTabelType.enHero) { type = Info.ENTabelType.enHero; HeroInfo heroInfo = m_heroTabel.Lookup(id); modelID = heroInfo.ModelId; weaponID = heroInfo.WeaponId; allSkillIDList = heroInfo.GetAllSkillIDList(); } else { type = Info.ENTabelType.enNPC; NPCInfo npcInfo = m_npcTabel.Lookup(id); modelID = npcInfo.ModelId; weaponID = npcInfo.WeaponID; allSkillIDList.AddRange(npcInfo.SkillList); allSkillIDList.Add(npcInfo.StaminaSkillID); } } else { id = m_idList[m_index]; if (m_tableIndex == 0) { type = Info.ENTabelType.enHero; HeroInfo heroInfo = m_heroTabel.Lookup(id); modelID = heroInfo.ModelId; weaponID = heroInfo.WeaponId; allSkillIDList = heroInfo.GetAllSkillIDList(); } else { type = Info.ENTabelType.enNPC; NPCInfo npcInfo = m_npcTabel.Lookup(id); modelID = npcInfo.ModelId; weaponID = npcInfo.WeaponID; allSkillIDList.AddRange(npcInfo.SkillList); allSkillIDList.Add(npcInfo.StaminaSkillID); } } ModelInfo modelInfo = m_modelTable.Lookup(modelID); if (modelInfo == null) { Debug.LogError("model error,modelID:" + modelID + ",card id:" + id + ",type:" + type.ToString()); return; } WeaponInfo weaponInfo = m_weaponTable.Lookup(weaponID); if (weaponInfo == null) { Debug.LogError("weapon error,weaponID:" + weaponID + ",card id:" + id + ",type:" + type.ToString()); return; } m_currentInfo.m_tabelType = type; m_currentInfo.m_tabelID = id; m_currentInfo.m_modelType = modelInfo.modelType; m_currentInfo.m_weaponType = (int)weaponInfo.WeaponType; List <int> skillIDList = new List <int>(); foreach (var item in allSkillIDList) {//删除相同的技能id if (!skillIDList.Contains(item)) { skillIDList.Add(item); } } GetAnimationList(skillIDList); //加载模型,并给模型加一个父 GameObject parentObj = new GameObject(); m_currentObj = parentObj; parentObj.transform.parent = ObjPanel.transform; GameObject modelObj = GameObject.Instantiate(GameData.LoadPrefab <GameObject>(modelInfo.ModelFile)) as GameObject; modelObj.name = "body"; ObjEffect.GetComponent <EDSkillEventTrigger>().MainObj = modelObj; parentObj.name = modelObj.name + "_parent"; modelObj.transform.parent = parentObj.transform; parentObj.AddComponent <AnimationCameraCallback>(); parentObj.AddComponent <AnimationEffectCallback>(); parentObj.AddComponent <AnimationEndCallback>(); parentObj.AddComponent <AnimationShaderParamCallback>(); parentObj.AddComponent <AnimationSoundCallback>(); parentObj.AddComponent <BreakPointCallback>(); parentObj.AddComponent <AttackActionCallback>(); #region//加载模型的父的animation Animation parentAnim = parentObj.AddComponent <Animation>(); string path = "Assets/Resources/SkillAnim/"; foreach (var item in m_skillAnimList) { Info.AnimInfo info = null; m_currentInfo.m_animMap.TryGetValue(item, out info); string filename = m_currentInfo.m_modelType.ToString() + "-" + m_currentInfo.m_weaponType.ToString() + "-" + info.m_skillID.ToString() + "-" + ((int)info.m_skillStepType).ToString() + "-" + info.m_animName + ".anim"; string assetPath = path + filename; AnimationClip clip = AssetDatabase.LoadMainAssetAtPath(assetPath) as AnimationClip; if (clip != null) { parentAnim.AddClip(clip, item); } else { Debug.Log("load clip failed, path:" + assetPath); } } #endregion #region//加载模型的脚本和animation if (modelObj.GetComponent <AnimationCameraCallback>() == null) { modelObj.AddComponent <AnimationCameraCallback>(); } if (modelObj.GetComponent <AnimationEffectCallback>() == null) { modelObj.AddComponent <AnimationEffectCallback>(); } if (modelObj.GetComponent <AnimationEndCallback>() == null) { modelObj.AddComponent <AnimationEndCallback>(); } if (modelObj.GetComponent <AnimationShaderParamCallback>() == null) { modelObj.AddComponent <AnimationShaderParamCallback>(); } if (modelObj.GetComponent <AnimationSoundCallback>() == null) { modelObj.AddComponent <AnimationSoundCallback>(); } if (modelObj.GetComponent <BreakPointCallback>() == null) { modelObj.AddComponent <BreakPointCallback>(); } if (modelObj.GetComponent <AttackActionCallback>() == null) { modelObj.AddComponent <AttackActionCallback>(); } if (LoadAnimationClip(modelObj, modelInfo.modelType, (int)weaponInfo.WeaponType)) { Animation modelAnim = modelObj.GetComponent <Animation>(); //加载模型的事件 foreach (var item in m_skillAnimList) { Info.AnimInfo info = null; m_currentInfo.m_animMap.TryGetValue(item, out info); AnimationClip copyClip = modelAnim.GetClip(GetFullAnimName(info.m_animName, m_currentInfo.m_modelType, m_currentInfo.m_weaponType)); if (copyClip == null) { Debug.LogError("body get animation failed, anim:" + info.m_animName); } modelAnim.AddClip(copyClip, item); AnimationClip modelClip = modelAnim.GetClip(item); AnimationClip parentClip = parentAnim.GetClip(item); if (parentClip != null) {//从parentObj中获取事件信息 AnimationClipCurveData[] array = AnimationUtility.GetAllCurves(parentClip); foreach (var data in array) { if (!m_typeList.Contains(data.type.BaseType)) { continue; } string dataPath = ""; if (data.path.Contains("body")) { dataPath = data.path.Substring(4); } else if (data.path.Contains("body/")) { dataPath = data.path.Substring(5); } modelClip.SetCurve(dataPath, data.type, data.propertyName, data.curve); } AnimationUtility.SetAnimationEvents(modelClip, AnimationUtility.GetAnimationEvents(parentClip)); } else {//获取原来的事件信息,存储在resources/skillanim目录下 string dir = "assets/resources/skillanim/"; string animName = "a-" + m_currentInfo.m_modelType.ToString() + "-w" + m_currentInfo.m_weaponType.ToString() + "-" + info.m_animName + ".anim"; UnityEngine.Object tempObj = AssetDatabase.LoadMainAssetAtPath(dir + animName); if (tempObj == null) { //Debug.LogWarning("animation name:" + animName); //resources/skillanim目录下不存在 //从原动作中获取 AnimationClip bodyClip = modelAnim.GetClip(info.m_animName); if (bodyClip == null) { Debug.LogError("animation is null, name:" + info.m_animName); } else { AnimationClipCurveData[] array = AnimationUtility.GetAllCurves(bodyClip); foreach (var data in array) { if (!m_typeList.Contains(data.type.BaseType)) { continue; } //if (!string.IsNullOrEmpty(data.path)) //{//不是body下的 // continue; //} modelClip.SetCurve(data.path, data.type, data.propertyName, data.curve); } AnimationUtility.SetAnimationEvents(modelClip, AnimationUtility.GetAnimationEvents(bodyClip)); } } else { AnimationClip clip = GameObject.Instantiate(tempObj) as AnimationClip; AnimationClipCurveData[] array = AnimationUtility.GetAllCurves(clip); foreach (var data in array) { if (!m_typeList.Contains(data.type.BaseType)) { continue; } //if (!string.IsNullOrEmpty(data.path)) //{//不是body下的 // continue; //} modelClip.SetCurve(data.path, data.type, data.propertyName, data.curve); } AnimationUtility.SetAnimationEvents(modelClip, AnimationUtility.GetAnimationEvents(clip)); GameObject.DestroyImmediate(clip); } } } } else { Debug.LogError("LoadAnimationClip failed"); } #endregion #region//加载武器 if (weaponInfo.LeftModelID != 0) { Transform leftArmParentTrans = Actor.S_LookupBone2(modelObj.transform, weaponInfo.LeftPoint); ArmLoad(leftArmParentTrans, weaponInfo.LeftModelID, weaponInfo.IsHideLeftModel); } if (weaponInfo.RightModelID != 0) { Transform rightArmParentTrans = Actor.S_LookupBone2(modelObj.transform, weaponInfo.RightPoint); ArmLoad(rightArmParentTrans, weaponInfo.RightModelID, weaponInfo.IsHideRightModel); } #endregion #region//刷新动画列表 Animation AniList = modelObj.GetComponent <Animation>(); m_loadedAnimationList.Clear(); foreach (AnimationState state in AniList) { m_loadedAnimationList.Add(state.name); } m_loadedAnimationList.AddRange(m_skillAnimList); m_playingAniIndex = m_loadedAnimationList.Count - 1; ED_SimActorManager.Instance.Clear(); ED_SimActorManager.Instance.AddActor(m_currentObj); #endregion Selection.activeObject = modelObj; }