protected void Create_Standard_Patrol(int End_A, int End_B) { List <int> Route = NetworkMethod.Dijkstrafy_Routes(map, new List <int>() { End_A, End_B }); if (Route.Count > 2) { List <int> Way_Back = new List <int>(); for (int I = Route.Count - 2; I >= 1; I--)//cuts the first and last point - these would just be repeats. { Way_Back.Add(Route[I]); } Route.AddRange(Way_Back); } AIMoveManager.Instance.RemoveFromRR(Route); Default_Route_Waypoints = Create_New_Waypoint_Set(Route); if (Default_Route_Waypoints.Count == Route.Count) { Default_Route_Waypoint_Rooms = Route; } else { Default_Route_Waypoint_Rooms = new List <int>(); for (int I = 0; I < Default_Route_Waypoints.Count; I++) { Default_Route_Waypoint_Rooms.Add(RectMethod.FindWhatRoomLocationIsIn(Default_Route_Waypoints[I], map, out bool VOID)); } } NextWaypointNum = AssignStartingWaypoint(); }
public override PlanStep DecideWhatToDo() { //Vector2 PlayerLoc = StealthManager.Instance.PlayerLoc; if (HaveConfirmedTile && !WaitingforGoAhead && !HasAPlan) {//plan could make enemy face different direction in navigation to player, so shouldn't unconfirm the tile if (StealthMethod.CheckLOS(map, Me.TilePosition, StealthManager.Instance.PlayerLoc) && StealthMethod.CheckFOV(Me.TilePosition, StealthManager.Instance.PlayerLoc, Me.Direction)) { //player in sight, so move confirmed location to him MoveConfirmedPosition(StealthManager.Instance.PlayerLoc); //All behaviour for when seeing the enemy if (RectMethod.DistanceBetweenLocations (Me.TilePosition, StealthManager.Instance.PlayerLoc) == 1) { return(AttackAdjacentEnemy()); } else { return(base.DecideWhatToDo());//act using the usual protocol. } } //if not in sight, then UNCONFIRM else { CancelConfirmedPosition(); // behaviour for not } } // no confirmed tile, but on alert return(base.DecideWhatToDo()); }
protected List <Vector2> Create_New_Waypoint_Set(List <int> RoomIDsInOrder)//for circular routes. //NOTE: These rooms should all be connected. Call Dijkstra's Algorithm to organise the list first. { List <Vector2> Waypoints = new List <Vector2>(); Vector2 Next; for (int I = 0; I < RoomIDsInOrder.Count; I++) { Rectangle RoomArea = map.Rooms[RoomIDsInOrder[I]].Location; if (map.D.Next(0, 100) > 50) { Rectangle CentralArea = new Rectangle(RoomArea.X + (RoomArea.Width / 4), RoomArea.Y + (RoomArea.Height / 4), RoomArea.Width / 2, RoomArea.Height / 2); Next = RectMethod.ReturnRandomEmptyTile(CentralArea, map.Collision.CMap, map.D); if (Next != new Vector2(-1, -1)) { Waypoints.Add(Next); } else { Next = RectMethod.ReturnRandomEmptyTile(RoomArea, map.Collision.CMap, map.D); if (Next != new Vector2(-1, -1)) { Waypoints.Add(Next); } else { //skip it } } } else { Next = RectMethod.ReturnRandomEmptyTile(RoomArea, map.Collision.CMap, map.D); if (Next != new Vector2(-1, -1)) { Waypoints.Add(Next); } else { //skip } } } return(Waypoints); }
public static void CreateandSaveFullMap(Map Map, int Version, bool CollisionOverlay) { RenderTarget2D Target = new RenderTarget2D(ScreenManager.Instance.GraphicsDevice, (int)Map.Size.X * (int)Map.TileDimensions.X, (int)Map.Size.Y * (int)Map.TileDimensions.Y); ContentManager content = new ContentManager(ScreenManager.Instance.Content.ServiceProvider, "Content"); ScreenManager.Instance.GraphicsDevice.SetRenderTarget(Target); ScreenManager.Instance.GraphicsDevice.Clear(Color.Transparent); ScreenManager.Instance.SpriteBatch.Begin(); Rectangle TheWholeMap = new Rectangle(0, 0, (int)Map.Size.X - 1, (int)Map.Size.Y - 1); Map.Draw(ScreenManager.Instance.SpriteBatch, RectMethod.ShrinkHeight(RectMethod.ShrinkWidth(Map.FullMap)), Vector2.Zero, Vector2.Zero); if (CollisionOverlay) { Image Overlay = new Image(); Overlay.Path = CollOverlayPath; Overlay.LoadContent(); Overlay.Alpha = 0.4f; for (int X = 0; X < Map.Size.X; X++) { for (int Y = 0; Y < Map.Size.Y; Y++) { int Collision = Map.Collision.CMap[X, Y]; int CollisionY = (Collision / 10) * 32; int CollisionX = (Collision % 10) * 32; ScreenManager.Instance.SpriteBatch.Draw(Overlay.Texture, new Rectangle(X * 32, Y * 32, 32, 32), new Rectangle(CollisionX, CollisionY, 32, 32), Color.White * Overlay.Alpha); } } } ScreenManager.Instance.SpriteBatch.End(); var ImageStream = new FileStream("Content/Dungeon Imaging/Output/Map_" + Version + "_Final.png", FileMode.Create); Target.SaveAsPng(ImageStream, Target.Width, Target.Height); ImageStream.Close(); ScreenManager.Instance.GraphicsDevice.SetRenderTarget(null); content.Unload(); }
protected void Create_Long_Circuit_Patrol(List <int> Visits)//doesn't have to be sorted { List <int> Route = NetworkMethod.Dijkstrafy_Routes(map, Visits); AIMoveManager.Instance.RemoveFromRR(Route); Default_Route_Waypoints = Create_New_Waypoint_Set(Route); if (Default_Route_Waypoints.Count == Route.Count) { Default_Route_Waypoint_Rooms = Route; } else { Default_Route_Waypoint_Rooms = new List <int>(); for (int I = 0; I < Default_Route_Waypoints.Count; I++) { Default_Route_Waypoint_Rooms.Add(RectMethod.FindWhatRoomLocationIsIn(Default_Route_Waypoints[I], map, out bool VOID)); } } NextWaypointNum = AssignStartingWaypoint(); }
protected virtual Rectangle ThreatLocation() { int BiggestValue = 0; Vector2 BiggestKey = Vector2.Zero; foreach (KeyValuePair <Vector2, int> I in Me.CurrentSuspicions) { if (I.Value > BiggestValue) { BiggestValue = I.Value; BiggestKey = I.Key; } } int RoomIndex = RectMethod.FindWhatRoomLocationIsIn(BiggestKey, map, out bool IsInPassage); if (RoomIndex == Me.CurrentRoomIn) { return(RectMethod.AddABorder(Me.ImmediatelyAhead, 1)); } else { return(CalculateCurrentRoomIn(BiggestKey)); } }
public override bool IsValid(Vector2 tilePositionBeforeStart) { return(RectMethod.TwoTilesAreAdjacent(Location, tilePositionBeforeStart)); }