void GUI_StageItem(int index, StageConfig stageConfig) { Texture icon = null; if (stageIcons.ContainsKey(stageConfig.id)) { icon = stageIcons[stageConfig.id]; } else { icon = LoadEditorResource <Texture2D>("StageIcon/" + stageConfig.id + ".png"); stageIcons.Add(stageConfig.id, icon); } if (icon == null) { icon = defaultStageIcon; } GUIContent iconContent = new GUIContent(icon); GUILayout.Space(5); GUILayout.BeginHorizontal(); GUILayout.Label(stageConfig.id + "", guiSkin.label, GUILayout.Width(50), GUILayout.Height(itemHeight)); GUILayout.Space(10); GUILayout.Box(iconContent, guiSkin.box, GUILayout.Width(300), GUILayout.Height(itemHeight)); GUILayout.Space(10); GUILayout.BeginVertical(); GUILayout.Label(stageConfig.name, guiSkin.label, GUILayout.Height(30)); GUILayout.Space(10); if (GUILayout.Button("运行", guiSkin.button, GUILayout.Height(30))) { WarEditor_Instance.Run(stageConfig); } if (GUILayout.Button("编辑", guiSkin.button, GUILayout.Height(30))) { WarEditor_Instance.Open(stageConfig); if (editorIsOpenStageConfigWindow) { WarEditor_StageConfigWindow_Modify.Open(); } } if (GUILayout.Button("克隆", guiSkin.button, GUILayout.Height(30))) { WarEditor_StageConfigWindow_Create.Open(stageConfig); } if (GUILayout.Button("删除", guiSkin.button, GUILayout.Height(30))) { if (EditorUtility.DisplayDialog("删除关卡", "是否真的要删除?", "删除", "取消")) { WarEditor_File.Delete(stageConfig.id); } } GUILayout.EndVertical(); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.Box(iconContent, GUILayout.ExpandWidth(true), GUILayout.Height(1)); }
protected void GUIHanlder(StageConfig stageConfig) { scrollPos = EditorGUILayout.BeginScrollView(scrollPos); fold_base = EditorGUILayout.Foldout(fold_base, "基本配置"); if (fold_base) { EditorGUILayout.BeginVertical(style_box_marginleft); if (id == -1 || _stageConfig != stageConfig) { sourceId = id = stageConfig.id; _stageConfig = stageConfig; } id = EditorGUILayout.IntField("编号", id); OnIdChange(stageConfig); stageConfig.name = EditorGUILayout.TextField("名称", stageConfig.name); GUILayout.Space(5); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("描述", GUILayout.Width(100)); stageConfig.description = EditorGUILayout.TextArea(stageConfig.description, GUILayout.Height(50)); EditorGUILayout.EndHorizontal(); GUILayout.Space(5); stageConfig.type = (StageType)EditorGUILayout.IntPopup("关卡类型", (int)stageConfig.type, stageType_names, stageType_ids); stageConfig.level = EditorGUILayout.IntField("等级", stageConfig.level); stageConfig.nextStageId = EditorGUILayout.IntField("解锁关卡", stageConfig.nextStageId); stageConfig.dropId = EditorGUILayout.IntField("掉落", stageConfig.dropId); stageConfig.costStrength = EditorGUILayout.IntField("消耗体力", stageConfig.costStrength); stageConfig.time = EditorGUILayout.IntField("限时", (int)stageConfig.time); EditorGUILayout.ToggleLeft("限时", stageConfig.time > 0); stageConfig.showHP = EditorGUILayout.ToggleLeft("血条开关", stageConfig.showHP); stageConfig.sos = EditorGUILayout.ToggleLeft("求救提示", stageConfig.sos); stageConfig.neutralRoleLevel = EditorGUILayout.IntField("中立主公等级", stageConfig.neutralRoleLevel); stageConfig.winId = EditorGUILayout.IntPopup("胜利条件", stageConfig.winId, win_names, win_ids); GUILayout.Space(10); EditorGUILayout.LabelField("星级评价"); EditorGUILayout.BeginVertical(style_box_marginleft); if (stageConfig.stars.Length < 3) { int[] tempStarts = stageConfig.stars; stageConfig.stars = new int[3]; for (int i = 0; i < tempStarts.Length; i++) { GUILayout.Space(3); stageConfig.stars[i] = tempStarts[i]; GUILayout.Space(3); } } for (int i = 0; i < 3; i++) { stageConfig.stars[i] = EditorGUILayout.IntPopup("星级评价1", stageConfig.stars[i], star_names, star_ids); } EditorGUILayout.EndVertical(); GUILayout.Space(10); EditorGUILayout.EndVertical(); } fold_legionList = EditorGUILayout.Foldout(fold_legionList, "势力列表"); if (fold_legionList) { List <StageLegionConfig> legionList = new List <StageLegionConfig>(); foreach (var legionKVP in stageConfig.legionDict) { legionList.Add(legionKVP.Value); } foreach (StageLegionConfig legionConfig in legionList) { GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); GUILayout.Space(30); if (GUILayout.Button("删除", style_box_center, GUILayout.Width(50), GUILayout.Height(30))) { stageConfig.legionDict.Remove(legionConfig.legionId); } EditorGUILayout.BeginVertical(style_box_legion); legion_toggles[legionConfig.legionId] = GUILayout.Toggle(legion_toggles[legionConfig.legionId], string.Format("<color={2}>势力{0} [{1}--{3}]</color>", legionConfig.legionId, WarColor.Names[legionConfig.color], WarColor.GetUnitHPColor(legionConfig.color).ToStr32(), EnumUtil.GetName <LegionType>(legionConfig.type)), style_label_toggle, GUILayout.ExpandWidth(true), GUILayout.Height(30)); if (legion_toggles[legionConfig.legionId]) { legionConfig.color = EditorGUILayout.IntPopup("颜色", legionConfig.color, WarColor.Names, WarColor.IDs, style_label_IntPopup_color); if (legionConfig.color != legionConfig.legionId) { if (stageConfig.legionDict.ContainsKey(legionConfig.color)) { EditorGUILayout.HelpBox(string.Format("该颜色以被其他势力使用, 请改回'{0}'", WarColor.Names[legionConfig.legionId]), MessageType.Error); } else { stageConfig.legionDict.Remove(legionConfig.legionId); legionConfig.legionId = legionConfig.color; stageConfig.legionDict.Add(legionConfig.legionId, legionConfig); } } legionConfig.type = (LegionType)EditorGUILayout.IntPopup("类型", (int)legionConfig.type, legionType_Names, legionType_ids); legionConfig.groupId = EditorGUILayout.IntPopup("联盟", legionConfig.groupId, group_names, group_ids); // legionConfig.ai = EditorGUILayout.IntPopup("AI", legionConfig.ai, ai_names, ai_ids); legionConfig.robotId = EditorGUILayout.IntField("机器人", legionConfig.robotId); GUILayout.Space(10); legionConfig.produce = EditorGUILayout.ToggleLeft("兵营是否产兵", legionConfig.produce); legionConfig.produceLimit = EditorGUILayout.ToggleLeft("兵营生产是否上限(一般只有中立勾选)", legionConfig.produceLimit); GUILayout.Space(10); legionConfig.aiUplevel = EditorGUILayout.ToggleLeft("是否自动升级", legionConfig.aiUplevel); legionConfig.aiSendArm = EditorGUILayout.ToggleLeft("是否自动派兵", legionConfig.aiSendArm); legionConfig.aiSkill = EditorGUILayout.ToggleLeft("是否自动使用技能", legionConfig.aiSkill); GUILayout.Space(10); // =========================== // EditorGUILayout.LabelField("士兵"); // EditorGUILayout.BeginVertical(style_box_solider); // if(legionConfig.soldierMonsterId > 0) // { // GUI_Solider(legionConfig.soliderMonster); // // if(GUILayout.Button("清除", GUILayout.Height(30))) // { // legionConfig.soldierMonsterId = 0; // } // } // // if(GUILayout.Button("选择", GUILayout.Height(30))) // { // WarEditor_SoliderLibraryWindow.Open(OnSelectSolider, legionConfig); // } // EditorGUILayout.EndVertical(); // =========================== // EditorGUILayout.LabelField("英雄"); // EditorGUILayout.BeginVertical(); // int heroIndex = 0; // for(int i = 0; i < legionConfig.heroIdList.Length; i ++) // { // int heroId = legionConfig.heroIdList[i]; // if(heroId <= 0) continue; // GUI_Hero(heroId, legionConfig, heroIndex, i); // GUILayout.Space(10); // heroIndex ++; // } // // if(GUILayout.Button("添加", GUILayout.Height(30))) // { // WarEditor_HeroLibraryWindow.Open(OnSelectAddHero, legionConfig); // } // // EditorGUILayout.EndVertical(); // =========================== } EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); } } // fold_legionGroup = EditorGUILayout.Foldout(fold_legionGroup, "势力关系"); // if (fold_legionGroup) // { // for(int i = 0; i < stageConfig.legionGroups.Count; i ++) // { // GUILayout.Box("联盟" + i); // EditorGUILayout.BeginHorizontal(); // // EditorGUILayout.EndHorizontal(); // // } // } EditorGUILayout.EndScrollView(); //------------------------ GUILayout.Space(20); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("应用", GUILayout.Width(100), GUILayout.Height(30))) { if (stageConfig.legionDict.Count < 2) { this.ShowNotification(new GUIContent("请创建势力,势力至少需要2个")); } else { GenerateGroup(stageConfig); WarEditor_Instance.Open(stageConfig); WarEditor_StageConfigWindow_Modify.Open(); } } if (visiable_SaveButton && GUILayout.Button("保存", GUILayout.Width(100), GUILayout.Height(30))) { GenerateGroup(stageConfig); WarEditor_File.SaveStageConfig(stageConfig); } if (stageConfig.legionDict.Count < WarColor.Names.Length && GUILayout.Button("添加势力", GUILayout.Width(100), GUILayout.Height(30))) { int legionId = 0; for (int i = 0; i < WarColor.Names.Length; i++) { if (!stageConfig.legionDict.ContainsKey(i)) { legionId = i; break; } } StageLegionConfig legionConfig = CreateStageLegionConfig(legionId); stageConfig.legionDict.Add(legionConfig.legionId, legionConfig); } EditorGUILayout.EndHorizontal(); }