using RichCreator.Utility;
|
using RichCreator.Utility.CV;
|
using RichCreator.Utility.InputControl;
|
using RichCreator.Utility.Maps;
|
using RichCreator.Utility.Structs;
|
using RichCreator.Utilitys;
|
using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading;
|
using System.Threading.Tasks;
|
|
namespace RichCreator.Dnf
|
{
|
/// <summary>
|
/// 地图信息
|
/// </summary>
|
public abstract class MapInfo
|
{
|
public MapInfo(MapType mapType, ZTRectangle gameRect, CancellationToken cancellationToken)
|
{
|
this.MapType = mapType;
|
this.GameRect = gameRect;
|
this.CancelToken = cancellationToken;
|
this.Role = new DnfRole(gameRect);
|
}
|
|
/// <summary>
|
/// 游戏区域
|
/// </summary>
|
public ZTRectangle GameRect { get; set; }
|
|
/// <summary>
|
/// 小地图
|
/// </summary>
|
public IMiniMap MiniMap { get; set; }
|
|
|
|
/// <summary>
|
/// 取消令牌
|
/// </summary>
|
public CancellationToken CancelToken { get; set; }
|
|
|
/// <summary>
|
/// 地图类型
|
/// </summary>
|
public MapType MapType { get; set; }
|
|
|
|
/// <summary>
|
/// 角色
|
/// </summary>
|
public DnfRole Role { get; set; }
|
|
|
#region Func
|
|
/// <summary>
|
/// 关闭所有弹出窗
|
/// </summary>
|
/// <param name="cancelToken"></param>
|
/// <param name="gameRect"></param>
|
/// <returns></returns>
|
protected void CloseAllAlertWindowByEsc(CancellationToken cancelToken, ZTRectangle gameRect)
|
{
|
GameUtils.CloseAllAlertWindowByEsc(cancelToken, gameRect);
|
}
|
|
/// <summary>
|
/// 关闭所有弹出窗
|
/// </summary>
|
/// <param name="cancelToken"></param>
|
/// <param name="gameRect"></param>
|
/// <returns></returns>
|
protected void CloseAllAlertWindowByX(CancellationToken cancelToken, ZTRectangle gameRect)
|
{
|
GameUtils.CloseAllAlertWindowByX(cancelToken, gameRect);
|
}
|
|
|
|
/// <summary>
|
/// 点击右上角"退到城镇"文字
|
/// </summary>
|
protected void ExitToTown()
|
{
|
G.Instance.DebugWriter("返回城镇");
|
Utility.Structs.ZTPoint point = new Utility.Structs.ZTPoint(this.GameRect.Start.X +667, this.GameRect.Start.Y + 147);
|
G.Instance.InputControl.MoveToAndClick(point);
|
Thread.Sleep(5000);
|
}
|
|
|
|
/// <summary>
|
/// 点击右上角的“再次挑战”
|
/// </summary>
|
protected void ReplayGame()
|
{
|
G.Instance.DebugWriter("重新挑战");
|
Utility.Structs.ZTPoint point = new Utility.Structs.ZTPoint(this.GameRect.Start.X+667, this.GameRect.Start.Y + 87);
|
G.Instance.InputControl.MoveToAndClick(point);
|
}
|
|
/// <summary>
|
/// 出售装备
|
/// </summary>
|
/// <param name="saleButtonRect"></param>
|
protected bool SaleEquipment()
|
{
|
//卖装备并关闭商店
|
ZTRectangle closeButtonRect = ZTRectangle.Empty;
|
ZTRectangle saleButtonRect = ZTRectangle.Empty;
|
if (!DnfCVHelper.HasSaleButton(out saleButtonRect, out closeButtonRect, this.GameRect))
|
{
|
return false;
|
}
|
|
//卖装备
|
G.Instance.InfoWriter("出售装备");
|
G.Instance.InputControl.MoveToAndClick(saleButtonRect.GetCenterPoint());
|
|
//得到装备文字位置
|
ZTRectangle equipmentTextRect = ZTRectangle.Empty;
|
bool result = FuncUtils.TimeoutCancelableWrap(5000, this.CancelToken, () =>
|
{
|
Int32 status = 0;
|
if (DnfCVHelper.GetEquipmentSelectStatus(out equipmentTextRect, out status, this.GameRect))
|
{
|
if (status == 1)
|
{
|
return true;
|
}
|
|
G.Instance.InputControl.MoveToAndClick(equipmentTextRect.GetCenterPoint());
|
}
|
return false;
|
});
|
|
if (!result)
|
{
|
G.Instance.InfoWriter("装备文字未取到");
|
return false;
|
}
|
|
|
|
//开始点,每格步进30
|
ZTPoint startPoint = new Utility.Structs.ZTPoint(equipmentTextRect.End.X - 30, equipmentTextRect.End.Y + 9);
|
List<Int32> points = DnfCVHelper.GetEquipmentIndexs(startPoint);
|
|
for (int i = 0; i < points.Count; i++)
|
{
|
Int32 index = points[i];
|
|
int row = index / 8;
|
int col = index % 8;
|
int x = col * 30 + 15;
|
int y = row * 30 + 15;
|
|
//点窗格
|
G.Instance.InputControl.MoveToAndClick(new Utility.Structs.ZTPoint(startPoint.X + x, startPoint.Y + y));
|
Thread.Sleep(500);
|
//点确定
|
G.Instance.InputControl.Move(0, 0, true, false, false);
|
Thread.Sleep(RandomUtils.MouseClickDuration);
|
G.Instance.InputControl.Move(0, 0, false, false, false);
|
Thread.Sleep(RandomUtils.MouseClickDuration);
|
}
|
G.Instance.DebugWriter("equipment:" + ZTImage.Utils.ConcatString(points.ToArray(), ","));
|
Thread.Sleep(RandomUtils.KeyPressDuration);
|
G.Instance.InputControl.PressKey(RandomUtils.KeyPressDuration, HIDCode.Escape);
|
return true;
|
}
|
#endregion
|
|
|
|
|
#region abstruct func
|
/// <summary>
|
/// 开始刷图
|
/// </summary>
|
/// <returns></returns>
|
public abstract ZTResult Start(Int32 runningStep);
|
|
|
/// <summary>
|
/// 是否已进入地图
|
/// </summary>
|
/// <returns></returns>
|
public virtual bool IsEntryMap()
|
{
|
return true;
|
}
|
|
/// <summary>
|
/// 进入每个房间后的前置工作
|
/// </summary>
|
/// <param name="houseIndex"></param>
|
/// <param name="preHouseIndex"></param>
|
public virtual void EntryHousePrework(Int32 houseIndex, Int32 preHouseIndex)
|
{ }
|
#endregion
|
|
|
|
}
|
}
|