/// <summary> /// 重置当前选中技能的选择技能 /// </summary> private void ResetCombineSkillLattice() { //重置技能 if (nowSelectSkillItem && nowUISkilCombineLattice) { //判断当前锁定框的位置并修改技能 int level = nowUISkilCombineLattice.Level; EnumSkillType[] thisCombineSkillTypes = nowCombineSkillItem.value as EnumSkillType[]; EnumSkillType[] tempCombineSkillTypes = thisCombineSkillTypes.Clone() as EnumSkillType[]; tempCombineSkillTypes[level - 1] = (EnumSkillType)nowSelectSkillItem.value; if (SkillCombineStaticTools.GetCanCombineSkills(tempCombineSkillTypes) ||//该框内是否可以使用该技能 tempCombineSkillTypes.Count(temp => temp == EnumSkillType.None) == 4 //说明都是空的 ) { thisCombineSkillTypes[level - 1] = (EnumSkillType)nowSelectSkillItem.value; //修改组合框的图标 SetSkillCombineLatticeAndShowVadio(thisCombineSkillTypes); //修改组合技能集合中选中技能的名字 if (nowCombineSkillItem) { int key = SkillCombineStaticTools.GetCombineSkillKey(thisCombineSkillTypes); nowCombineSkillItem.childText.text = CombineSkillText(key); } } } //切换状态到技能框 uiSelectSkillList.gameObject.SetActive(false); enumUISkillCombine = EnumUISkillCombine.CombineSkillLattice; }
private void OnEnable() { UIManager.Instance.KeyUpHandle += Instance_KeyUpHandle; //重新载入数据 skillStructData_Base = DataCenter.Instance.GetMetaData <SkillStructData>(); //元数据 playerState = DataCenter.Instance.GetEntity <PlayerState>(); //玩家状态 uiCombineSkillList.Init(); foreach (EnumSkillType[] skillTypes in playerState.CombineSkills) { SkillBaseStruct[] thisUsedSkills = skillStructData_Base.SearchSkillDatas(temp => skillTypes.Contains(temp.skillType)); int key = SkillCombineStaticTools.GetCombineSkillKey(thisUsedSkills.Select(temp => temp.skillType)); UIListItem thisUIListItem = uiCombineSkillList.NewItem(); thisUIListItem.value = thisUsedSkills.Select(temp => temp.skillType).ToArray(); thisUIListItem.childText.text = CombineSkillText(key); } if (playerState.CombineSkills.Count < 30) { for (int i = 0; i < 30 - playerState.CombineSkills.Count; i++) { UIListItem thisUIListItem = uiCombineSkillList.NewItem(); thisUIListItem.value = new EnumSkillType[4]; thisUIListItem.childText.text = "[None]"; } } uiCombineSkillList.UpdateUI(); //重设状态 enumUISkillCombine = EnumUISkillCombine.CombineSkillItem; uiCombineSkillList.CanClickListItem = true; nowCombineSkillItem = uiCombineSkillList.FirstShowItem(); uiCombineSkillList.ShowItem(nowCombineSkillItem); if (nowCombineSkillItem) { nowCombineSkillItem.childImage.enabled = true; nowCombineSkillItem.childImage.gameObject.SetActive(true); SetSkillCombineLatticeAndShowVadio((EnumSkillType[])nowCombineSkillItem.value); } }
private void OnGUI() { if (skillTypeToParticalNameDic == null) { return; } EditorGUILayout.BeginHorizontal(); //左侧的选择配置项按钮面板 EditorGUILayout.BeginVertical(GUILayout.Width(250)); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("保存", GUILayout.Width(35))) { string valueText = SerializeNow(skillTypeToParticalNameDic); File.WriteAllText(dataDirecotryPath + "/CombinePartical.txt", valueText, Encoding.UTF8); EditorUtility.DisplayDialog("保存数据", "保存成功!", "确认"); } GUILayout.Space(100); if (GUILayout.Button("增量加载资源", GUILayout.Width(100))) { ParticalManager.IncrementalLoad(); } EditorGUILayout.EndHorizontal(); if (GUILayout.Button("添加", GUILayout.Width(35))) { if (!skillTypeToParticalNameDic.ContainsKey(-1)) { skillTypeToParticalNameDic.Add(-1, "None"); } else { EditorUtility.DisplayDialog("提示", "请先编辑之前添加的数据!", "确认"); } } leftScroll = EditorGUILayout.BeginScrollView(leftScroll); KeyValuePair <int, string>[] tempValues = skillTypeToParticalNameDic.ToArray(); Type enumType = typeof(EnumSkillType); foreach (KeyValuePair <int, string> tempValue in tempValues) { EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("×", GUILayout.Width(15))) { if (EditorUtility.DisplayDialog("警告!", "将会减去该数据!", "确认", "取消")) { skillTypeToParticalNameDic.Remove(tempValue.Key); } } if (object.Equals(tempValue.Key, selectKey)) { GUILayout.Space(30); } string[] showNames = new string[0]; EnumSkillType[] thisSkillTyps = SkillCombineStaticTools.GetCombineSkills(tempValue.Key); if (thisSkillTyps != null) { showNames = thisSkillTyps.Select <EnumSkillType, string>(temp => { FieldInfo fieldInfo = enumType.GetField(temp.ToString()); if (fieldInfo == null) { return(""); } FieldExplanAttribute fieldExplanAttribute = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).Select(innerTemp => innerTemp as FieldExplanAttribute).Where(innerTemp => innerTemp != null).FirstOrDefault(); if (fieldExplanAttribute == null) { return(""); } return(fieldExplanAttribute.GetExplan()); }).Where(temp => !string.IsNullOrEmpty(temp)).ToArray(); } string showName = showNames.Length > 0 ? string.Join("+", showNames) : "None"; if (GUILayout.Button(showName)) { if (object.Equals(tempValue.Key, selectKey)) { selectKey = 0; } else { selectKey = tempValue.Key; nowSelectSkillTyps = thisSkillTyps; } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); //第一个技能 EditorGUILayout.BeginVertical(); if (nowSelectSkillTyps == null || nowSelectSkillTyps.Length < 1) { nowSelectSkillTyps = new EnumSkillType[] { EnumSkillType.None } } ; var enumSkillTypes_First = allSkillTypes.Select(temp => { FieldInfo fieldInfo = enumType.GetField(temp.ToString()); if (fieldInfo == null) { return new { type = temp, str = "" } } ; FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault(); if (fieldExplanAttriubte == null) { return new { type = temp, str = "" } } ; return(new { type = temp, str = fieldExplanAttriubte.GetExplan() }); }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type < EnumSkillType.MagicCombinedLevel1End).Reverse(); int index_First = enumSkillTypes_First.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[0]); int nowIndex_First = EditorGUILayout.Popup(index_First, enumSkillTypes_First.Select(temp => temp.str).ToArray()); if (nowIndex_First > -1 && nowIndex_First < enumSkillTypes_First.Count()) { EnumSkillType selectEnumSkillType = enumSkillTypes_First.ToArray()[nowIndex_First].type; nowSelectSkillTyps[0] = selectEnumSkillType; } if (nowSelectSkillTyps[0] < EnumSkillType.MagicCombinedLevel1Start) { EnumSkillType[] tempArray = nowSelectSkillTyps; nowSelectSkillTyps = new EnumSkillType[1]; Array.Copy(tempArray, nowSelectSkillTyps, 1); } //第二个技能 if (nowSelectSkillTyps.Length > 0 && nowSelectSkillTyps[0] > EnumSkillType.MagicCombinedLevel1Start) { if (nowSelectSkillTyps.Length < 2) { EnumSkillType[] tempArray = nowSelectSkillTyps; nowSelectSkillTyps = new EnumSkillType[2]; Array.Copy(tempArray, nowSelectSkillTyps, 1); } var enumSkillTypes_Second = allSkillTypes.Select(temp => { FieldInfo fieldInfo = enumType.GetField(temp.ToString()); if (fieldInfo == null) { return new { type = temp, str = "" } } ; FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault(); if (fieldExplanAttriubte == null) { return new { type = temp, str = "" } } ; return(new { type = temp, str = fieldExplanAttriubte.GetExplan() }); }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type <EnumSkillType.MagicCombinedLevel2End && temp.type> EnumSkillType.MagicCombinedLevel2Start); int index_Second = enumSkillTypes_Second.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[1]); int nowIndex_Second = EditorGUILayout.Popup(index_Second, enumSkillTypes_Second.Select(temp => temp.str).ToArray()); if (nowIndex_Second > -1 && nowIndex_Second < enumSkillTypes_Second.Count()) { EnumSkillType selectEnumSkillType = enumSkillTypes_Second.ToArray()[nowIndex_Second].type; nowSelectSkillTyps[1] = selectEnumSkillType; } } //第三个技能 if (nowSelectSkillTyps.Length > 1 && nowSelectSkillTyps[1] > EnumSkillType.MagicCombinedLevel2Start) { if (nowSelectSkillTyps.Length < 3) { EnumSkillType[] tempArray = nowSelectSkillTyps; nowSelectSkillTyps = new EnumSkillType[3]; Array.Copy(tempArray, nowSelectSkillTyps, 2); } var enumSkillTypes_Third = allSkillTypes.Select(temp => { FieldInfo fieldInfo = enumType.GetField(temp.ToString()); if (fieldInfo == null) { return new { type = temp, str = "" } } ; FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault(); if (fieldExplanAttriubte == null) { return new { type = temp, str = "" } } ; return(new { type = temp, str = fieldExplanAttriubte.GetExplan() }); }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type <EnumSkillType.MagicCombinedLevel3End && temp.type> EnumSkillType.MagicCombinedLevel3Start); int index_Third = enumSkillTypes_Third.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[2]); int nowIndex_Third = EditorGUILayout.Popup(index_Third, enumSkillTypes_Third.Select(temp => temp.str).ToArray()); if (nowIndex_Third > -1 && nowIndex_Third < enumSkillTypes_Third.Count()) { EnumSkillType selectEnumSkillType = enumSkillTypes_Third.ToArray()[nowIndex_Third].type; nowSelectSkillTyps[2] = selectEnumSkillType; } } //第四个技能 if (nowSelectSkillTyps.Length > 2 && nowSelectSkillTyps[2] > EnumSkillType.MagicCombinedLevel3Start) { if (nowSelectSkillTyps.Length < 4) { EnumSkillType[] tempArray = nowSelectSkillTyps; nowSelectSkillTyps = new EnumSkillType[4]; Array.Copy(tempArray, nowSelectSkillTyps, 3); } var enumSkillTypes_Fourth = allSkillTypes.Select(temp => { FieldInfo fieldInfo = enumType.GetField(temp.ToString()); if (fieldInfo == null) { return new { type = temp, str = "" } } ; FieldExplanAttribute fieldExplanAttriubte = fieldInfo.GetCustomAttributes(typeof(FieldExplanAttribute), false).OfType <FieldExplanAttribute>().Where(innerTemp => innerTemp != null).FirstOrDefault(); if (fieldExplanAttriubte == null) { return new { type = temp, str = "" } } ; return(new { type = temp, str = fieldExplanAttriubte.GetExplan() }); }).Where(temp => !string.IsNullOrEmpty(temp.str)).Where(temp => temp.type <EnumSkillType.MagicCombinedLevel4End && temp.type> EnumSkillType.MagicCombinedLevel4Start); int index_Fourth = enumSkillTypes_Fourth.Select(temp => temp.type).ToList().IndexOf(nowSelectSkillTyps[3]); int nowIndex_Fourth = EditorGUILayout.Popup(index_Fourth, enumSkillTypes_Fourth.Select(temp => temp.str).ToArray()); if (nowIndex_Fourth > -1 && nowIndex_Fourth < enumSkillTypes_Fourth.Count()) { EnumSkillType selectEnumSkillType = enumSkillTypes_Fourth.ToArray()[nowIndex_Fourth].type; nowSelectSkillTyps[3] = selectEnumSkillType; } } //技能粒子对象 if (skillTypeToParticalNameDic.ContainsKey(selectKey)) { GameObject particalObj = (GameObject)EditorGUILayout.ObjectField(ParticalManager.GetPartical(skillTypeToParticalNameDic[selectKey]), typeof(GameObject), true); skillTypeToParticalNameDic[selectKey] = ParticalManager.GetName(particalObj); } if (GUILayout.Button("保存", GUILayout.Width(35))) { int key = SkillCombineStaticTools.GetCombineSkillKey(nowSelectSkillTyps); if (key == 0 || (key != selectKey && skillTypeToParticalNameDic.ContainsKey(key))) { EditorUtility.DisplayDialog("提示", "无法保存该数据!", "确认"); } else { string particalName = ""; if (skillTypeToParticalNameDic.ContainsKey(selectKey)) { particalName = skillTypeToParticalNameDic[selectKey]; skillTypeToParticalNameDic.Remove(selectKey); } skillTypeToParticalNameDic.Add(key, particalName); selectKey = key; } } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); } }
/// <summary> /// 更新显示 /// </summary> private void ChangeSpriteLattice() { SkillBaseStruct[] skillBaseStructs = iSkillState.CombineSkills; Action <Transform, Sprite> SetImageSprite = (trans, sprite) =>//设置技能的图片显示 { if (trans) { Image image = trans.GetComponent <Image>(); if (image) { image.sprite = sprite; image.enabled = sprite != null; } } }; Action <Transform, float> SetImageInnerState = (trans, coolingTime) =>//设置技能的冷却显示 { if (trans) { Image image = trans.GetComponent <Image>(); if (image) { image.fillAmount = Mathf.Clamp(coolingTime, 0, 1); } } }; if (skillBaseStructs != null) { int skillID = SkillCombineStaticTools.GetCombineSkillKey(skillBaseStructs); float skillCoolingTime = iSkillState.GetSkillRuntimeCoolingTime(skillID); //本技能的冷却时间 float maxTime = skillCoolingTime > iSkillState.PublicCoolingTime ? (skillCoolingTime / iSkillState.GetSkillMaxCoolingTime(skillID)) : iSkillState.PublicCoolingTime; //选取最大的时间作为显示时间 if (skillBaseStructs.Length > 0 && skillBaseStructs[0] != null) { Sprite sprite = SkillCombineStaticTools.GetCombineSkillSprite(skillStructData, (int)skillBaseStructs[0].skillType); SetImageSprite(firstImage, sprite); SetImageInnerState(firstInnerImage, maxTime); } else//清理第一个框 { SetImageSprite(firstImage, null); SetImageInnerState(firstInnerImage, 0); } if (skillBaseStructs.Length > 1 && skillBaseStructs[1] != null) { Sprite sprite = SkillCombineStaticTools.GetCombineSkillSprite(skillStructData, (int)skillBaseStructs[1].skillType); SetImageSprite(secondImage, sprite); SetImageInnerState(secondInnerImage, maxTime); } else//清理第二个框 { SetImageSprite(secondImage, null); SetImageInnerState(secondInnerImage, 0); } if (skillBaseStructs.Length > 2 && skillBaseStructs[2] != null) { Sprite sprite = SkillCombineStaticTools.GetCombineSkillSprite(skillStructData, (int)skillBaseStructs[2].skillType); SetImageSprite(thirdImage, sprite); SetImageInnerState(thirdInnerImage, maxTime); } else//清理第三个框 { SetImageSprite(thirdImage, null); SetImageInnerState(thirdInnerImage, 0); } if (skillBaseStructs.Length > 3 && skillBaseStructs[3] != null) { Sprite sprite = SkillCombineStaticTools.GetCombineSkillSprite(skillStructData, (int)skillBaseStructs[3].skillType); SetImageSprite(fourthImage, sprite); SetImageInnerState(fourthInnerImage, maxTime); } else//清理第四个框 { SetImageSprite(fourthImage, null); SetImageInnerState(fourthInnerImage, 0); } } else { SetImageSprite(firstImage, null); SetImageSprite(secondImage, null); SetImageSprite(thirdImage, null); SetImageSprite(fourthImage, null); SetImageInnerState(firstInnerImage, 0); SetImageInnerState(secondInnerImage, 0); SetImageInnerState(thirdInnerImage, 0); SetImageInnerState(fourthInnerImage, 0); } }
/// <summary> /// 显示集合 /// </summary> private void ShowUIList() { uiKeySettingList.Init(); //注意第一项弄成空的 UIListItem firstItem = uiKeySettingList.NewItem(); firstItem.childText.text = "None"; //firstItem.transform.GetChild(1).GetComponent<Text>().text = "None"; firstItem.value = null; uiKeySettingList.UpdateUI(); //其他项从技能和道具中检索 List <KeyContactStruct> keyContactStructList = new List <KeyContactStruct>(); //单独的技能 foreach (var item in playerState.SkillPoint) { if (item.Value <= 0) { continue; } SkillBaseStruct skillBaseStruct = skillStructData.SearchSkillDatas(temp => temp.skillType == item.Key).FirstOrDefault(); if (skillBaseStruct != null) { KeyContactStruct tempKeyContactStruct = new KeyContactStruct(); tempKeyContactStruct.id = (int)item.Key; tempKeyContactStruct.key = 0; tempKeyContactStruct.keyContactType = EnumKeyContactType.Skill; tempKeyContactStruct.name = skillBaseStruct.skillName; keyContactStructList.Add(tempKeyContactStruct); } } //组合的技能 foreach (var item in playerState.CombineSkills) { if (item != null && item.Count(temp => temp == EnumSkillType.None) < 4) { KeyContactStruct tempKeyContactStruct = new KeyContactStruct(); tempKeyContactStruct.id = SkillCombineStaticTools.GetCombineSkillKey(item); tempKeyContactStruct.key = 0; tempKeyContactStruct.keyContactType = EnumKeyContactType.Skill; tempKeyContactStruct.name = SkillCombineStaticTools.GetCombineSkillsName(item); keyContactStructList.Add(tempKeyContactStruct); } } //可使用的炼金道具 foreach (var item in playerState.PlayerAllGoods.Where(temp => ((int)temp.GoodsInfo.EnumGoodsType > (int)EnumGoodsType.Item && (int)temp.GoodsInfo.EnumGoodsType < (int)EnumGoodsType.Item + 1000000) || ((int)temp.GoodsInfo.EnumGoodsType > (int)EnumGoodsType.Elixir && (int)temp.GoodsInfo.EnumGoodsType < (int)EnumGoodsType.Elixir + 1000000) )) { KeyContactStruct tempKeyContactStruct = new KeyContactStruct(); tempKeyContactStruct.id = item.ID; tempKeyContactStruct.key = 0; tempKeyContactStruct.keyContactType = EnumKeyContactType.Prap; tempKeyContactStruct.name = item.GoodsInfo.GoodsName; keyContactStructList.Add(tempKeyContactStruct); } //显示在下拉列表中 foreach (var item in keyContactStructList) { UIListItem uiListItem = uiKeySettingList.NewItem(); uiListItem.childText.text = item.name; uiListItem.value = item; uiListItem.childImage.enabled = false; } //最后的设置 uiKeySettingList.UpdateUI(); nowKeySettingListItem = uiKeySettingList.FirstShowItem(); uiKeySettingList.ShowItem(nowKeySettingListItem); if (nowKeySettingListItem) { nowKeySettingListItem.childImage.enabled = true; } selectTargetPanel.gameObject.SetActive(true); //状态改为选择技能 enumKeySettingType = EnumKeySettingType.Select; }
/// <summary> /// 当隐藏时处理 /// </summary> private void OnDisable() { UIManager.Instance.KeyUpHandle -= Instance_KeyUpHandle; if (nowKeySettingLattice) { nowKeySettingLattice.LostForcus(); } //保存状态 UIFocus[] uiKeySettingLatticeArray = keySettingFocusPath.UIFocuesArray; foreach (UIFocus item in uiKeySettingLatticeArray) { if (!item) { continue; } UIFocusKeySettingLattice uiKeySettingLattice = item as UIFocusKeySettingLattice; int inputKey = uiKeySettingLattice.GetKeySettingInput();//输入的按键值 if (uiKeySettingLattice) { //KeyContactStruct[] keyContactStructs = keyContactData.GetKeyContactStruct(inputKey); KeyContactStruct newTarget = new KeyContactStruct(); newTarget.id = uiKeySettingLattice.id; newTarget.keyContactType = uiKeySettingLattice.keyLatticeType; //if (keyContactStructs.Length > 0) //{ // newTarget = keyContactStructs[0]; //} //else //{ //设置对象的名字 switch (newTarget.keyContactType) { case EnumKeyContactType.None: newTarget.name = "None"; break; case EnumKeyContactType.Skill: EnumSkillType[] skillTypes = SkillCombineStaticTools.GetCombineSkills(newTarget.id); newTarget.name = SkillCombineStaticTools.GetCombineSkillsName(skillTypes); //如果是火球术 if (newTarget.id == SkillCombineStaticTools.GetCombineSkillKey(new EnumSkillType[] { EnumSkillType.FS01, EnumSkillType.YSX01 })) { //给任务系统填入状态 INowTaskState iNowTaskState = GameState.Instance.GetEntity <INowTaskState>(); iNowTaskState.CheckNowTask(EnumCheckTaskType.Special, (int)TaskMap.Enums.EnumTaskSpecialCheck.SetFireSkillToLattice); } break; case EnumKeyContactType.Prap: PlayGoods playGoods = playerState.PlayerAllGoods.FirstOrDefault(temp => temp.ID == newTarget.id); newTarget.name = playGoods.GoodsInfo.GoodsName; break; case EnumKeyContactType.Action: newTarget.name = "暂无功能"; break; } //} keyContactData.SetKeyContactStruct(inputKey, newTarget); } } }