using RichCreator.Utility;
|
using RichCreator.Utility.Captures;
|
using RichCreator.Utility.CV;
|
using RichCreator.Utility.InputControl;
|
using RichCreator.Utility.Structs;
|
using RichCreator.Utility.Utilitys;
|
using Emgu.CV;
|
using Emgu.CV.Structure;
|
using RichCreator.Jobs;
|
using RichCreator.Jobs.StateMachines;
|
using System;
|
using System.Collections.Generic;
|
using System.Threading;
|
using RichCreator.Utility.Maps;
|
using RichCreator.Utility.Skills;
|
using RichCreator.Dnf;
|
|
namespace RichCreator.Maps.Lindong
|
{
|
/// <summary>
|
/// 凛冬地图
|
/// </summary>
|
public class LindongMap : ShikongzhimenMapBase
|
{
|
public LindongMap(ZTRectangle gameRect, CancellationToken cancelToken) :base(MapType.Lingdong,gameRect,cancelToken)
|
{
|
this.MiniMap = new LindongMiniMap(gameRect);
|
}
|
|
/// <summary>
|
/// 地图的所有房间
|
/// NextIndex=-1,完成
|
/// NextIndex=-2,出错
|
/// </summary>
|
private static readonly HouseInfo[] Houses = new HouseInfo[] {
|
new HouseInfo (0 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (1 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (2 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (3 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (4 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (5 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (6 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (7 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (8 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (9 ,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (10,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (11,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (12,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (13,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (14,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (15,MapType.Lingdong,true ,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (16,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (17,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (18,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1),
|
new HouseInfo (19,MapType.Lingdong,false,new HIDCode[] { HIDCode.A,HIDCode.D,HIDCode.X},null,-1)
|
};
|
|
private Int32 runningStep = RunningStep.None;
|
|
|
/// <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 (!IntoTaskRoom())
|
{
|
return ZTResult.Failed;
|
}
|
|
G.Instance.InfoWriter("成功进入副本");
|
}
|
|
while (true)
|
{
|
//重复刷,直到疲劳值不够了
|
if (this.CancelToken.IsCancellationRequested)
|
{
|
return ZTResult.Cancel;
|
}
|
|
|
DateTime startHouse = DateTime.Now;
|
ZTResult killResult = KillMonster();
|
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();
|
|
Int32 houseTotalSecond = (Int32)(DateTime.Now - startHouse).TotalSeconds;
|
G.Instance.InfoWriter("单次刷图成功,用时:"+(houseTotalSecond/60)+"分"+(houseTotalSecond%60)+"秒");
|
|
//查询疲劳值
|
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 LindongCVHelper.ExistLingdongText(image, this.GameRect);
|
}
|
}, 10);
|
|
if (!findResult)
|
{
|
G.Instance.InfoWriter("未找到进入凛冬的文字");
|
}
|
else
|
{
|
G.Instance.InfoWriter("进入凛冬");
|
}
|
|
return findResult;
|
}
|
|
/// <summary>
|
/// 进入每个房间前的工作
|
/// </summary>
|
/// <param name="houseIndex"></param>
|
/// <param name="preHouseIndex"></param>
|
public override void EntryHousePrework(int houseIndex, int preHouseIndex)
|
{
|
G.Instance.InfoWriter("in lingdong");
|
//移动和发招
|
switch (houseIndex)
|
{
|
case 2:
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.LeftArrow);
|
this.Role.SyncMove(new ZTPoint(-110, 0));
|
G.Instance.InputControl.PressKeys(HIDCode.LeftArrow, HIDCode.G);
|
|
break;
|
case 1:
|
this.Role.SyncMove(new ZTPoint(-480, 80));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.W);
|
break;
|
case 5:
|
//G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.RightArrow);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.R);
|
Thread.Sleep(1000);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.T);
|
break;
|
case 4:
|
this.Role.SyncMove(new ZTPoint(-1150, -50));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.RightArrow);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.E);
|
//Thread.Sleep(1000);
|
//G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.E);
|
break;
|
case 8:
|
this.Role.SyncMove(new ZTPoint(-100, 110));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.RightArrow);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.G);
|
//Thread.Sleep(300);
|
//G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Z);
|
break;
|
case 9:
|
this.Role.SyncMove(new ZTPoint(325, 65));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.R);
|
Thread.Sleep(1000);
|
this.Role.SyncMove(new ZTPoint(300, 0));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.T);
|
break;
|
case 10:
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Q);
|
break;
|
case 12:
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.RightArrow);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.R);
|
Thread.Sleep(1000);
|
this.Role.SyncMove(new ZTPoint(-110, 0));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.T);
|
break;
|
case 13:
|
if (preHouseIndex == 12)
|
{
|
this.Role.SyncMove(new ZTPoint(600, 150));
|
}
|
else
|
{
|
this.Role.SyncMove(new ZTPoint(-300, 200));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.RightArrow);
|
}
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Q);
|
Thread.Sleep(1000);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.E);
|
break;
|
case 14:
|
if (preHouseIndex == 13)
|
{
|
this.Role.SyncMove(new ZTPoint(400, 0));
|
}
|
else
|
{
|
this.Role.SyncMove(new ZTPoint(0, 100));
|
}
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.W);
|
break;
|
|
case 15:
|
this.Role.SyncMove(new ZTPoint(600, 0));
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.H);
|
Thread.Sleep(5000);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Y);
|
break;
|
case 18:
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.W);
|
break;
|
|
}
|
}
|
|
/// <summary>
|
/// 刷房间
|
/// </summary>
|
/// <returns></returns>
|
private ZTResult KillMonster()
|
{
|
bool ret = false;
|
|
if (!IsEntryMap())
|
{
|
G.Instance.InfoWriter("未找到进入凛冬");
|
return ZTResult.Failed;
|
}
|
G.Instance.InfoWriter("进入凛冬");
|
|
Int32 preHouseIndex = -1;
|
Int32 houseIndex = -1;
|
|
|
//技能加成
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Space);
|
|
//循环刷房间
|
while (true)
|
{
|
preHouseIndex = houseIndex;
|
//看房间号
|
ret = this.MiniMap.GetCurrentHouseIndexWaitTimeout(out houseIndex, null, this.CancelToken, 3 * 1000);
|
if (!ret)
|
{
|
G.Instance.InfoWriter("未找到人物所在房间");
|
return ZTResult.Failed;
|
}
|
|
G.Instance.InfoWriter("进入房间->" + houseIndex.ToString());
|
|
HouseInfo houseInfo = Houses[houseIndex];
|
this.Role.SetHouse(houseInfo);
|
DateTime startTime = DateTime.Now;
|
KillMonsterStateMachine kmsm = new KillMonsterStateMachine(this, houseInfo,this.Role);
|
ZTResult smresult = kmsm.Work( 5 * 60 * 1000,preHouseIndex,this.runningStep);
|
Int32 roomTotalSecond = (Int32)(DateTime.Now - startTime).TotalSeconds;
|
G.Instance.InfoWriter("房间刷完,用时:" + (roomTotalSecond / 60) + "分" + (roomTotalSecond % 60) + "秒");
|
|
runningStep = RunningStep.None;
|
if (smresult == ZTResult.Success)
|
{
|
if (houseInfo.IsEnd)
|
{
|
//所有房间刷完
|
return ZTResult.Success;
|
}
|
|
//刷其它房间
|
continue;
|
}
|
else
|
{
|
return smresult;
|
}
|
}
|
}
|
|
|
/// <summary>
|
/// 进入指定房间
|
/// </summary>
|
/// <returns></returns>
|
private bool IntoTaskRoom()
|
{
|
|
bool result = false;
|
//选择凛冬
|
G.Instance.InfoWriter("开始选择凛冬");
|
|
Int32 nandu = 0;
|
if (!SelectLindong(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 SelectLindong(out Int32 nandu)
|
{
|
Image<Rgb, byte> image = ScreenCapture.Instance.CaptureScreenReturnImage();
|
|
if (LindongCVHelper.GetChoiceLingdongNandu(out nandu, image, this.GameRect))
|
{
|
return true;
|
}
|
|
G.Instance.InputControl.MoveToAndClick(new Utility.Structs.ZTPoint(this.GameRect.Start.X + 313, this.GameRect.Start.Y + 462));
|
Thread.Sleep(5000);
|
image = ScreenCapture.Instance.CaptureScreenReturnImage();
|
if (LindongCVHelper.GetChoiceLingdongNandu(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 (!LindongCVHelper.GetChoiceLingdongNandu(out nandu, image, this.GameRect))
|
{
|
return false;
|
}
|
|
if (nandu == 4)
|
{
|
return true;
|
}
|
|
|
return false;
|
}
|
|
|
|
|
}
|
}
|