优化符文副本重生
This commit is contained in:
parent
7e4834769d
commit
07fb378809
@ -20,11 +20,14 @@ namespace BFEditor
|
|||||||
// }
|
// }
|
||||||
const string BOARD_EXCEL_KEY = "bf_board_excel_key";
|
const string BOARD_EXCEL_KEY = "bf_board_excel_key";
|
||||||
const string BOARD_GRID_TYPE_KEY = "bf_board_grid_type_key";
|
const string BOARD_GRID_TYPE_KEY = "bf_board_grid_type_key";
|
||||||
|
const string BOARD_GRID_EDGE_KEY = "bf_board_grid_edge_key";
|
||||||
int gridCount = 49;
|
int gridCount = 49;
|
||||||
string battleImgDirectory = "Assets/arts/textures/ui/battle/";
|
string battleImgDirectory = "Assets/arts/textures/ui/battle/";
|
||||||
string boardFilepath;
|
string boardFilepath;
|
||||||
string boardGridTypePath;
|
string boardGridTypePath;
|
||||||
|
string boardGridEdgePath;
|
||||||
string boardFiledName = "board";
|
string boardFiledName = "board";
|
||||||
|
string boardEdgeFiledName = "grid_edge";
|
||||||
string randomTypeStr = "";
|
string randomTypeStr = "";
|
||||||
int curIndex = 1;
|
int curIndex = 1;
|
||||||
int maxRow = 7;
|
int maxRow = 7;
|
||||||
@ -32,6 +35,9 @@ namespace BFEditor
|
|||||||
Dictionary<int, JArray> boardDict = new Dictionary<int, JArray>();
|
Dictionary<int, JArray> boardDict = new Dictionary<int, JArray>();
|
||||||
Dictionary<int, JArray> outPutBoardDict = new Dictionary<int, JArray>();
|
Dictionary<int, JArray> outPutBoardDict = new Dictionary<int, JArray>();
|
||||||
Dictionary<string, Texture> imgDict = new Dictionary<string, Texture>();
|
Dictionary<string, Texture> imgDict = new Dictionary<string, Texture>();
|
||||||
|
Dictionary<int, Dictionary<string, string>> boardGridEdgeDict = new Dictionary<int, Dictionary<string, string>>();
|
||||||
|
Dictionary<int, JArray> edgeDict = new Dictionary<int, JArray>();
|
||||||
|
Dictionary<int, JArray> outPutBoardEdgeDict = new Dictionary<int, JArray>();
|
||||||
bool loadExcelOver = false;
|
bool loadExcelOver = false;
|
||||||
Dictionary<int, string> elementTypeImgDict = new Dictionary<int, string>(){
|
Dictionary<int, string> elementTypeImgDict = new Dictionary<int, string>(){
|
||||||
[1] = "red_1",
|
[1] = "red_1",
|
||||||
@ -55,6 +61,12 @@ namespace BFEditor
|
|||||||
{
|
{
|
||||||
boardGridTypePath = "选择grid_type配置表路径";
|
boardGridTypePath = "选择grid_type配置表路径";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boardGridEdgePath = GetBoardGridEdgePath();
|
||||||
|
if (boardGridEdgePath.Equals(""))
|
||||||
|
{
|
||||||
|
boardGridEdgePath = "选择grid_edge_type配置表路径";
|
||||||
|
}
|
||||||
string[] paths = Directory.GetFiles(battleImgDirectory);
|
string[] paths = Directory.GetFiles(battleImgDirectory);
|
||||||
foreach(var path in paths)
|
foreach(var path in paths)
|
||||||
{
|
{
|
||||||
@ -86,6 +98,16 @@ namespace BFEditor
|
|||||||
PlayerPrefs.SetString(BOARD_GRID_TYPE_KEY, path);
|
PlayerPrefs.SetString(BOARD_GRID_TYPE_KEY, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string GetBoardGridEdgePath()
|
||||||
|
{
|
||||||
|
return PlayerPrefs.GetString(BOARD_GRID_EDGE_KEY, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
void SetBoardGridEdgePath(string path)
|
||||||
|
{
|
||||||
|
PlayerPrefs.SetString(BOARD_GRID_EDGE_KEY, path);
|
||||||
|
}
|
||||||
|
|
||||||
BoardEditorWindow()
|
BoardEditorWindow()
|
||||||
{
|
{
|
||||||
this.titleContent = new GUIContent("棋盘编辑器");
|
this.titleContent = new GUIContent("棋盘编辑器");
|
||||||
@ -114,6 +136,20 @@ namespace BFEditor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
|
GUILayout.BeginHorizontal();
|
||||||
|
GUILayout.Label("grid_edge 路径", GUILayout.Width(100));
|
||||||
|
GUILayout.Space(10);
|
||||||
|
GUILayout.TextField(boardGridEdgePath, GUILayout.Width(300));
|
||||||
|
if (GUILayout.Button("选择", GUILayout.Width(80)))
|
||||||
|
{
|
||||||
|
string openPath = EditorUtility.OpenFilePanel("选择配置表", GetBoardGridEdgePath(), "");
|
||||||
|
if (openPath.CompareTo("") != 0)
|
||||||
|
{
|
||||||
|
boardGridEdgePath = openPath;
|
||||||
|
SetBoardGridEdgePath(openPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GUILayout.EndHorizontal();
|
||||||
|
|
||||||
GUILayout.Space(10);
|
GUILayout.Space(10);
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
@ -357,6 +393,21 @@ namespace BFEditor
|
|||||||
boardGridTypeDict[key] = dict;
|
boardGridTypeDict[key] = dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 读取grid_edge_type配置表
|
||||||
|
BFEditorUtils.RunCommond("python", "load_board.py " + tempPath + " " + boardGridEdgePath, pythonToolPath);
|
||||||
|
string boardGridEdgeJson = File.ReadAllText(tempPath);
|
||||||
|
jsonObj = (JObject)JsonConvert.DeserializeObject(boardGridEdgeJson);
|
||||||
|
foreach (var item in jsonObj)
|
||||||
|
{
|
||||||
|
int key = int.Parse(item.Key);
|
||||||
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||||||
|
foreach (var item2 in (JObject)item.Value)
|
||||||
|
{
|
||||||
|
dict[item2.Key] = item2.Value.ToString();
|
||||||
|
}
|
||||||
|
boardGridEdgeDict[key] = dict;
|
||||||
|
}
|
||||||
|
|
||||||
// 读取boardFile配置表
|
// 读取boardFile配置表
|
||||||
BFEditorUtils.RunCommond("python", "load_board.py " + tempPath + " " + boardFilepath, pythonToolPath);
|
BFEditorUtils.RunCommond("python", "load_board.py " + tempPath + " " + boardFilepath, pythonToolPath);
|
||||||
string boardFileJson = File.ReadAllText(tempPath);
|
string boardFileJson = File.ReadAllText(tempPath);
|
||||||
@ -369,6 +420,12 @@ namespace BFEditor
|
|||||||
boardDict[key] = copyBoard((JArray)item.Value[boardFiledName]);
|
boardDict[key] = copyBoard((JArray)item.Value[boardFiledName]);
|
||||||
outPutBoardDict[key] = copyBoard((JArray)item.Value[boardFiledName]);
|
outPutBoardDict[key] = copyBoard((JArray)item.Value[boardFiledName]);
|
||||||
}
|
}
|
||||||
|
if (item.Value[boardEdgeFiledName] != null)
|
||||||
|
{
|
||||||
|
int key = int.Parse(item.Key);
|
||||||
|
edgeDict[key] = copyBoard((JArray)item.Value[boardEdgeFiledName]);
|
||||||
|
outPutBoardEdgeDict[key] = copyBoard((JArray)item.Value[boardEdgeFiledName]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadExcelOver = true;
|
loadExcelOver = true;
|
||||||
@ -394,7 +451,7 @@ namespace BFEditor
|
|||||||
void DragBoard()
|
void DragBoard()
|
||||||
{
|
{
|
||||||
Texture img;
|
Texture img;
|
||||||
GUI.DrawTexture(new Rect(0, 150, 702, 702), boardImg);
|
GUI.DrawTexture(new Rect(0, 200, 702, 702), boardImg);
|
||||||
if(!loadExcelOver)
|
if(!loadExcelOver)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -406,7 +463,7 @@ namespace BFEditor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GUILayout.BeginArea(new Rect(0, 150, 702, 702));
|
GUILayout.BeginArea(new Rect(0, 200, 702, 702));
|
||||||
GUILayout.BeginVertical();
|
GUILayout.BeginVertical();
|
||||||
JArray jo = boardDict[curIndex];
|
JArray jo = boardDict[curIndex];
|
||||||
int posIndex = 0;
|
int posIndex = 0;
|
||||||
@ -452,9 +509,37 @@ namespace BFEditor
|
|||||||
GUILayout.EndHorizontal();
|
GUILayout.EndHorizontal();
|
||||||
}
|
}
|
||||||
GUILayout.EndVertical();
|
GUILayout.EndVertical();
|
||||||
|
if (edgeDict.ContainsKey(curIndex))
|
||||||
|
{
|
||||||
|
JArray edgeJo = edgeDict[curIndex];
|
||||||
|
for (int i = 0; i < edgeJo.Count; i++)
|
||||||
|
{
|
||||||
|
JArray gridInfo = (JArray)edgeJo[i];
|
||||||
|
if(gridInfo.Count < 3)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int posId = (int)gridInfo[0];
|
||||||
|
int edgeType = (int)gridInfo[1];
|
||||||
|
int dir = (int)gridInfo[2];
|
||||||
|
// 绘制类型
|
||||||
|
if(boardGridEdgeDict[edgeType].ContainsKey("icon"))
|
||||||
|
{
|
||||||
|
string icon = boardGridEdgeDict[edgeType]["icon"];
|
||||||
|
if (imgDict.ContainsKey(icon))
|
||||||
|
{
|
||||||
|
int row = posId / 10;
|
||||||
|
int col = posId % 10;
|
||||||
|
img = imgDict[icon];
|
||||||
|
GUI.DrawTexture(new Rect(startOffset + (col - 1) * textureWidth, startOffset + (row - 1) * textureWidth, 92, 32), img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GUILayout.EndArea();
|
GUILayout.EndArea();
|
||||||
|
|
||||||
GUILayout.BeginArea(new Rect(730, 150, 510 * 7, 550 / 7 * maxRow));
|
GUILayout.BeginArea(new Rect(730, 200, 510 * 7, 550 / 7 * maxRow));
|
||||||
GUILayout.BeginVertical();
|
GUILayout.BeginVertical();
|
||||||
GUILayout.BeginHorizontal();
|
GUILayout.BeginHorizontal();
|
||||||
GUILayout.Label("棋盘配置信息", GUILayout.Width(100), GUILayout.Height(30));
|
GUILayout.Label("棋盘配置信息", GUILayout.Width(100), GUILayout.Height(30));
|
||||||
|
|||||||
@ -104,7 +104,7 @@ namespace BFEditor
|
|||||||
[MenuItem("其他工具/棋盘编辑器", false, 9)]
|
[MenuItem("其他工具/棋盘编辑器", false, 9)]
|
||||||
public static void CreateBoardEditorWindow()
|
public static void CreateBoardEditorWindow()
|
||||||
{
|
{
|
||||||
var window = (BoardEditorWindow)EditorWindow.GetWindowWithRect(typeof(BoardEditorWindow), new Rect(Screen.width / 2, Screen.height / 2, 1200, 850), true);
|
var window = (BoardEditorWindow)EditorWindow.GetWindowWithRect(typeof(BoardEditorWindow), new Rect(Screen.width / 2, Screen.height / 2, 1200, 1000), true);
|
||||||
window.Show();
|
window.Show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user