| | |
| | | /// <summary> |
| | | /// 小方格主角偏移 |
| | | /// </summary> |
| | | private static ZTPoint[] houseRoleBlockOffset = new ZTPoint[] { |
| | | new ZTPoint(0,0), |
| | | new ZTPoint(1,0), |
| | | new ZTPoint(0,1), |
| | | new ZTPoint(1,1) |
| | | private static Structs.ZTPoint[] houseRoleBlockOffset = new Structs.ZTPoint[] { |
| | | new Structs.ZTPoint(0,0), |
| | | new Structs.ZTPoint(1,0), |
| | | new Structs.ZTPoint(0,1), |
| | | new Structs.ZTPoint(1,1) |
| | | }; |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="minMapStart"></param> |
| | | /// <param name="offset"></param> |
| | | /// <returns></returns> |
| | | public static bool GetCurrentHouseIndex(out Int32 houseIndex, Image<Rgb, byte> image, ZTPoint minMapStart) |
| | | public static bool GetCurrentHouseIndex(out Int32 houseIndex, Image<Rgb, byte> image, Structs.ZTPoint minMapStart) |
| | | { |
| | | houseIndex = -1; |
| | | Int32 mainMonsterHouseIndex = -1; |
| | |
| | | Int32 x = minMapStart.X + col * 18; |
| | | Int32 y = minMapStart.Y + row * 18; |
| | | |
| | | ZTPoint position = ZTPoint.Empty; |
| | | Structs.ZTPoint position = Structs.ZTPoint.Empty; |
| | | ZTRectangle limit = new ZTRectangle(x, y, x + 17, y + 17); |
| | | if (CVHelper.FindColorBlock(out position, image, limit, minMinimapRoleColor, maxMinimapRoleColor, houseRoleBlockOffset)) |
| | | { |
| | |
| | | /// <summary> |
| | | /// 小方格色块偏移 |
| | | /// </summary> |
| | | private static ZTPoint[] houseColorBlockOffset = new ZTPoint[] { |
| | | new ZTPoint(2,2), |
| | | new ZTPoint(2,3), |
| | | new ZTPoint(15,14), |
| | | new ZTPoint(15,15), |
| | | private static Structs.ZTPoint[] houseColorBlockOffset = new Structs.ZTPoint[] { |
| | | new Structs.ZTPoint(2,2), |
| | | new Structs.ZTPoint(2,3), |
| | | new Structs.ZTPoint(15,14), |
| | | new Structs.ZTPoint(15,15), |
| | | }; |
| | | /// <summary> |
| | | /// 房间是否开放 |
| | | /// </summary> |
| | | /// <param name="houseIndex"></param> |
| | | /// <returns></returns> |
| | | public static bool HouseIsOpen(Image<Rgb, byte> image, ZTPoint minMapStart, Int32 houseIndex) |
| | | public static bool HouseIsOpen(Image<Rgb, byte> image, Structs.ZTPoint minMapStart, Int32 houseIndex) |
| | | { |
| | | //第一块距上边15px,距左边1px |
| | | Int32 row = houseIndex / 4; |
| | |
| | | /// </summary> |
| | | /// <param name="image"></param> |
| | | /// <returns></returns> |
| | | public static ZTPoint[] FindMonster(Image<Hsv, byte> image,ZTRectangle gameRect) |
| | | public static Structs.ZTPoint[] FindMonster(Image<Hsv, byte> image,ZTRectangle gameRect) |
| | | { |
| | | List<ZTRectangle> rects = CVHelper.FindBlocks(image, minMonsterHsv, maxMonsterHsv, monsterBlockSize); |
| | | ZTPoint[] monsterPoints = new ZTPoint[rects.Count]; |
| | | Structs.ZTPoint[] monsterPoints = new Structs.ZTPoint[rects.Count]; |
| | | for (int i = 0; i < rects.Count; i++) |
| | | { |
| | | monsterPoints[i] = rects[i].GetCenterPoint().Add(gameRect.Start); |
| | |
| | | { |
| | | continue; |
| | | } |
| | | ZTPoint doorPosition = ZTPoint.Empty; |
| | | Structs.ZTPoint doorPosition = Structs.ZTPoint.Empty; |
| | | for (int i = 0; i < doors.Count; i++) |
| | | { |
| | | doorPosition = new ZTPoint(doors[i].Start.X + (doors[i].End.X - doors[i].Start.X) / 2, doors[i].Start.Y + (doors[i].End.Y - doors[i].Start.Y) / 2); |
| | | doorPosition = new Structs.ZTPoint(doors[i].Start.X + (doors[i].End.X - doors[i].Start.X) / 2, doors[i].Start.Y + (doors[i].End.Y - doors[i].Start.Y) / 2); |
| | | if (doorPosition.X >= limitRect.Start.X && |
| | | doorPosition.X <= limitRect.End.X && |
| | | doorPosition.Y >= limitRect.Start.Y && |
| | |
| | | } |
| | | } |
| | | |
| | | return ZTPoint.Empty; |
| | | return Structs.ZTPoint.Empty; |
| | | } |
| | | |
| | | /// <summary> |