using Emgu.CV;
|
using Emgu.CV.Structure;
|
using RichCreator.Dnf;
|
using RichCreator.Jobs.StateMachines;
|
using RichCreator.Models;
|
using RichCreator.Utility;
|
using RichCreator.Utility.Captures;
|
using RichCreator.Utility.CV;
|
using RichCreator.Utility.InputControl;
|
using RichCreator.Utility.Maps;
|
using RichCreator.Utility.Structs;
|
using RichCreator.Utility.Utilitys;
|
using RichCreator.Utilitys;
|
using System;
|
using System.Collections.Generic;
|
using System.Threading;
|
|
namespace RichCreator.Maps.Kalete
|
{
|
/// <summary>
|
/// 卡勒特地图
|
/// </summary>
|
public class KaleteMap : ShikongzhimenMapBase
|
{
|
public KaleteMap(ZTRectangle gameRect, CancellationToken cancelToken) : base(MapType.Lingdong, gameRect, cancelToken)
|
{
|
this.MiniMap = new KaleteMiniMap(gameRect);
|
}
|
|
/// <summary>
|
/// 地图的所有房间
|
/// NextIndex=-1,完成
|
/// NextIndex=-2,出错
|
/// </summary>
|
private static readonly HouseInfo[] Houses = new HouseInfo[] {
|
new HouseInfo (0 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (1 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (2 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (3 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (4 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (5 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (6 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,1),
|
new HouseInfo (7 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,6),
|
new HouseInfo (8 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},new int[]{20,21,22,23 },7),
|
new HouseInfo (9 ,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (10,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (11,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (12,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,13),
|
new HouseInfo (13,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,8),
|
new HouseInfo (14,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (15,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (16,MapType.Kalete,true ,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,17),
|
new HouseInfo (17,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,12),
|
new HouseInfo (18,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0),
|
new HouseInfo (19,MapType.Kalete,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,0)
|
};
|
|
private Int32 runningStep = RunningStep.None;
|
private DateTime startRoleTime = DateTime.Now;
|
|
/// <summary>
|
/// 开始
|
/// </summary>
|
/// <param name="gameRect"></param>
|
/// <param name="cancelToken"></param>
|
/// <param name="runningStep"></param>
|
/// <returns></returns>
|
public override ZTResult Start(Int32 runningStep)
|
{
|
this.runningStep = runningStep;
|
WindowUtils.SetDnfToTop();
|
|
if (runningStep < RunningStep.War)
|
{
|
if (!MoveToSunan())
|
{
|
return ZTResult.Failed;
|
}
|
|
if (!MoveToShikongzhimen())
|
{
|
return ZTResult.Failed;
|
}
|
|
if (!MoveToChoiceTaskPage())
|
{
|
return ZTResult.Failed;
|
}
|
|
if (!IntoHouse())
|
{
|
return ZTResult.Failed;
|
}
|
|
G.Instance.InfoWriter("成功进入副本");
|
}
|
|
while (true)
|
{
|
//重复刷,直到疲劳值不够了
|
if (this.CancelToken.IsCancellationRequested)
|
{
|
return ZTResult.Cancel;
|
}
|
DateTime startMapTime = DateTime.Now;
|
ZTResult killResult = KillOfMap();
|
StateProvider.Instance.RoleTimePassed = (Int32)(DateTime.Now - startRoleTime).TotalSeconds;
|
StateProvider.Instance.PreMapTime= (Int32)(DateTime.Now - startMapTime).TotalSeconds;
|
if (killResult == ZTResult.Success)
|
{
|
//捡东西
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.V);
|
Thread.Sleep(1000);
|
for (int i = 0; i < 5; i++)
|
{
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.X);
|
Thread.Sleep(RandomUtils.KeyPressDuration * 3);
|
}
|
|
//卖装备并关闭商店
|
SaleEquipment();
|
G.Instance.InfoWriter("单次刷图完成");
|
|
//查询疲劳值
|
Int32 pilaozhi = DnfCVHelper.GetPiLaoZhi(this.GameRect);
|
G.Instance.InfoWriter("疲劳值:" + pilaozhi);
|
if (pilaozhi <= 0)
|
{
|
ExitToTown();
|
return ZTResult.Success;
|
}
|
|
ReplayGame();
|
continue;
|
}
|
else
|
{
|
return killResult;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 是否进入打怪地图
|
/// </summary>
|
/// <returns></returns>
|
public override bool IsEntryMap()
|
{
|
//查找顶端卡勒特之初文字
|
bool findResult = FuncUtils.TimeoutCancelableWrap(2 * 60 * 1000, CancelToken, () =>
|
{
|
using (Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage())
|
{
|
return KaleteCVHelper.ExistKaleteText(image, this.GameRect);
|
}
|
}, 10);
|
|
|
return findResult;
|
}
|
|
/// <summary>
|
/// 进入房间后的预先工作
|
/// </summary>
|
/// <param name="houseIndex"></param>
|
/// <param name="preHouseIndex"></param>
|
public override void EntryHousePrework(int houseIndex, int preHouseIndex)
|
{
|
//移动和发招
|
switch (houseIndex)
|
{
|
case 0:
|
this.Role.SyncMove(new ZTPoint(297, 0));
|
this.Role.ReleaseSkill(HIDCode.R);
|
this.Role.ReleaseSkill(HIDCode.E);
|
|
break;
|
case 1:
|
this.Role.SyncMove(new ZTPoint(241, 0));
|
this.Role.ReleaseSkill(HIDCode.Q);
|
this.Role.ReleaseSkill(HIDCode.W);
|
break;
|
case 6:
|
this.Role.SyncMove(new ZTPoint(139, 90));
|
this.Role.ReleaseSkill(HIDCode.G);
|
break;
|
case 7:
|
this.Role.SyncMove(new ZTPoint(330, 90));
|
this.Role.ReleaseSkill(HIDCode.R);
|
break;
|
case 8:
|
this.Role.SyncMove(new ZTPoint(305, 0));
|
this.Role.ReleaseSkill(HIDCode.H);
|
break;
|
case 13:
|
this.Role.SyncMove(new ZTPoint(-104, 82));
|
this.Role.ReleaseSkill(HIDCode.Q);
|
this.Role.ReleaseSkill(HIDCode.E);
|
break;
|
case 12:
|
this.Role.SyncMove(new ZTPoint(-550, 90));
|
this.Role.ReleaseSkill(HIDCode.T);
|
break;
|
case 17:
|
this.Role.SyncMove(new ZTPoint(-200, 60));
|
this.Role.ReleaseSkill(HIDCode.Q);
|
this.Role.ReleaseSkill(HIDCode.F);//用w代替
|
break;
|
case 16:
|
this.Role.SyncMove(new ZTPoint(-174, 0));
|
this.Role.ReleaseSkill(HIDCode.Y);
|
break;
|
}
|
}
|
|
/// <summary>
|
/// 刷房间
|
/// </summary>
|
/// <returns></returns>
|
private ZTResult KillOfMap()
|
{
|
bool ret = false;
|
DateTime startMapTime = DateTime.Now;
|
if (!IsEntryMap())
|
{
|
G.Instance.InfoWriter("未找到进入卡勒特");
|
return ZTResult.Failed;
|
}
|
G.Instance.InfoWriter("进入卡勒特");
|
Int32 houseIndex = -1;
|
|
//技能加成
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Space);
|
|
//循环刷房间
|
while (true)
|
{
|
DateTime startHouseTime = DateTime.Now;
|
Int32 fromHouseIndex = houseIndex;
|
//看房间号
|
ret = this.MiniMap.GetCurrentHouseIndexWaitTimeout(out houseIndex, null, this.CancelToken, 3 * 1000);
|
if (!ret)
|
{
|
G.Instance.InfoWriter("未找到人物所在房间");
|
return ZTResult.Failed;
|
}
|
|
StateProvider.Instance.HouseIndex = houseIndex;
|
G.Instance.InfoWriter($"进入房间({houseIndex})");
|
|
|
HouseInfo houseInfo = Houses[houseIndex];
|
this.Role.SetHouse(houseInfo);
|
|
|
KillMonsterStateMachine kmsm = new KillMonsterStateMachine(this, houseInfo,this.Role);
|
ZTResult smresult = kmsm.Work(2 * 60 * 1000,fromHouseIndex,this.runningStep);
|
G.Instance.InfoWriter($"房间刷完({houseIndex})");
|
StateProvider.Instance.RoleTimePassed = (Int32)(DateTime.Now - startRoleTime).TotalSeconds;
|
StateProvider.Instance.MapTimePassed= (Int32)(DateTime.Now - startMapTime).TotalSeconds;
|
StateProvider.Instance.PreHouseTime = (Int32)(DateTime.Now - startHouseTime).TotalSeconds;
|
|
runningStep = RunningStep.None;
|
if (smresult == ZTResult.Success)
|
{
|
if (houseInfo.IsEnd)
|
{
|
//所有房间刷完
|
return ZTResult.Success;
|
}
|
|
//刷其它房间
|
continue;
|
}
|
else
|
{
|
return smresult;
|
}
|
}
|
}
|
|
/// <summary>
|
/// 进入指定房间
|
/// </summary>
|
/// <returns></returns>
|
private bool IntoHouse()
|
{
|
bool result = false;
|
//选择卡勒特之初
|
G.Instance.InfoWriter("开始选择卡勒特之初");
|
|
Int32 nandu = 0;
|
if (!SelectKalete(out nandu))
|
{
|
G.Instance.InfoWriter("选择卡勒特之初失败");
|
return false;
|
}
|
G.Instance.InfoWriter("选择卡勒特之初成功,难度:" + nandu);
|
|
|
|
if (nandu != 4)
|
{
|
G.Instance.InfoWriter("开始选择难度");
|
result = SelectNandu(nandu);
|
if (!result)
|
{
|
G.Instance.InfoWriter("选择难度失败");
|
return false;
|
}
|
G.Instance.InfoWriter("选择难度成功");
|
}
|
|
|
//开始
|
G.Instance.InputControl.PressKey(80, HIDCode.Space);
|
return true;
|
}
|
|
/// <summary>
|
/// 选择凛冬
|
/// </summary>
|
/// <returns></returns>
|
private bool SelectKalete(out Int32 nandu)
|
{
|
Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage();
|
|
if (KaleteCVHelper.GetChoiceKaleteNandu(out nandu, image, this.GameRect))
|
{
|
return true;
|
}
|
|
G.Instance.InputControl.MoveToAndClick(new ZTPoint(this.GameRect.Start.X + 568, this.GameRect.Start.Y + 141));
|
Thread.Sleep(5000);
|
image = ScreenCapture.Instance.CaptureScreenReturnImage();
|
if (KaleteCVHelper.GetChoiceKaleteNandu(out nandu, image, this.GameRect))
|
{
|
return true;
|
}
|
|
return false;
|
}
|
|
/// <summary>
|
/// 选择难度
|
/// </summary>
|
/// <param name="rightCan"></param>
|
/// <param name="leftCan"></param>
|
/// <returns></returns>
|
private bool SelectNandu(Int32 nandu)
|
{
|
Int32 count = 4 - nandu;
|
for (int i = 0; i < Math.Abs(count); i++)
|
{
|
if (count < 0)
|
{
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.LeftArrow);
|
}
|
else
|
{
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.RightArrow);
|
}
|
Thread.Sleep(400);
|
}
|
|
Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage();
|
if (!KaleteCVHelper.GetChoiceKaleteNandu(out nandu, image, this.GameRect))
|
{
|
return false;
|
}
|
|
if (nandu == 4)
|
{
|
return true;
|
}
|
|
|
return false;
|
}
|
|
}
|
}
|