//画像 void DrawTexture() { string[] names = Directory.GetFiles(filePath, "*.png"); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); //カウント数 int cntY = 0; int typeCnt = 0; foreach (var texturePath in names) { Texture2D tex = (Texture2D)AssetDatabase.LoadAssetAtPath(texturePath, typeof(Texture2D)); if (cntY % 4 == 0) { EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); } if (GUILayout.Button(tex, GUILayout.MaxWidth(50.0f), GUILayout.MaxHeight(50.0f), GUILayout.ExpandWidth(false), GUILayout.ExpandHeight(false))) { selectImagePath = texturePath; type_ = (Field.FIELD_TYPE)GetType(typeCnt); } typeCnt++; cntY++; } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
private void DijkstraFix(Field.FIELD_TYPE type, int indexX, int indexY) { INDEX index; index.indexX = 0; index.indexY = 0; switch (type) { case Field.FIELD_TYPE.FIELD_CONVEX_DOWN: //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CONVEX_LEFT: //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CONVEX_RIGHT: //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CONVEX_UP: //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CORNER_LEFTDOWN: //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CORNER_LEFTUP: //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CORNER_RIGHTDOWN: //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CORNER_RIGHTUP: //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CORRIDOR_LEFTRIGHT: //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CORRIDOR_UPDOWN: //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_CROSSROAD: //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_ENDOFROAD_DOWN: //下 if (indexY + 1 < fieldMaxY_) { index = GetNextDijkStra(indexX, indexY, 0, 1); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_ENDOFROAD_LEFT: //左 if (indexX - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, -1, 0); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_ENDOFROAD_RIGHT: //右 if (indexX + 1 < fieldMaxX_) { index = GetNextDijkStra(indexX, indexY, 1, 0); DijkstraLink(index, indexX, indexY); } break; case Field.FIELD_TYPE.FIELD_ENDOFROAD_UP: //上 if (indexY - 1 >= 0) { index = GetNextDijkStra(indexX, indexY, 0, -1); DijkstraLink(index, indexX, indexY); } break; } }