using Emgu.CV;
using Emgu.CV.Structure;
using RichCreator.Utility.Captures;
using RichCreator.Utility.Structs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RichCreator.Utility.CV
{
public class ShikongzhimenCVHelper
{
public static ZTSize minDoorBlockSize = new ZTSize(25, 25);//门的最小大小
public static Hsv minUpDoorColor = new Hsv(17, 254, 254);
public static Hsv maxUpDoorColor = new Hsv(19, 255, 255);
public static Hsv minRightDoorColor = new Hsv(143, 254, 254);
public static Hsv maxRightDoorColor = new Hsv(145, 255, 255);
public static Hsv minBottomDoorColor = new Hsv(17, 254, 254);
public static Hsv maxBottomDoorColor = new Hsv(19, 255, 255);
public static Hsv minLeftDoorColor = new Hsv(107, 254, 254);
public static Hsv maxLeftDoorColor = new Hsv(109, 255, 255);
public static Hsv minRealBottomDoorColor = new Hsv(35, 254, 254);
public static Hsv maxRealBottomDoorColor = new Hsv(37, 255, 255);
///
/// 查找门
///
///
///
public static Dictionary FindDoor(Image image, Direction[] directions, ZTRectangle gameRect)
{
Dictionary doorDir = new Dictionary();
Direction targetDirection = Direction.None;
Int32 height = gameRect.End.Y - gameRect.Start.Y;
Int32 width = gameRect.End.X - gameRect.Start.X;
Int32 yHalf = height / 2;
Int32 xHalf = width / 2;
ZTRectangle limitRect = ZTRectangle.Empty;
Hsv minDoorHsvColor = default(Hsv), maxDoorHsvColor = default(Hsv);
for (int doorIndex = 0; doorIndex < directions.Length; doorIndex++)
{
targetDirection = directions[doorIndex];
switch (targetDirection)
{
case Direction.Up:
minDoorHsvColor = minUpDoorColor;
maxDoorHsvColor = maxUpDoorColor;
limitRect = new ZTRectangle(0, 0, width, yHalf);
break;
case Direction.Right:
minDoorHsvColor = minRightDoorColor;
maxDoorHsvColor = maxRightDoorColor;
limitRect = new ZTRectangle(xHalf, 0, width, height);
break;
case Direction.Bottom:
minDoorHsvColor = minBottomDoorColor;
maxDoorHsvColor = maxBottomDoorColor;
limitRect = new ZTRectangle(0, yHalf, width, height);
break;
case Direction.Left:
minDoorHsvColor = minLeftDoorColor;
maxDoorHsvColor = maxLeftDoorColor;
limitRect = new ZTRectangle(0, 0, xHalf, height);
break;
}
List doors = CVHelper.FindBlocks(image, minDoorHsvColor, maxDoorHsvColor, minDoorBlockSize);
if (doors.Count <= 0)
{
continue;
}
Structs.ZTPoint doorPosition = Structs.ZTPoint.Empty;
for (int i = 0; i < doors.Count; i++)
{
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 &&
doorPosition.Y <= limitRect.End.Y)
{
ZTPoint door = doorPosition + gameRect.Start;
if (!doorDir.ContainsKey(door))
{
doorDir.Add(door, targetDirection);
}
}
}
}
return doorDir;
}
///
/// 地图右上角素喃文字
///
public static ColorArray MapTopSunan = ColorArray.FromHsvFloatString(0.002f, 0.002f, 0.002f, "1401,72,230,200,155$1381,69,230,200,155$1380,68,0,0,0$1385,68,0,0,0$1386,68,230,200,155$1386,67,0,0,0$1387,67,0,0,0$1387,68,0,0,0$1391,68,0,0,0$1391,69,230,200,155$1392,69,0,0,0$1393,69,230,200,155$1393,68,0,0,0$1396,69,0,0,0$1395,69,230,200,155$1397,69,230,200,155$1399,68,0,0,0$1401,68,0,0,0$1404,69,0,0,0$1404,72,0,0,0$1403,72,230,200,155$1402,72,0,0,0$1400,72,0,0,0$1399,72,230,200,155$1398,72,0,0,0$1397,72,230,200,155$1396,72,0,0,0$1395,72,230,200,155$1394,72,0,0,0$1393,72,230,200,155$1392,72,0,0,0$1381,79,0,0,0$1382,79,230,200,155$1383,79,0,0,0$1385,79,230,200,155$1387,79,0,0,0$1390,79,230,200,155$1391,79,0,0,0$1396,79,0,0,0$1397,79,230,200,155$1398,79,0,0,0$1397,80,0,0,0$1401,79,0,0,0$1402,79,230,200,155$1402,80,0,0,0$1403,80,0,0,0$1403,79,230,200,155$1404,79,0,0,0$1404,80,0,0,0");
///
/// 是否进入素喃
///
///
///
///
public static bool IsInSunan(ZTRectangle gameRect)
{
Image image = ScreenCapture.Instance.CaptureScreenReturnImage();
ZTRectangle limit = new ZTRectangle(gameRect.Start.X + 716, gameRect.Start.Y, gameRect.End.X, gameRect.Start.Y + 54);
ZTRectangle position = ZTRectangle.Empty;
return CVHelper.FindColorArray(out position, image, MapTopSunan, limit);
}
///
/// 地图右上角时空之门文字
///
public static ColorArray MapTopShikongzhimen = ColorArray.FromHsvFloatString(0.002f, 0.002f, 0.002f, "1187,48,230,200,155$1177,46,230,200,155$1180,46,230,200,155$1180,55,230,200,155$1177,55,230,200,155$1184,56,230,200,155$1186,56,230,200,155$1186,45,230,200,155$1189,48,230,200,155$1193,45,230,200,155$1196,48,230,200,155$1199,47,230,200,155$1199,48,230,200,155$1201,48,230,200,155$1209,48,230,200,155$1204,45,230,200,155$1212,45,230,200,155$1213,46,230,200,155$1215,45,230,200,155$1221,45,230,200,155$1221,56,230,200,155$1219,56,230,200,155$1212,56,230,200,155$1210,56,230,200,155$1205,56,230,200,155$1199,56,230,200,155$1189,56,230,200,155$1194,55,230,200,155");
///
/// 是否进入时空之门
///
///
///
///
public static bool IsInShikongzhimen(ZTRectangle gameRect)
{
Image image = ScreenCapture.Instance.CaptureScreenReturnImage();
ZTRectangle limit = new ZTRectangle(gameRect.Start.X + 662, gameRect.Start.Y, gameRect.End.X, gameRect.Start.Y + 54);
ZTRectangle position = ZTRectangle.Empty;
return CVHelper.FindColorArray(out position, image, MapTopShikongzhimen, limit);
}
///
/// 选择进那个副本界面的下方"space"文字
///
public static ColorArray ChoiceTaskPage_Space = ColorArray.FromHsvFloatString(0.002f, 0.002f, 0.002f, "1522,728,0,0,0$1505,728,208,182,131$1506,728,0,0,0$1508,728,0,0,0$1509,728,208,182,131$1510,728,208,182,131$1511,728,0,0,0$1513,728,0,0,0$1514,728,0,0,0$1515,728,208,182,131$1517,728,208,182,131$1518,728,0,0,0$1519,728,0,0,0$1520,728,0,0,0$1521,728,208,182,131$1523,728,208,182,131$1524,728,0,0,0$1526,728,0,0,0$1527,728,208,182,131$1529,728,208,182,131$1530,728,0,0,0$1532,728,0,0,0$1533,728,208,182,131$1533,727,0,0,0$1532,727,208,182,131$1530,727,208,182,131$1529,727,0,0,0$1528,727,208,182,131$1527,727,0,0,0$1524,727,208,182,131$1523,727,0,0,0$1522,727,208,182,131$1521,727,0,0,0$1520,727,208,182,131$1518,727,208,182,131$1517,727,0,0,0$1516,727,208,182,131$1515,727,0,0,0$1514,727,208,182,131$1512,727,208,182,131$1511,727,0,0,0$1510,727,208,182,131$1509,727,0,0,0$1508,727,208,182,131$1506,727,208,182,131$1505,727,0,0,0$1505,725,208,182,131$1506,725,0,0,0$1507,725,0,0,0$1508,725,208,182,131$1510,725,208,182,131$1511,725,0,0,0$1512,725,208,182,131$1514,725,208,182,131$1515,725,0,0,0$1517,725,208,182,131$1518,725,0,0,0$1520,725,0,0,0$1521,725,0,0,0$1522,725,208,182,131$1523,725,0,0,0$1524,725,208,182,131$1528,725,208,182,131$1529,725,0,0,0$1531,725,0,0,0$1533,725,0,0,0$1534,725,208,182,131$1533,723,208,182,131$1532,723,0,0,0$1530,723,0,0,0$1529,723,208,182,131$1527,723,208,182,131$1526,723,0,0,0$1524,723,0,0,0$1523,723,208,182,131$1521,723,208,182,131$1520,723,0,0,0$1518,723,0,0,0$1517,723,208,182,131$1515,723,208,182,131$1514,723,0,0,0$1511,723,0,0,0$1510,723,208,182,131$1509,723,208,182,131$1508,723,0,0,0$1506,723,0,0,0$1505,723,208,182,131");
///
/// 是否打开选择副本界面
///
///
///
///
public static bool IsInChoiceTaskPage(Image image, ZTRectangle gameRect)
{
ZTRectangle limit = new ZTRectangle(gameRect.Start.X + 420, gameRect.Start.Y + 576, gameRect.Start.X + 467, gameRect.End.Y);
ZTRectangle position = ZTRectangle.Empty;
//if (CVHelper.FindColorArray(out position, image, ChoiceTaskPage_0, gameRect))
//{
// return true;
//}
return CVHelper.FindColorArray(out position, image, ChoiceTaskPage_Space, limit);
}
}
}