| | |
| | | private const Int32 PaddingLeft = 140;//左边框内边距 |
| | | private const Int32 PaddingRight = 140;//右边框内边距 |
| | | |
| | | public MoveState(ZTRectangle gameRect, MapHouse house) |
| | | public MoveState(ZTRectangle gameRect, HouseInfo house) |
| | | { |
| | | this.gameRect = gameRect; |
| | | this.house = house; |
| | |
| | | private Int32 maxCenterLineY; |
| | | private Int32 centerLineErrorRange = 35;//中间性可允许的误差 |
| | | |
| | | private MapHouse house; |
| | | private HouseInfo house; |
| | | private ZTRectangle gameRect = ZTRectangle.Empty; |
| | | |
| | | private HIDCode moveKey = HIDCode.NoEvent; |
| | | private MoveIntent movingIntent = MoveIntent.ToAttack;//移动意图 |
| | | private MoveIntent movingIntent = MoveIntent.AttackMove;//移动意图 |
| | | private MoveMethod movingMethod= MoveMethod.Vertical;//移动方式,默认垂直移动 |
| | | private ZTSize movingDistance;//移动距离 |
| | | |
| | |
| | | public enum MoveIntent |
| | | { |
| | | None,//没移动 |
| | | ToAttack,//去攻击 |
| | | ToFindDoor,//去找门 |
| | | ToFindRole,//找主角 |
| | | ToPickup//去拾取 |
| | | AttackMove,//去攻击 |
| | | FindDoorMove,//去找门 |
| | | FindRoleMove,//找主角 |
| | | PickupMove//去拾取 |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | get |
| | | { |
| | | if (IsMoving && movingIntent == MoveIntent.ToAttack) |
| | | if (IsMoving && movingIntent == MoveIntent.AttackMove) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | { |
| | | get |
| | | { |
| | | if (IsMoving && movingIntent == MoveIntent.ToFindDoor) |
| | | if (IsMoving && movingIntent == MoveIntent.FindDoorMove) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | { |
| | | get |
| | | { |
| | | if (IsMoving && movingIntent == MoveIntent.ToFindRole) |
| | | if (IsMoving && movingIntent == MoveIntent.FindRoleMove) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | { |
| | | get |
| | | { |
| | | if (IsMoving && movingIntent == MoveIntent.ToPickup) |
| | | if (IsMoving && movingIntent == MoveIntent.PickupMove) |
| | | { |
| | | return true; |
| | | } |
| | |
| | | public void AttackMove(ZTSize moveDistance) |
| | | { |
| | | PutKey(moveDistance); |
| | | movingIntent = MoveIntent.ToAttack; |
| | | movingIntent = MoveIntent.AttackMove; |
| | | } |
| | | |
| | | private Int32 RandomDirRun = 0;//随机行走的方向 |
| | | private const Int32 FindRoleMaxDelayMillSecond = 1000;//找角色开始移动最大延迟 |
| | | private DateTime FindRoleMoveTimeout = DateTime.MinValue;//方向移动过期时间 |
| | | private DateTime FindRoleStartTimeout = DateTime.MinValue;//开始查找主角移动过期时间 |
| | | /// <summary> |
| | |
| | | /// <param name="moveDistance"></param> |
| | | public void FindRoleMove() |
| | | { |
| | | if (IsMoving && !IsFindRoleMoving) |
| | | { |
| | | StopMove(); |
| | | } |
| | | const Int32 FindRoleMaxDelayMillSecond = 1000;//找角色开始移动最大延迟 |
| | | bool recomputationTimeoutTime = false; |
| | | //延迟开始找角色 |
| | | if (!IsMoving) |
| | |
| | | G.Instance.InputControl.PutDown(false, false, false, false, false, false, false, false, dirKey); |
| | | moveKey = dirKey; |
| | | } |
| | | movingIntent = MoveIntent.ToFindRole; |
| | | movingIntent = MoveIntent.FindRoleMove; |
| | | } |
| | | |
| | | |
| | | |
| | | /// <summary> |
| | | /// 拾起物品移动 |
| | | /// </summary> |
| | |
| | | |
| | | //G.Instance.DebugWriter("pickup distance:" + moveDistance.ToString()); |
| | | PutKey(moveDistance); |
| | | movingIntent = MoveIntent.ToPickup; |
| | | movingIntent = MoveIntent.PickupMove; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 找门找怪移动 |
| | | /// 找门移动 |
| | | /// </summary> |
| | | /// <param name="rolePosition"></param> |
| | | public void FindDoorMove(ZTPoint rolePosition) |
| | |
| | | } |
| | | |
| | | PutKey(movingDistance); |
| | | movingIntent = MoveIntent.ToFindDoor; |
| | | movingIntent = MoveIntent.FindDoorMove; |
| | | } |
| | | |
| | | |
| | |
| | | ZTRectangle limitRect = ZTRectangle.Empty; |
| | | |
| | | //达到未移动阀值,可能有障碍物,先攻击,如果攻击后还是无效则上下左右移 |
| | | if (rolePosition == this.roleLastPosition) |
| | | if (rolePosition .Equals( this.roleLastPosition)) |
| | | { |
| | | if (StaticTimerIsStart) |
| | | { |