private static Point GetAvailPoint(Point pos, string type, bool isLeft) { List <Point> posList = GetPointInner(pos, type, isLeft); List <Point> availPoints = new List <Point>(); foreach (var point in posList) { if (BattleLocationManager.IsPlaceCanMove(point.X, point.Y)) { availPoints.Add(point); } } if (availPoints.Count > 0) { return(availPoints[MathTool.GetRandom(availPoints.Count)]); } return(new Point(-1)); }
private void CheckMove(LiveMonster nearestEnemy) { var moveDis = BattleManager.Instance.MemMap.CardSize; Point aimPos; //决定想去的目标点 bool goX; if (nearestEnemy.Position.X != monster.Position.X) { var x = monster.Position.X + (nearestEnemy.Position.X > monster.Position.X ? moveDis : -moveDis); aimPos = new Point(x, monster.Position.Y); goX = true; } else { var y = monster.Position.Y + (nearestEnemy.Position.Y > monster.Position.Y ? moveDis : -moveDis); aimPos = new Point(monster.Position.X, y); goX = false; } if (!BattleLocationManager.IsPlaceCanMove(aimPos.X, aimPos.Y)) { if (goX)//绕过不可行走区域 { aimPos = MonsterPositionHelper.GetAvailPoint(monster.Position, "side", monster.IsLeft, 1); } else//往前走 { aimPos = MonsterPositionHelper.GetAvailPoint(monster.Position, "come", monster.IsLeft, 1); } } if (aimPos.X != monster.Position.X || aimPos.Y != monster.Position.Y) { BattleLocationManager.SetToPosition(monster, aimPos); } if (monster.ReadMov > 10) //会返回一些ats { monster.AddActionRate((float)(monster.ReadMov - 10) / monster.ReadMov); } monster.MovRound++; }
public static List <Point> GetAvailPointList(Point pos, string type, bool isLeft, int count) { List <Point> posList = GetPointInner(pos, type, isLeft); List <Point> availPoints = new List <Point>(); foreach (var point in posList) { if (BattleLocationManager.IsPlaceCanMove(point.X, point.Y)) { availPoints.Add(point); } } while (availPoints.Count > count) { availPoints.RemoveAt(MathTool.GetRandom(availPoints.Count)); } return(availPoints); }